How can I synchronize threads in Optix?

NVIDIA Optix programming guide says that I can’t use syncthreads in optix cu files

How I can do it in my ray gen program?

What exactly is the problem you want to solve which requires to sync threads?

I want to visualize edges on mesh

In ray gen program after calling rtTrace I compare polygon indices on adjacent pixels, and if they are not equal i draw black pixel

When the image is moving near this lines appears artifacts. I suppose it’s because of asunc of threads

If there are any other ways of visualizing I’ll be glad to consider it

Right, for that to work all IDs would have to be present for the edge detection, and there is no way to make sure the information of adjacent pixels is valid when doing this in the same ray generation program while rendering the image.

That edge detection could easily be done in a second pass.
Either with a second entry point and a ray generation program which does that 2D processing (no rtTrace in that) or even faster by moving this into a GLSL fragment shader applied when displaying the final image to the screen.

For either method you would need to output the polygon ID into a separate buffer.

When doing that during the display post-process, create a buffer backed up by a pixel buffer object rtCreateBufferFromBO(), move that into an OpenGL texture (like the main image) and apply a small fragment program which does a Laplace like filter during the final texture blit to the screen while reading both the color data and the polygon IDs from the textures.

Yes, Detlef’s suggestion is spot on. One thing you have to think about with OptiX is that it is a single ray programming model. In other words the launch indices can be done in any order. If you need to rely on information that a neighboring ray may produce, you can’t enforce this sort of ordering of execution.

I tried 2 entry points in my program and it works well.

Thank you very much for reply.