Static linking nvcc and openmp

Hi All,

I have two questions, I’d be very grateful for any help with either :-)

  1. Is it possible to static link against openmp libs? To compile I currently do…

nvcc -arch=sm_13 -O3 -Xcompiler -fopenmp -lgomp -Xcompiler -msse4.1 -o Cuda16

but because I compile on one machine (fedora 9) then run on rhel4 I find that i get a seg fault.
If i take out the openmp stuff the code runs as expected. So I’m guessing a static linking against the openmp libs will sort this out, only when I try nvcc gives me an error.

  1. is it possible to compile with intel icc? if so how is this done?

Thanks and best wishes,


Your OpenMP problem will definitely be compiler/OpenMP library version difference related. RHEL 4 uses Redhat’s own back port of OpenMP to gcc 4.1, whereas Fedora core 9 is gcc 4.3, which has OpenMP support out of the box. They aren’t the same (the old gcc 4.1 OpenMP performance is truly horrible). What you might be able to do is pass libgomp.a directly to the linker. The CUDA runtime itself doesn’t support static linking, so you might have to compile your device code to objects and the link them with gcc, but I can’t see any obvious reason the linking wouldn’t work. glibc compatiblity is probably going to be the one to watch. While there is usally a degree of backwards compatibility, code compiled for a newer libc often won’t run on a system with an older libc.

Some people have claimed to be able get icc to work with the CUDA driver API, but I don’t think you can use it with the runtime API. Or if you can is it going to be a very ugly hack.

Thanks for the reply.

Could someone outline how I’d go about doing this?



At a bare minimum, try replacing -lgomp with libgomp.a (I think you should be using a -Xlinker option for those linking arguments rather than -Xcompile as you are doing now).