Does Optix support multi-thread host application?

Hi,

My project need to update mesh vertices each frame, so I have to ‘mark Dirty’ to update accelerate data structures every frame. When I use visual profiler to optimize the program, I realized there is a long GPU idle time, more than 20ms, after calling the Optix ‘launch’. I’ve tried different accelerator/travellers, but no big different.

I’m wondering is it possible to use a separate host thread update scene by calling ‘launch(0, 0)’, then I can utilize the GPU idle time to do some other CUDA based computation? And how much benefit can I get from it?

Straight from the OptiX Programming Guide, last paragraph before the appendix:
“Currently, OptiX is not guaranteed to be thread-safe. While it may be successful in some applications to use OptiX contexts in different host threads, it may fail in others. OptiX should therefore only be used from within a single host thread.”

The separate launch(0,0) wouldn’t free the GPU anyways if the acceleration structure builder is running on the GPU.

For maximum acceleration building performance try Lbvh.
If you have rtPrintf() in your OptiX programs, benchmark without as well.

Hi Detlef,

Thanks a lot for the helpful reply. I’v tried Lbvh/Bvh accelerator today, that seems to be 20~30% faster than other accelerator. That’s really cool!

And as you said, the GPU are not free when building the acceleration structure, there are a lot host to device memory copy and GPU computation during the structure building period. Then if I move some computation back to the host, and make it simultaneously with the launch(0, 0), maybe I can ‘hide’ the time cost. Am I right?

The increased acceleration structure building speed of the Lbvh unfortunately comes with a slower rendering performance, but if the acceleration structure building performance is paramount, it’s the best choice.
There is an additional method to increase the acceleration structure building speed of animated models even more by using refitting.

Please have a look into this year’s GTC presentations.
Go here: GTC 2022: #1 AI Conference
and search for “ray tracing”
As OptiX beginner watch the “GPU Ray Tracing Using OptiX” presentation and for optimizations watch the “Advanced OptiX Programming and Optimization”. Minutes 22:00-31:00 explain the refitting.

Yes, you might try to do some tasks in parallel on the CPU, but note that OptiX can also do some tasks with multi-threading. Search the reference guide for RT_CONTEXT_ATTRIBUTE_CPU_NUM_THREADS.