Matt John
Matt John

Reputation: 145

Autotools issues when linking with OpenMP, MPI and CUDA

I have a project that is compiled with autotools and up until this week needed to be only compiled with OpenMP and MPI support. I have now added a CUDA kernel that I wish to compile into the code under certain circumstances. The compiling of the code goes okay and all of the object files are created. When it comes to linking the objects into the executable the following command is used:

/bin/bash ../libtool --tag=CXX --mode=link nvcc -ccbin=mpicxx -I/usr/local/cuda/include -Xcompiler -std=c++0x -Xcompiler -fopenmp -L/usr/local/cuda/lib64 -lcuda -lcudart -lcufft -o utrplauncher utrplauncher-UTRP.o crossovers/libcrossovers.a initialisers/libinitialisers.a mutators/libmutators.a problem/libproblem.a common/libcommon.a variables/libvariables.a ../libraries/framework/libmoeaframework.a ../libraries/ticpp/libticpp.a

Which in turn generates the follwong link command

libtool: link: nvcc -ccbin=mpicxx -I/usr/local/cuda/include -std=c++0x -fopenmp -o utrplauncher utrplauncher-UTRP.o -L/usr/local/cuda/lib64 -lcuda -lcudart -lcufft crossovers/libcrossovers.a initialisers/libinitialisers.a mutators/libmutators.a problem/libproblem.a common/libcommon.a variables/libvariables.a ../libraries/framework/libmoeaframework.a ../libraries/ticpp/libticpp.a

This the generates the following error because the -std=c++0x and -fopenmp are interpreted by the CUDA compiler and not the mpicxx compiler.

nvcc fatal   : Value 'c++0x' is not defined for option 'std'

I can post my configure.ac if that would help but wanted to keep the question concise at the moment.

My question is therefore is it possible to forward the -Xcompiler flags to the mpicxx compiler rather than having them stripped off by libtool?

Upvotes: 2

Views: 591

Answers (1)

Grzegorz Szpetkowski
Grzegorz Szpetkowski

Reputation: 37944

One way is to pass both -Xcompiler=-std=c++0x and -Xcompiler=-fopenmp directly to the compiler using -Wc,, thus -Xcompiler is not stripped by libtool. For instance following dry-run:

libtool -n --tag=CXX --mode=link nvcc -ccbin=mpicxx-I/usr/local/cuda/include -Wc,-Xcompiler=-std=c++0x -Wc,-Xcompiler=-fopenmp -L/usr/local/cuda/lib64 -lcuda -lcudart -lcufft -o utrplauncher utrplauncher-UTRP.o crossovers/libcrossovers.a initialisers/libinitialisers.a mutators/libmutators.a problem/libproblem.a common/libcommon.a variables/libvariables.a ../libraries/framework/libmoeaframework.a ../libraries/ticpp/libticpp.a

generates:

libtool: link: nvcc -ccbin=mpicxx-I/usr/local/cuda/include -Xcompiler=-std=c++0x -Xcompiler=-fopenmp -o utrplauncher utrplauncher-UTRP.o -L/usr/local/cuda/lib64 -lcuda -lcudart -lcufft crossovers/libcrossovers.a initialisers/libinitialisers.a mutators/libmutators.a problem/libproblem.a common/libcommon.a variables/libvariables.a ../libraries/framework/libmoeaframework.a ../libraries/ticpp/libticpp.a

Upvotes: 1

Related Questions