Re: [CMake] CMake + MPI

2015-09-09 Thread Chuck Atkins
>
> The only exception to that (which I am aware of) is if you are on a CRAY
> system where the MPI (and BLAS and LAPACK) are baked into the compiler
> wrappers (cc, ftn, etc). In those situations, you actually do not want to
> run find_package(MPI) or it will throw errors.
>

Not true.  The FindMPI.cmake module performs the appropriate introspection
to check if your primary compiler wraps accordingly.  For example, on a
Cray XC30, with the PrgEnv-pgi and cray-mpich modules loaded:

p02064@swan:~/Code/tmp/build> cat ../source/CMakeLists.txt
cmake_minimum_required(VERSION 3.3)
project(TestMPI C CXX)

find_package(MPI REQUIRED)

add_executable(test-mpi-c test-mpi.c)
target_include_directories(test-mpi-c PRIVATE ${MPI_C_INCLUDE_PATH})
target_link_libraries(test-mpi-c ${MPI_C_LIBRARIES})

add_executable(test-mpi-cxx test-mpi.cxx)
target_include_directories(test-mpi-cxx PRIVATE ${MPI_CXX_INCLUDE_PATH})
target_link_libraries(test-mpi-cxx ${MPI_CXX_LIBRARIES})
p02064@swan:~/Code/tmp/build>

p02064@swan:~/Code/tmp/build> cmake ../source
-- The C compiler identification is PGI 15.7.0
-- The CXX compiler identification is PGI 15.7.0
-- Check for working C compiler: /opt/cray/craype/2.4.1/bin/cc
-- Check for working C compiler: /opt/cray/craype/2.4.1/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /opt/cray/craype/2.4.1/bin/CC
-- Check for working CXX compiler: /opt/cray/craype/2.4.1/bin/CC -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found MPI_C: /opt/cray/craype/2.4.1/bin/cc
-- Found MPI_CXX: /opt/cray/craype/2.4.1/bin/CC
-- Configuring done
-- Generating done
-- Build files have been written to: /home/users/p02064/Code/tmp/build
p02064@swan:~/Code/tmp/build>

p02064@swan:~/Code/tmp/build> grep '^MPI_.*' CMakeCache.txt | grep -v
INTERNAL
MPI_CXX_COMPILER:STRING=/opt/cray/craype/2.4.1/bin/CC
MPI_CXX_COMPILE_FLAGS:STRING=
MPI_CXX_INCLUDE_PATH:STRING=
MPI_CXX_LIBRARIES:STRING=
MPI_CXX_LINK_FLAGS:STRING=
MPI_CXX_NO_INTERROGATE:STRING=/opt/cray/craype/2.4.1/bin/CC
MPI_C_COMPILER:STRING=/opt/cray/craype/2.4.1/bin/cc
MPI_C_COMPILE_FLAGS:STRING=
MPI_C_INCLUDE_PATH:STRING=
MPI_C_LIBRARIES:STRING=
MPI_C_LINK_FLAGS:STRING=
MPI_C_NO_INTERROGATE:STRING=/opt/cray/craype/2.4.1/bin/cc
MPI_EXTRA_LIBRARY:STRING=MPI_EXTRA_LIBRARY-NOTFOUND
MPI_LIBRARY:FILEPATH=MPI_LIBRARY-NOTFOUND
p02064@swan:~/Code/tmp/build>

p02064@swan:~/Code/tmp/build> make
[ 25%] Building C object CMakeFiles/test-mpi-c.dir/test-mpi.c.o
[ 50%] Linking C executable test-mpi-c
[ 50%] Built target test-mpi-c
[ 75%] Building CXX object CMakeFiles/test-mpi-cxx.dir/test-mpi.cxx.o
[100%] Linking CXX executable test-mpi-cxx
[100%] Built target test-mpi-cxx
p02064@swan:~/Code/tmp/build>

As you can see from the resulting cache, the FindMPI module knows how to
act accordingly even when mpi libraries are folded into the regular
compiler.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] CMake + MPI

