I have a matrix in global memory that has nx columns and ny rows.
Each element is a float.
The kernel has to search all elements that are greater than a constant float passed to the kernel.
Is it possible implementing it without an if statement ?
If I understand correctly, if statement in kernel can harm performance.
An if statement in itself is not an issue. It’s only if the “if/else” sections both exist and have sizable contents that divergence really hurts. Try writing it and see the performance.
On a side note, you might also want to use thrust::transform/copy_if depending if you need dense/sparse output instead of writing your own kernels.
Thank you very much !