You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[kernel]pubfnlife(mutout:DisjointSlice<[f32;SIZE]>){let idx = thread::index_1d();let a = match out.get_mut(idx){Some(a) => a,None => return,};for i in0..SIZE{
a.get_mut(i).map(|e| *e = 42.);}// This works as expected.//// for e in a {// *e = 42.;// }}
Write through get_mut() doesn't end up being persisted in out. Out remains all zeroes. Compiles fine.
What do you see in the out that comes out of the kernel?
When I try to use get_mut(i) I get a compile error since the API changed to take a ThreadIndex a little while ago. If you do end up upgrading your cuda-oxide install, beware of #49 .
I don't know enough about the SIMT model to know if it is safe to access a destination cell that is not assigned to your thread. The APi I most recently checked out does not have a safe route to do it. I modified my app to include
for i in 0..5000 {
unsafe {
*dst.as_mut_ptr().add(i) = 77;
}
}
and it behaved as I expected.
Under normal circumstances I would be worried about a race condition, since I hypothesize that multiple SIMT threads would be trying to perform the same iteration and I am not sure if there is a defined order in which each thread would write 42.0 to any particular cell. Since they all write 42.0 the effect would be the same, but if the computation were more complex it may become a problem.
I should have been clearer on which get_mut I meant. It's this one:
for i in0..SIZE{
a.get_mut(i).map(|e| *e = 42.);}
Each a reference is unique to each thread as per the ThreadIndex guard from the lines above the loop. out remains unchanged (all arrays are filled with zeroes as it was initialized to zeroes).
Activity
mutantbob commentedon May 15, 2026
What do you see in the
outthat comes out of the kernel?When I try to use
get_mut(i)I get a compile error since the API changed to take aThreadIndexa little while ago. If you do end up upgrading your cuda-oxide install, beware of #49 .I don't know enough about the SIMT model to know if it is safe to access a destination cell that is not assigned to your thread. The APi I most recently checked out does not have a
saferoute to do it. I modified my app to includeand it behaved as I expected.
Under normal circumstances I would be worried about a race condition, since I hypothesize that multiple SIMT threads would be trying to perform the same iteration and I am not sure if there is a defined order in which each thread would write 42.0 to any particular cell. Since they all write 42.0 the effect would be the same, but if the computation were more complex it may become a problem.
DanilSerd commentedon May 15, 2026
I should have been clearer on which
get_mutI meant. It's this one:Each
areference is unique to each thread as per theThreadIndexguard from the lines above the loop.outremains unchanged (all arrays are filled with zeroes as it was initialized to zeroes).This variant results in the same bug:
This variant results in a compile time error:
Which is good.
fix(mir-importer): compute element addresses through fat-pointer derefs
Merge origin/main into fix/issue138-noop-drop-glue-v2
Add unsafe device pointer support for AsyncKernelLaunch and remove Wi…