Create a SIMD[DType.address] from a DTypePointer[T]
It would seem like DTypePointer[T].address_of(SIMD[T) would be correct, but this returns a DTypePointer aswell, which has type T, not DType.address. A bitcast seems incorrect as this would directly cast the numeric value into a pointer location, which is wrong, and I do not feel that loading the data as an address is the correct answer either. Hoping to use gather and scatter on SIMD vectors from a DTypePointer if possible.
11 Replies
Congrats @benny, you just advanced to level 8!
I had the same question. 🙂
any luck? i’m still stuck
Same
I think since 24.1.0 you can write int(p) and get the int representation of the pointer address, so I thought maybe I can wrap it in SIMD[DType.address,1] but this also doesn’t work. I have a feeling it’s something which was introduced early, but now needs reworking so until it’s done, nobody wants to talk about it 😀.
@Jack Clayton any insight on this?
still havent found a solution
Hi @benny is this what you're looking for:
Or are you trying to fill a SIMD vec with addresses?
that is the issue yes
for potentially use with gather / scatter (that’s the required input)
i figured once stdlib is open sourced their may be some use of what i’m trying to do in there I can look for, but until then I got nothing
Ok haven't seen that, asking the team
You should be able to do
SIMD[DType.address](int(my_pointer))
E.g.
sadly print on DType.address is broken right now. Will fixperfect! thank you so much :)
Finally, we can try to actually use gather/scatter based on this. There is an open change request to make that way less clunky but Mojo team considers it 'just semantic sugar'. Kind request for the first successful example code using gather and scatter to be shared amongst mojicans !