2015-09-09 Thread Tim Gallagher
That's good to know -- it looks like that capability was added 3 months after 
we wrote our CMakeLists.txt and we had to skip the find_package if we used a 
cray. That was 2011 and we never looked back at it because it worked. 

I guess I can go ahead and update that! 

Tim 

- Original Message -

From: "Chuck Atkins" <chuck.atk...@kitware.com> 
To: "tim gallagher" <tim.gallag...@gatech.edu> 
Cc: "Andreas Naumann" <andreas-naum...@gmx.net>, cmake@cmake.org 
Sent: Wednesday, September 9, 2015 11:11:27 AM 
Subject: Re: [CMake] CMake + MPI 






The only exception to that (which I am aware of) is if you are on a CRAY system 
where the MPI (and BLAS and LAPACK) are baked into the compiler wrappers (cc, 
ftn, etc). In those situations, you actually do not want to run 
find_package(MPI) or it will throw errors. 




Not true. The FindMPI.cmake module performs the appropriate introspection to 
check if your primary compiler wraps accordingly. For example, on a Cray XC30, 
with the PrgEnv-pgi and cray-mpich modules loaded: 

p02064@swan:~/Code/tmp/build> cat ../source/CMakeLists.txt 
cmake_minimum_required(VERSION 3.3) 
project(TestMPI C CXX) 

find_package(MPI REQUIRED) 

add_executable(test-mpi-c test-mpi.c) 
target_include_directories(test-mpi-c PRIVATE ${MPI_C_INCLUDE_PATH}) 
target_link_libraries(test-mpi-c ${MPI_C_LIBRARIES}) 

add_executable(test-mpi-cxx test-mpi.cxx) 
target_include_directories(test-mpi-cxx PRIVATE ${MPI_CXX_INCLUDE_PATH}) 
target_link_libraries(test-mpi-cxx ${MPI_CXX_LIBRARIES}) 
p02064@swan:~/Code/tmp/build> 

p02064@swan:~/Code/tmp/build> cmake ../source 
-- The C compiler identification is PGI 15.7.0 
-- The CXX compiler identification is PGI 15.7.0 
-- Check for working C compiler: /opt/cray/craype/2.4.1/bin/cc 
-- Check for working C compiler: /opt/cray/craype/2.4.1/bin/cc -- works 
-- Detecting C compiler ABI info 
-- Detecting C compiler ABI info - done 
-- Check for working CXX compiler: /opt/cray/craype/2.4.1/bin/CC 
-- Check for working CXX compiler: /opt/cray/craype/2.4.1/bin/CC -- works 
-- Detecting CXX compiler ABI info 
-- Detecting CXX compiler ABI info - done 
-- Found MPI_C: /opt/cray/craype/2.4.1/bin/cc 
-- Found MPI_CXX: /opt/cray/craype/2.4.1/bin/CC 
-- Configuring done 
-- Generating done 
-- Build files have been written to: /home/users/p02064/Code/tmp/build 
p02064@swan:~/Code/tmp/build> 

p02064@swan:~/Code/tmp/build> grep '^MPI_.*' CMakeCache.txt | grep -v INTERNAL 
MPI_CXX_COMPILER:STRING=/opt/cray/craype/2.4.1/bin/CC 
MPI_CXX_COMPILE_FLAGS:STRING= 
MPI_CXX_INCLUDE_PATH:STRING= 
MPI_CXX_LIBRARIES:STRING= 
MPI_CXX_LINK_FLAGS:STRING= 
MPI_CXX_NO_INTERROGATE:STRING=/opt/cray/craype/2.4.1/bin/CC 
MPI_C_COMPILER:STRING=/opt/cray/craype/2.4.1/bin/cc 
MPI_C_COMPILE_FLAGS:STRING= 
MPI_C_INCLUDE_PATH:STRING= 
MPI_C_LIBRARIES:STRING= 
MPI_C_LINK_FLAGS:STRING= 
MPI_C_NO_INTERROGATE:STRING=/opt/cray/craype/2.4.1/bin/cc 
MPI_EXTRA_LIBRARY:STRING=MPI_EXTRA_LIBRARY-NOTFOUND 
MPI_LIBRARY:FILEPATH=MPI_LIBRARY-NOTFOUND 
p02064@swan:~/Code/tmp/build> 

