Re: [CMake] How to compile MPI code
I'll check my system, maybe cmake "can't find" MPI properly. I'm using cmake 2.8.4. and my code works when I compile without cmake (I use those instructions exactly). Thank you --- El jue, 23/6/11, Todd Gamblin escribió: De: Todd Gamblin Asunto: Re: [CMake] How to compile MPI code Para: "Mª Dolores Villalobos Ortiz" CC: "cmake@cmake.org" Fecha: jueves, 23 de junio, 2011 05:13 On Jun 22, 2011, at 11:11 AM, Mª Dolores Villalobos Ortiz wrote: > Thank you. > > I have tried to compile my code using that version of CMakeLists, but it > doesn't work. My program's output is still wrong. Whether or not mpiexec launches properly isn't something CMake can control. If you are getting rank 0 for all your processes when you launch mpiexec, this is more than likely a problem with your system. Just out of curiosity, what version of MPI are you using? And does the code work when you compile it *without* CMake? e.g. if you just run: mpicxx -o hello hello.cpp mpiexec -n 2 ./hello Does that work, or does that do the same thing? -Todd ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] How to compile MPI code
On Jun 22, 2011, at 11:11 AM, Mª Dolores Villalobos Ortiz wrote: > Thank you. > > I have tried to compile my code using that version of CMakeLists, but it > doesn't work. My program's output is still wrong. Whether or not mpiexec launches properly isn't something CMake can control. If you are getting rank 0 for all your processes when you launch mpiexec, this is more than likely a problem with your system. Just out of curiosity, what version of MPI are you using? And does the code work when you compile it *without* CMake? e.g. if you just run: mpicxx -o hello hello.cpp mpiexec -n 2 ./hello Does that work, or does that do the same thing? -Todd > This is completely, utterly wrong! > > > # 2.7 was a development version, so you should either specify > # 2.6 or 2.8... > cmake_minim_required(VERSION 2.7) > project(ITK_MPI) > > find_package(MPI REQUIRED) > > include_directories(${MPI_INCLUDE_PATH}) > > add_executable(hello hello.cpp) > target_link_libraries(hello ${MPI_LIBRARIES}) > > if(MPI_COMPILE_FLAGS) > set_target_properties(hello PROPERTIES > COMPILE_FLAGS "${MPI_COMPILE_FLAGS}") > endif() > > if(MPI_LINK_FLAGS) > set_target_properties(hello PROPERTIES > LINK_FLAGS "${MPI_LINK_FLAGS}") > endif() > > > You should *NEVER* set CMAKE__COMPILER, this completely breaks > things. Also, with CMake you shouldn't use the compiler wrappers (mpicxx > etc.), because CMake figures out how to compile MPI programs without it. > > HTH > > Michael > ___ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake __ Todd Gamblin, tgamb...@llnl.gov, http://people.llnl.gov/gamblin2 CASC @ Lawrence Livermore National Laboratory, Livermore, CA, USA ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] How to compile MPI code
Thank you. I have tried to compile my code using that version of CMakeLists, but it doesn't work. My program's output is still wrong. This is completely, utterly wrong! # 2.7 was a development version, so you should either specify # 2.6 or 2.8... cmake_minim_required(VERSION 2.7) project(ITK_MPI) find_package(MPI REQUIRED) include_directories(${MPI_INCLUDE_PATH}) add_executable(hello hello.cpp) target_link_libraries(hello ${MPI_LIBRARIES}) if(MPI_COMPILE_FLAGS) set_target_properties(hello PROPERTIES COMPILE_FLAGS "${MPI_COMPILE_FLAGS}") endif() if(MPI_LINK_FLAGS) set_target_properties(hello PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}") endif() You should *NEVER* set CMAKE__COMPILER, this completely breaks things. Also, with CMake you shouldn't use the compiler wrappers (mpicxx etc.), because CMake figures out how to compile MPI programs without it. HTH Michael ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] How to compile MPI code
Hm... this is the CMake user list, not the MPI-user list. You're posing your question on the wrong list. (but how did you compile? Did you use mpicc?) Sincerely, Jakob On 06/22/2011 02:25 PM, Mª Dolores Villalobos Ortiz wrote: >What do you mean with "it doesn't run correctly"? Does it not even start? How do you start your program? -- My program's code is: #include using namespace std; #include "mpi.h" int main( int argc, char * argv[] ) { int node; int num_nodes; int i, buf; MPI::Init(argc, argv); node = MPI::COMM_WORLD.Get_rank(); num_nodes = MPI::COMM_WORLD.Get_size(); std::cout << "I am node " << node << std::endl; if ( node == 0 ) { std::cout << "I am node " << node << std::endl; std::cout << "Num threads (Get_size) -> " << num_nodes << std::endl; } else { std::cout << "I am node " << node << std::endl; } MPI_Finalize(); return 0; } -- And, in order to run the program, I type in Ubuntu's terminal: mpiexec -n 2 ./main_program - The program write in terminal: I am node 0 I am node 0 Num threads (Get_size) -> 1 I am node 0 I am node 0 Num threads (Get_size) -> 1 instead of: I am node 0 I am node 0 Num threads (Get_size) -> 2 I am node 1 I am node 1 Lola ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] How to compile MPI code
On 06/22/2011 12:00 PM, Mª Dolores Villalobos Ortiz wrote: > Hi > > I'm trying to compile a main program (it contains MPI functions) using > cmake. I get an executable file (there aren't problems in compilation ), > but it doesn't run correctly. > > If I compile my code using a simple Makefile, it works; but I need to > compile it using cmake (that's a prerequisite for my work). > > I have installed MPICH2 and cmake 2.8.4. and I use the next files: > > CMakeLists.txt: > > cmake_minimum_required(VERSION 2.7) > set(CMAKE_CXX_COMPILER "/home/lola/Packages/mpich2-1.3.2p1/bin/mpicxx") > set(CMAKE_C_COMPILER "/home/lola/Packages/mpich2-1.3.2p1/bin/mpicc") > project( ITK_MPI ) > find_package ( MPI ) > if ( MPI_FOUND ) > include_directories( ${MPI_INCLUDE_PATH} ) > endif( MPI_FOUND ) > This is completely, utterly wrong! # 2.7 was a development version, so you should either specify # 2.6 or 2.8... cmake_minim_required(VERSION 2.7) project(ITK_MPI) find_package(MPI REQUIRED) include_directories(${MPI_INCLUDE_PATH}) add_executable(hello hello.cpp) target_link_libraries(hello ${MPI_LIBRARIES}) if(MPI_COMPILE_FLAGS) set_target_properties(hello PROPERTIES COMPILE_FLAGS "${MPI_COMPILE_FLAGS}") endif() if(MPI_LINK_FLAGS) set_target_properties(hello PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}") endif() You should *NEVER* set CMAKE__COMPILER, this completely breaks things. Also, with CMake you shouldn't use the compiler wrappers (mpicxx etc.), because CMake figures out how to compile MPI programs without it. HTH Michael ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] How to compile MPI code
>What do you mean with "it doesn't run correctly"? Does it not even start? How do you start your program? -- My program's code is: #include using namespace std; #include "mpi.h" int main( int argc, char * argv[] ) { int node; int num_nodes; int i, buf; MPI::Init(argc, argv); node = MPI::COMM_WORLD.Get_rank(); num_nodes = MPI::COMM_WORLD.Get_size(); std::cout << "I am node " << node << std::endl; if ( node == 0 ) { std::cout << "I am node " << node << std::endl; std::cout << "Num threads (Get_size) -> " << num_nodes << std::endl; } else { std::cout << "I am node " << node << std::endl; } MPI_Finalize(); return 0; } -- And, in order to run the program, I type in Ubuntu's terminal: mpiexec -n 2 ./main_program - The program write in terminal: I am node 0 I am node 0 Num threads (Get_size) -> 1 I am node 0 I am node 0 Num threads (Get_size) -> 1 instead of: I am node 0 I am node 0 Num threads (Get_size) -> 2 I am node 1 I am node 1 Lola ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] How to compile MPI code
What do you mean with "it doesn't run correctly"? Does it not even start? How do you start your program? Andreas Am 22.06.2011 12:00, schrieb Mª Dolores Villalobos Ortiz: Hi I'm trying to compile a main program (it contains MPI functions) using cmake. I get an executable file (there aren't problems in compilation ), but it doesn't run correctly. If I compile my code using a simple Makefile, it works; but I need to compile it using cmake (that's a prerequisite for my work). I have installed MPICH2 and cmake 2.8.4. and I use the next files: CMakeLists.txt: cmake_minimum_required(VERSION 2.7) set(CMAKE_CXX_COMPILER "/home/lola/Packages/mpich2-1.3.2p1/bin/mpicxx") set(CMAKE_C_COMPILER "/home/lola/Packages/mpich2-1.3.2p1/bin/mpicc") project( ITK_MPI ) find_package ( MPI ) if ( MPI_FOUND ) include_directories( ${MPI_INCLUDE_PATH} ) endif( MPI_FOUND ) -- CMakeCache.txt: . .. //CXX compiler. CMAKE_CXX_COMPILER:FILEPATH=/home/lola/Packages/mpich2-1.3.2p1/bin/mpicxx //Flags used by the compiler during all build types. CMAKE_CXX_FLAGS:STRING= //Flags used by the compiler during debug builds. CMAKE_CXX_FLAGS_DEBUG:STRING= //Flags used by the compiler during release minsize builds. CMAKE_CXX_FLAGS_MINSIZEREL:STRING= //Flags used by the compiler during release builds (/MD /Ob1 /Oi // /Ot /Oy /Gs will produce slightly less optimized but smaller // files). CMAKE_CXX_FLAGS_RELEASE:STRING= //Flags used by the compiler during Release with Debug Info builds. CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING= //C compiler. CMAKE_C_COMPILER:FILEPATH=/home/lola/Packages/mpich2-1.3.2p1/bin/mpicc //Value Computed by CMake ITK_MPI_BINARY_DIR:STATIC=/home/lola/Curso/Proyecto/Pruebas_MPI //Value Computed by CMake ITK_MPI_SOURCE_DIR:STATIC=/home/lola/Curso/Proyecto/Pruebas_MPI //Executable for running MPI programs. MPIEXEC:FILEPATH=/home/lola/Packages/mpich2-1.3.2p1/bin/mpiexec //Maximum number of processors available to run MPI applications. MPIEXEC_MAX_NUMPROCS:STRING=2 //Flag used by MPI to specify the number of processes for MPIEXEC; // the next option will be the number of processes. MPIEXEC_NUMPROC_FLAG:STRING=-n2 //These flags will come after all flags given to MPIEXEC. MPIEXEC_POSTFLAGS:STRING= //These flags will be directly before the executable that is being // run by MPIEXEC. MPIEXEC_PREFLAGS:STRING= //MPI compiler. Used only to detect MPI compilation flags. MPI_COMPILER:FILEPATH=/home/lola/Packages/mpich2-1.3.2p1/bin/mpicxx //MPI compilation flags MPI_COMPILE_FLAGS:STRING=' ' //Extra MPI libraries to link against MPI_EXTRA_LIBRARY:STRING=/usr/lib/mpich/lib/libmpich.a;/usr/lib/libpthread.so;/usr/lib/librt.so //MPI include path MPI_INCLUDE_PATH:STRING=/home/lola/Packages/mpich2-1.3.2p1/include //MPI library to link against MPI_LIBRARY:FILEPATH=/usr/lib/mpich/lib/libpmpich++.a;/usr/lib/mpich/lib/libmpich.a;/usr/lib/libpthread.so;/usr/lib/librt.so //MPI linking flags MPI_LINK_FLAGS:STRING= . ¿What's am I doing wrong?, ¿Is there any other configuration?. I really need to make it work. Thank you Lola ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] How to compile MPI code
Hi I'm trying to compile a main program (it contains MPI functions) using cmake. I get an executable file (there aren't problems in compilation ), but it doesn't run correctly. If I compile my code using a simple Makefile, it works; but I need to compile it using cmake (that's a prerequisite for my work). I have installed MPICH2 and cmake 2.8.4. and I use the next files: CMakeLists.txt: cmake_minimum_required(VERSION 2.7) set(CMAKE_CXX_COMPILER "/home/lola/Packages/mpich2-1.3.2p1/bin/mpicxx") set(CMAKE_C_COMPILER "/home/lola/Packages/mpich2-1.3.2p1/bin/mpicc") project( ITK_MPI ) find_package ( MPI ) if ( MPI_FOUND ) include_directories( ${MPI_INCLUDE_PATH} ) endif( MPI_FOUND ) -- CMakeCache.txt: . .. //CXX compiler. CMAKE_CXX_COMPILER:FILEPATH=/home/lola/Packages/mpich2-1.3.2p1/bin/mpicxx //Flags used by the compiler during all build types. CMAKE_CXX_FLAGS:STRING= //Flags used by the compiler during debug builds. CMAKE_CXX_FLAGS_DEBUG:STRING= //Flags used by the compiler during release minsize builds. CMAKE_CXX_FLAGS_MINSIZEREL:STRING= //Flags used by the compiler during release builds (/MD /Ob1 /Oi // /Ot /Oy /Gs will produce slightly less optimized but smaller // files). CMAKE_CXX_FLAGS_RELEASE:STRING= //Flags used by the compiler during Release with Debug Info builds. CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING= //C compiler. CMAKE_C_COMPILER:FILEPATH=/home/lola/Packages/mpich2-1.3.2p1/bin/mpicc //Value Computed by CMake ITK_MPI_BINARY_DIR:STATIC=/home/lola/Curso/Proyecto/Pruebas_MPI //Value Computed by CMake ITK_MPI_SOURCE_DIR:STATIC=/home/lola/Curso/Proyecto/Pruebas_MPI //Executable for running MPI programs. MPIEXEC:FILEPATH=/home/lola/Packages/mpich2-1.3.2p1/bin/mpiexec //Maximum number of processors available to run MPI applications. MPIEXEC_MAX_NUMPROCS:STRING=2 //Flag used by MPI to specify the number of processes for MPIEXEC; // the next option will be the number of processes. MPIEXEC_NUMPROC_FLAG:STRING=-n2 //These flags will come after all flags given to MPIEXEC. MPIEXEC_POSTFLAGS:STRING= //These flags will be directly before the executable that is being // run by MPIEXEC. MPIEXEC_PREFLAGS:STRING= //MPI compiler. Used only to detect MPI compilation flags. MPI_COMPILER:FILEPATH=/home/lola/Packages/mpich2-1.3.2p1/bin/mpicxx //MPI compilation flags MPI_COMPILE_FLAGS:STRING=' ' //Extra MPI libraries to link against MPI_EXTRA_LIBRARY:STRING=/usr/lib/mpich/lib/libmpich.a;/usr/lib/libpthread.so;/usr/lib/librt.so //MPI include path MPI_INCLUDE_PATH:STRING=/home/lola/Packages/mpich2-1.3.2p1/include //MPI library to link against MPI_LIBRARY:FILEPATH=/usr/lib/mpich/lib/libpmpich++.a;/usr/lib/mpich/lib/libmpich.a;/usr/lib/libpthread.so;/usr/lib/librt.so //MPI linking flags MPI_LINK_FLAGS:STRING= . ¿What's am I doing wrong?, ¿Is there any other configuration?. I really need to make it work. Thank you Lola ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake