mpicc with no warning when compiling

2019-06-13 16:22发布

问题:

I would like to know what flag to use in order to avoid warning messages that appear when compiling a C/C++ parallel using mpicc. More specifically, I prefer not to have my screen of messages referring to unused variables,e.g. warning: unused variable

Thanks

回答1:

Most (?) MPI compiler wrappers will pass compiler options to the compiler that they wrap. so you should be able to use the same flag, for mpicc, that you would use for your compiler unwrapped.

For a better answer: consult the source of your installation of mpicc which is generally implemented (on Linux systems) as a shell script. Many versions also respond to -help and similar.



回答2:

As pointed by High Performance Mark, mpicc is simply a wrapper around the real compiler toolchain. There is an almost standard option that (almost) all wrappers understand: -showme. It shows you what flags exactly get passed on to the compiler, e.g.:

$ mpicc -showme
icc <lots of preprocessor flags> -fexceptions -pthread \
    <lots of linker flags> -lmpi -losmcomp -lrdmacm -libverbs -lrt \
    -lnsl -lutil -lpsm_infinipath -lbat -llsf -ldl -lm -lnuma

Examine these options, consult your compiler's manual and find out how to suppress the warnings.



回答3:

depending on your compiler , you can add flags to avoid such warning messages, for instance -w is the GCC-wide option to disable warning messages.