Using C++ thread with OpenACC

I would like to know, is it possible to use OpenACC mixing with C++ thread library?

For example
I have a program where I created 8 threads and within each thread will run the same program that has been enabled OpenACC.

I also wrote a program to run OpenACC inside threads (on the CPU created by C ++ thread library, I used std :: async) and it ran successfully. However, there is one problem: share memory and resident memory are not freed and causes the program to kill the operating system.

Hi hungmol,

Using OpenACC within a C++ thread is not something we’ve tested nor have I heard of anyone trying it before, so your blazing trail here.

In theory, it should work, with the main issue being the device data management as you discovered. Things like Thread-local storage (TLS) are known not to work since the compiler can’t tell which copy of the TLS data to use under which context and that there are multiple copies.

For shared memory I would think it should be ok provided the device data management was done by the master thread and all threads were using the same GPU. Though for multi-GPUs, each thread will need to manage it’s own data management of the shared data.

Do you have an example of the code your using that I could take a look at? Again, I haven’t tried this myself, but I might be able to help determine how to make it work for you.