简体   繁体   中英

CUDA combined with OpenMP

I saw a few threads on this but they don't seem to relate to the problem I'm having.

I have my CUDA code which works, but I want to parallelize the for loops that are running asynchronously with the kernel code (and after the kernel has finished as well).

I seem to be having a linking problem though... the errors are as such.

.../lib/liblalinference.so: error: undefined reference to 'omp_get_num_threads'

.../lib/liblalinference.so: error: undefined reference to 'omp_get_thread_num'

.../lib/liblalinference.so: error: undefined reference to 'GOMP_barrier'

.../lib/liblalinference.so: error: undefined reference to 'GOMP_single_start'

.../lib/liblalinference.so: error: undefined reference to 'GOMP_critical_start'

.../lib/liblalinference.so: error: undefined reference to 'GOMP_critical_end'

.../lib/liblalinference.so: error: undefined reference to '__gxx_personality_v0'

.../lib/liblalinference.so: error: undefined reference to 'GOMP_parallel_start'

.../lib/liblalinference.so: error: undefined reference to 'GOMP_parallel_end'

First I'd like to point out that I have had opemMP work before but in a separate section where I compiled the C code with

CFLAGS = -g -O2 *many flags here* -fopenmp

Everything else there is extraneous information, the important part is that I just had to add the -fopenmp to the flag line in the makefile.

However, since CUDA is all complex and such with using nvcc which sort of uses a c++ compiler as its backbone (right?), I seem to be at a loss. When I add -fopenmp to

CPPFLAGS =  ... *many cuda flags* -fopenmp

I get the stated errors above.

I've even tried

CPPFLAGS =  ... *many cuda flags* -fopenmp -lgomp

It is also noted that when I configure my project the GCC flags are disabled when CUDA is enabled.

Where am I going wrong? Do I need to put the flag(s) elsewhere? Do I need to give up?

I found out that it worked when I did the following.

nvcc flags -Xcompiler -fopenmp -fgomp file stuffs

Thanks to Tudor

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM