Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an easy way to use clang with Open MPI?

Tags:

clang

openmpi

OpenMPI strongly recommends using their wrapper compilers. Behind the scenes, their wrapper compiler mpiCC calls gcc (by default?) and adds the necessary flags for MPI code to compile. However, other compilers give more descriptive error messages than gcc (e.g. clang which is also GCC-compatible). So, I'd like to be able to use clang with Open MPI.

I tried:

1) finding an mpiCC option for specifying the compiler, but

mpiCC --help

just spits out the g++ help page.

2) using the --showme:compile option

mpiCC --showme:compile ./test-boost.cc -lboost_mpi -lboost_serialization -o test-boost

which, instead of calling gcc, prints the flags needed for compiling the MPI code. I can then use those with clang (since it's GCC-compatible). This should work, but I'm looking for an easier solution.

like image 266
Ammar Avatar asked Jan 22 '13 17:01

Ammar


2 Answers

Setting OMPI_CC=clang or OMPI_CXX=clang++ as environment variables in .bashrc, as described in the official FAQ of OpenMPI, is NOT working for me. I have to attach them ahead whenever I use mpicc, e.g.

OMPI_CC=clang mpicc --showme:command

So in Makefile, I set CC=OMPI_CC=clang mpicc, which works well for me.

like image 121
oracleyue Avatar answered Jan 24 '23 03:01

oracleyue


Open MPI FAQ says which environmental variables can be set to override the default choice of the compiler called by the wrapper.

http://www.open-mpi.org/faq/?category=mpi-apps#override-wrappers-after-v1.0

Depending on the version of OpenMPI you should set OMPI_CXX=clang++ or OMPI_MPICC=clang. For OpenMPI v.1.1 and later use OMPI_CXX and then call the wrapper compiler. The wrapper would call clang++ in turn.

like image 29
Dmitri Chubarov Avatar answered Jan 24 '23 03:01

Dmitri Chubarov