c++ - MPI: Change number of processors in CMakelists -
i'm using clion. cmakelists.txt looks this:
cmake_minimum_required(version 3.2) project(mpi) add_executable(mpi main.cpp) # require mpi project: find_package(mpi required) set(cmake_cxx_compile_flags ${cmake_cxx_compile_flags} ${mpi_compile_flags}) set(cmake_cxx_link_flags ${cmake_cxx_link_flags} ${mpi_link_flags}) include_directories(mpi_include_path) target_link_libraries(mpi ${mpi_libraries}) the mpi - hello world runs well. but how change number of processors in cmakelists?
i tried add -np 4 , -n 4 program arguments in clion. still
hello world process 0 of 1
you cannot specify number of processes use in cmakelists.txt. number of processes argument specify when executing program mpirun.
to compile mpi c project use following cmakelists.txt
cmake_minimum_required(version 3.3) project(hellompi) find_package(mpi required) include_directories(${mpi_include_path}) set(cmake_c_compiler mpicc) set(cmake_cxx_compiler mpicxx) set(source_files main.c) add_executable(hellompi ${source_files}) in order execute program clion, first changed (obscure) location clion default outputs compiled files to. can specify location compiled files under settings in "build, execution , deployment" -> "cmake". changed project folder.
next edited run configurations. "run" -> "edit configurations" -> set executable mpirun. (the location of mpirun on machine)
next edited "program arguments"
-np 4 /home/mitzh/clionprojects/hellompi/debug/hellompi to execute program using 4 processes.
Comments
Post a Comment