Can a kernel function use two conditional statements with different ranges?

In a single kernel function, can we enable two commands with different condition ranges? For example, in a two-dimensional problem, the first condition executed is if (i>0 && i<imax); j=1. The second condition is if (j>0 && j<jmax); i=1. Would executing in this way lead to errors?

j=1;
if(i>0 && i<imax)
{
A[i][j]=…
}

i=1;
if(j>0&&j<jmax)
{
A[i][j]=…
}

Its certainly legal to do that, just as it would be in C++.

I don’t know if this is spanning multiple threads, but if it results in multiple threads potentially writing to the same location A[i][j], then you might have to sort out simultaneous access in order to get the result you expect.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.