chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.79k stars 421 forks source link

Support 'var' intent on gpuizables loop #25972

Open stonea opened 1 month ago

stonea commented 1 month ago

Currently we error out (saying that var intents aren't supported for foreach) if you attempt something like this:

foreach i in 1..100 with (var x = new MyThing()) { } 

But this might be a useful way of making a thread-private variable for a gpuizable loop (which might be useful in cases where @gpu.itersPerThread is not 1).

e-kayrakli commented 1 month ago

I bumped into a case where I needed this. In my case, I am using curand to have a per-thread RNG for a Monte Carlo simulation. I realized that the RNG initialization was my bottleneck. So, I wanted to use gpu.itersPerThread combined with a thread-private RNG.

In this particular case, doing it manually was relatively easy and non-heroic. Therefore, this is not a blocker for me, but with itersPerThread, it would certainly be a valuable addition.