[OptiX] Using shared memory in OptiX

Can I use shared memory in OptiX to optimize access to buffers? I haved read blog Questions re OptiX implementation but it is posted in 2013.
Thanks in advance!

Hi @novice,

The advice from 2013 still applies today, you can read about the reason for this in the current OptiX Programming Guide:

“For efficiency and coherence, the NVIDIA OptiX 7 runtime—unlike CUDA kernels—allows the execution of one task, such as a single ray, to be moved at any point in time to a different lane, warp or streaming multiprocessor (SM). (See section “Kernel Focus” in the CUDA Toolkit Documentation.) Consequently, applications cannot use shared memory, synchronization, barriers, or other SM-thread-specific programming constructs in their programs supplied to OptiX.” https://raytracing-docs.nvidia.com/optix7/guide/index.html#introduction#overview

This is becoming especially relevant today with the upcoming Shader Execution Reordering feature on Ada generation hardware, which will allow OptiX users to explicitly move threads to different lanes and SMs in order to gain more execution coherence.

One potential (and probably obvious) alternative option if you need shared memory is to execute CUDA kernels before or after your OptiX launch, if your render can be separated into distinct phases with and without shared memory. OptiX launches respect CUDA streams, dependencies, and priorities, so you can mingle and synchronize OptiX launches and CUDA launches at the kernel level.


David.

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