in my kernel,
global kernel ( …, imax, jmax, kmax, …) {
tx = threadIdx.x; ty = threadIdx.y; tz = threadIdx.z;
dx = blockDim.x; dy = blockDim.y; dz = blockDim.z;
bx = blockIdx.x; by = blockIdx.y; bz = blockIdx.z;
i = dxbx+tx;
j = dyby+ty;
k = tz;
if ((i<=imax) && (j<=jmax) && (k<=kmax)) {
…
/* i don't have any increment of i, j, k */
}
}
it is working fine but once i replace “if” to “while” like
while ((i<=imax) && (j<=jmax) && (k<=kmax)) {
…
/* i don’t have any increment of i, j, k */
}
my code quits right away…it seems the kernel’s never been launched at all.
–
i know in c/c++, all statements following “if” are executed exactly once if the if statement is true,
and all statements following “while” are executed over and over for as long as the while statement remains true.
and i also understand “while” loop may not even run at all.
–
in CUDA, i think its no different i guess.
then for my case why “if” statement is working but “while” statement is not?
without any increment of i j k, it must run at least once in my opinion.
any comments are welcome. and thanks in well advance.