I have always assumed that renderscripts are threadsafe with forEach across an allocation. To aid in my debugging, can someone confirm this?
(I'm seeing a static array value check succeed, but using rsDebug shows that the check should have failed.
static uint32_t state[16];
static void f(); // modifies state.
/* snip... */
void
root(const uint32_t *in, uint32_t *out)
{
/* snip... */
f();
if(state[0] == 0)
{
rsDebug("state[0]", state[0]);
*out = 1;
}
}
I see printed state[0] with a nonzero value!)
Each cell is expected to execute independently of the other cells. If you are writing to other cells of your input (or output) Allocation, you can certainly trigger undefined behavior. This is no different than any other multithreaded computation model, however. Can you show your kernel code exactly and describe how you are calling it?