-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from hpourreza/master
An example and a readme file
- Loading branch information
Showing
13 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
The `mpiexec` program from MSMPI can be used to launch applications on multiple nodes. There are two ways to launch applications | ||
on multiple nodes: | ||
1. Using MS-MPI Launch Service: | ||
* Start MS-MPI Launch Service on all the compute nodes | ||
* Specify your compute nodes in the `mpiexec` command line (either using `hosts` or `hostfile`), for example:<br> | ||
`mpiexec -c 1 -hosts 2 node1 node2 -wdir c:\Tests MPIHelloWorld.exe`<br> | ||
The above command runs the `MPIHelloWorld.exe` program on two hosts (`node1` and `node2`) using one core from each node | ||
2. Using `spmd`: | ||
* Run `spmd -d` on all compute nodes | ||
* The `spmd.exe` program is availble after installation of MSMPI (in the folder pointed by the `MSMPI_BIN` variable) | ||
* Specify your compute nodes in the `mpiexec` command line (either using `hosts` or `hostfile`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// A simple MPI code printing a message by each MPI rank | ||
|
||
#include <iostream> | ||
#include <mpi.h> | ||
|
||
|
||
int main() | ||
{ | ||
int my_rank; | ||
int world_size; | ||
|
||
MPI_Init(NULL, NULL); | ||
|
||
MPI_Comm_size(MPI_COMM_WORLD, &world_size); | ||
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); | ||
|
||
std::cout << "Hello World from process " << my_rank << " out of " << world_size << " processes!!!" << std::endl; | ||
|
||
MPI_Finalize(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
|
||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>16.0</VCProjectVersion> | ||
<ProjectGuid>{A05D6B11-34C1-462A-AE8B-93D43A6B358D}</ProjectGuid> | ||
<RootNamespace>MPIHelloWorld</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
|
||
<PropertyGroup Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v142</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
|
||
|
||
<ItemDefinitionGroup> | ||
<ClCompile> | ||
<AdditionalIncludeDirectories>$(MSMPI_INC);$(MSMPI_INC)\x64</AdditionalIncludeDirectories> | ||
</ClCompile> | ||
|
||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<AdditionalLibraryDirectories>$(MSMPI_LIB64)</AdditionalLibraryDirectories> | ||
<AdditionalDependencies>msmpi.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
|
||
<ItemGroup> | ||
<ClCompile Include="MPIHelloWorld.cpp" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
ld=link | ||
cc=cl | ||
|
||
cflags=/I"C:\Program Files (x86)\Microsoft SDKs\MPI\Include" | ||
ldflags=/libpath:"C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64" | ||
|
||
libs=msmpi.lib | ||
|
||
output=affinity.exe | ||
objs=affinity.obj | ||
|
||
all: $(objs) | ||
$(ld) $(libs) $(ldflags) -out:$(output) $(objs) | ||
|
||
.cpp.obj: | ||
$(cc) $(cflags) /c $*.cpp | ||
clean: | ||
@del /Q $(objs) | ||
@del /Q $(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## Compile and run a sample MPI code on Windows | ||
1. Download MS-MPI SDK and Redist installers and install them. The download link to a stable realease is available from [this](https://github.com/microsoft/Microsoft-MPI/releases) page. | ||
2. After installation, you can verify that the MS-MPI environment variables have been set correctly (you will want to use these environment variables in Visual Studio) | ||
![inline](./screenshots/set_msmpi.png) | ||
3. Open Visual Studio and create a Console App project. Let's name the project `MPIHelloWorld` | ||
* Instead of creating a project, you may open the provided `MPIHelloWorld.vcxproj` project file in Visual Studio and go to step 7. | ||
4. Use [this](MPIHelloWorld.cpp) code in the newly created project | ||
5. Setup the include directories so that the compiler can find the MS-MPI header files. Note that we will be building | ||
for 64 bits so we will point the include directory to `$(MSMPI_INC);$(MSMPI_INC)\x64`. If you will be building for 32 bits | ||
please use `$(MSMPI_INC);$(MSMPI_INC)\x86` | ||
![inline](./screenshots/inc_dir.png) | ||
6. Setup the linker options. Add `msmpi.lib` to the Additional Dependencies and also add `$(MSMPI_LIB64)` to the Additional | ||
Library Directories. Note that we will be building for 64 bits so we will point the Additional Library Directories to $(MSMPI_LIB64). | ||
If you will be building for 32 bits please use `$(MSMPI_LIB32)` | ||
![inline](./screenshots/lib_dir.png) | ||
7. Build the MPIHelloWorld project | ||
![inline](./screenshots/vs_build.png) | ||
8. Test run the program on the command line | ||
![inline](./screenshots/mpiexec.png) | ||
|
||
Alternatively, you can use Developer Command Prompt for your version of Visual Studio to compile and link the `MPIHelloWorld.cpp` | ||
code (replacing steps 3-7 above). To build a 64-bit application, choose x64 Native Tools Command Prompt from the Visual Studio folder | ||
in the Start menu. | ||
![inline](./screenshots/x64_prompt.png) | ||
|
||
To compile your program into an `.obj` file, go to the folder where `MPIHelloWorld.cpp` exists and run (you may ignore the warning message):<br> | ||
`cl /I"C:\Program Files (x86)\Microsoft SDKs\MPI\Include" /c MPIHelloWorld.cpp` | ||
![inline](./screenshots/compile.png) | ||
|
||
To create an executable file from the .obj file created in the previous step, run:<br> | ||
`link /machine:x64 /out:MPIHelloWorld.exe "msmpi.lib" /libpath:"C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64" MPIHelloWorld.obj` | ||
![inline](./screenshots/link.png) | ||
|
||
You may use the `nmake` command from Developer Command Prompt to compile and build the exmaple using the provided [`Makefile`](Makefile). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.