-
Notifications
You must be signed in to change notification settings - Fork 2
mpi_clion_win
- Download Cygwin - https://cygwin.com/install.html for 64-bit versions of Windows, if you running on 64-bit Windows
- Install Cygwin for example into
C:\cygwin64
with packages:
Packages for compilling C/C++ (and for CLion system requirements):
- search
gcc
for package: Devel -> gcc-core - search
gcc
for package: Devel -> gcc-g++ - search
gcc
for package: Libs -> libgcc1 - search
make
for package: Devel -> cmake - search
make
for package: Devel -> make - search
gdb
for package: Devel -> gdb
Packages for MPI:
- search
mpi
for package: Libs -> libopenmpi - search
mpi
for package: Libs -> libopenmpi-devel - search
mpi
for package: Libs -> libopenmpicxx1 - search
mpi
for package: Libs -> libopenmpifh2 - search
mpi
for package: Libs -> openmpi
-
Now in Cygwin Terminal run:
$ mpicc
and$ mpirun
-
If result is:
gcc: fatal error: no input files compilation terminated.
and:
--------------------------------------------------------------------------
mpirun could not find anything to do.
It is possible that you forgot to specify how many processes to run
via the "-np" argument.
--------------------------------------------------------------------------
- Then all is OK. Now you can compile and run MPI programs.
- Download CLion EAP Build - http://confluence.jetbrains.com/display/CLION/Early+Access+Program
- You can install .exe version or extract portable .zip version (-;
create new file MPI.xml
<?xml version="1.0" encoding="UTF-8"?>
<toolSet name="MPI">
<tool name="mpicc" description="MPI C compiler" showInMainMenu="true" showInEditor="true" showInProject="true" showInSearchPopup="true" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true">
<exec>
<option name="COMMAND" value="C:\cygwin64\bin\sh.exe" />
<option name="PARAMETERS" value="-l -c "cd /cygdrive/d/Dropbox/Dev/CLion_projects/$FileDirName$; mpicc -std=c99 $FileName$ -o $FileNameWithoutExtension$.exe"" />
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
</exec>
</tool>
<tool name="mpirun" description="Runner for MPI" showInMainMenu="true" showInEditor="true" showInProject="true" showInSearchPopup="true" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true">
<exec>
<option name="COMMAND" value="C:\cygwin64\bin\sh.exe" />
<option name="PARAMETERS" value="-l -c "cd /cygdrive/d/Dropbox/Dev/CLion_projects/$FileDirName$; mpirun -np $Prompt$ -bind-to core:overload-allowed $FileNameWithoutAllExtensions$" " />
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
</exec>
</tool>
</toolSet>
-
in this file MPI.xml find and replace 2 occurences of
d/Dropbox/Dev/CLion_projects
with your path to directory with CLion projects. -
and make sure that option COMMAND has correct value (path to sh.exe in cygwin64\bin folder)
NOTICE: D:\something
must be d/something
NOTICE: avoid spaces in path!
-
save MPI.xml file to
.clion\config\tools
default path is: C:\Users\<yourUserName>\.clion\config\tools
- Create new project (for example with name
MPI_Project
) - wait for end of process at background (updating indicies, building symbols, etc. in CLion)
- edit file
CMakeLists.txt
append this at the end of this file:
# Require MPI for this 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_Project ${MPI_LIBRARIES})
- now you can use
#include <mpi.h>
and you have code completition for MPI
Run CLion and:
- open File > Settings (CTRL + ALT + S)
- open Tools > External Tools
- now you can see a tree:
- MPI
- mpicc
- mpirun
- you can see that settings here are the same as in MPI.xml. CLion has loaded our MPI.xml file.
Right click on source file > MPI > mpicc
after successfull compilation:
Right click on source file > MPI > mpirun
now you type number of processes for running (np parameter)
Done!
created by Lukáš Melega