Tasks in 7.4 (is compilation of multiple modules safe in same task pool?)

I did not find any posts in this forum here about the new “Tasks” feature of OptiX 7.4 and I wonder whether the thread pool itself is so called “thread-safe” among OptiX modules. Is it ?
When I first thought about this new feature, I assumed that multiple OptiX modules can be compiled simultanouesly, but when I looked into the example code, it seems, that the example only shows one OptiX module compilation done by tasks.

In the “optixCompileWithTasks” example the function “compileModuleWithTasks()”
shows the case where several PTX files of one OptiX module can be processed
serially in the loop using g_pool.executeTaskAndWait(); Ok, I understand.

But when I would call g_pool.executeTask() instead, would it be safe to run
all PTX files of all OptiX modules with that one pool execution?
(of course using different “OptixModule” as param for “optixModuleCreateFromPTXWithTasks()” for several PTX files)
The “ThreadPool” struct has no method to wait for all the tasks, when executed asynchronous. Is this simply based on the fact, that its only an example code?

Is it correct to obtain progress information about the already completed count of
finished tasks, by “optixModuleGetCompilationState()” ?
Is it safe to use this function with multiple OptiX modules at the same time?

Thank you!

Hi @m001!

Yes, OptiX Tasks are thread safe. Specifically, optixTaskExecute() is the function you will probably want to call from multiple separate threads. OptiX does not manage a thread pool for you, and using threads is not required when dealing with OptiX Tasks. But you can use your own thread management to execute multiple tasks in parallel. This design allows use of any threading library or parallel execution structure you might have. Please note that, yes, the ThreadPool code in the SDK sample is not part of the OptiX API, it’s purely an example for educational purposes, and you can & should customize it to suit your needs, or use your own library.

BTW, OptiX Modules could already be compiled simultaneously on different threads prior to OptiX 7.4. The new Tasks API is enabling a finer granularity of parallelism, which is the ability to compile multiple pieces of a single module in parallel using multiple threads.

We have a presentation online from Fall GTC last year that covers the Tasks API in more detail: What's New in OptiX | NVIDIA On-Demand


David.

1 Like

Great Video! Thanks for sharing.

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