p02064@swan:~/Code/tmp/build> make 
[ 25%] Building C object CMakeFiles/test-mpi-c.dir/test-mpi.c.o 
[ 50%] Linking C executable test-mpi-c 
[ 50%] Built target test-mpi-c 
[ 75%] Building CXX object CMakeFiles/test-mpi-cxx.dir/test-mpi.cxx.o 
[100%] Linking CXX executable test-mpi-cxx 
[100%] Built target test-mpi-cxx 
p02064@swan:~/Code/tmp/build> 


As you can see from the resulting cache, the FindMPI module knows how to act 
accordingly even when mpi libraries are folded into the regular compiler. 

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] CMake + MPI

2015-09-08 Thread Andreas Naumann

Hi Nico,

I just use find_package(MPI REQUIRED) and use the given 
MPI_CXX_LIBRARIES and MPI_CXX_INCLUDE_PATH.

Recent mpi wrappers should support support interspection.

Regards,
Andreas

Am 08.09.2015 um 13:01 schrieb Nico Schlömer:

Hi everyone,

When it comes to compiling and linking, the MPI world is quite a mess. 
Sometimes, vendors make you link and include certain 
libraries/directories, sometimes you are supposed to simply use a 
compiler wrapper, often both.


What's the recommended way of dealing with MPI in CMake? Do you 
`find_package(MPI REQUIRED)` and set LINK_LIBRARIES and INCLUDE_DIRS? 
Do you select a compiler wrapper from within the CMake file? From outside?


Cheers,
Nico




--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


[CMake] CMake + MPI

2015-09-08 Thread Nico Schlömer
Hi everyone,

When it comes to compiling and linking, the MPI world is quite a mess.
Sometimes, vendors make you link and include certain libraries/directories,
sometimes you are supposed to simply use a compiler wrapper, often both.

What's the recommended way of dealing with MPI in CMake? Do you
`find_package(MPI REQUIRED)` and set LINK_LIBRARIES and INCLUDE_DIRS? Do
you select a compiler wrapper from within the CMake file? From outside?

Cheers,
Nico
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] CMake + MPI

2015-09-08 Thread Tim Gallagher
The only exception to that (which I am aware of) is if you are on a CRAY system 
where the MPI (and BLAS and LAPACK) are baked into the compiler wrappers (cc, 
ftn, etc). In those situations, you actually do not want to run 
find_package(MPI) or it will throw errors.

Tim

- Original Message -
From: "Andreas Naumann" <andreas-naum...@gmx.net>
To: cmake@cmake.org
Sent: Tuesday, September 8, 2015 8:07:38 AM
Subject: Re: [CMake] CMake + MPI

Hi Nico,

I just use find_package(MPI REQUIRED) and use the given 
MPI_CXX_LIBRARIES and MPI_CXX_INCLUDE_PATH.
Recent mpi wrappers should support support interspection.

Regards,
Andreas

Am 08.09.2015 um 13:01 schrieb Nico Schlömer:
> Hi everyone,
>
> When it comes to compiling and linking, the MPI world is quite a mess. 
> Sometimes, vendors make you link and include certain 
> libraries/directories, sometimes you are supposed to simply use a 
> compiler wrapper, often both.
>
> What's the recommended way of dealing with MPI in CMake? Do you 
> `find_package(MPI REQUIRED)` and set LINK_LIBRARIES and INCLUDE_DIRS? 
> Do you select a compiler wrapper from within the CMake file? From outside?
>
> Cheers,
> Nico
>
>

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake