I have a kernel that do atomic for each thread in a block. If the addition exceeds certain value, there is no point from running the remaining threads in a block.
So is there a way to kill a block on a certain condition to free the multiprocessor?
using return; will only kill the given thread right?
I can’t see that any such thing would be needed. In your code, every thread would do a test anyway, afaik letting just one thread do a test will make the other threads in the block wait.
Further, atomic functions return the old value, so it would be easy to detect the stop condition without performing an additional read, and let all threads return through their own code.
e.g.
#define LIMIT 345.666f // or whatever
…
float value = 3.3f; // substitute you calculation
if (atomicAdd( &myglobalfloatvar, value ) + value >= LIMIT) return;
…
wil do just fine afaik(, assuming compute capability 2.0 for the floats, otherwise similar with int’s)
I can’t see that any such thing would be needed. In your code, every thread would do a test anyway, afaik letting just one thread do a test will make the other threads in the block wait.
Further, atomic functions return the old value, so it would be easy to detect the stop condition without performing an additional read, and let all threads return through their own code.
e.g.
#define LIMIT 345.666f // or whatever
…
float value = 3.3f; // substitute you calculation
if (atomicAdd( &myglobalfloatvar, value ) + value >= LIMIT) return;
…
wil do just fine afaik(, assuming compute capability 2.0 for the floats, otherwise similar with int’s)