Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
65 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,24 @@ | ||
# The pre-processor and compiler options. | ||
#OPTIONS | ||
CC = mpic++ | ||
CFLAGS = -Wall -fopenmp -std=c++11 | ||
LDFLAGS = -lgomp -lz | ||
|
||
#---------- | ||
|
||
EXE = bin | ||
|
||
OBJS = $(patsubst %.cpp,%.o,$(wildcard *.cpp)) | ||
|
||
#---------- | ||
|
||
$(EXE): $(OBJS) | ||
$(CC) $(OBJS) $(LIB_DIRS) $(LLIBS)$(LDFLAGS) -o $(EXE) | ||
|
||
$(OBJS): %.o : %.cpp | ||
$(CC) $(CFLAGS) -c $< | ||
|
||
#---------- | ||
|
||
clean: | ||
rm -f *.o *.*~ *~ $(EXE) |
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,31 @@ | ||
#include <iostream> | ||
#include "mpi.h" | ||
#include "omp.h" | ||
|
||
#include <cstring> | ||
int main(int argc, char** argv) { | ||
|
||
// Initialize the MPI environment | ||
MPI_Init(NULL, NULL); | ||
char node_name[MPI_MAX_PROCESSOR_NAME]; | ||
int rank,size, namelen; | ||
int send_num = 5; | ||
int received = 0; | ||
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | ||
MPI_Comm_size(MPI_COMM_WORLD, &size); | ||
MPI_Get_processor_name(node_name, &namelen); | ||
memset(node_name+namelen,0,MPI_MAX_PROCESSOR_NAME-namelen); | ||
int dest = 1;//atoi(argv[2]); // change to command line inputs again if you want to vary these | ||
int src = 0; //atoi(argv[1]); | ||
if (rank == src) { | ||
MPI_Send(&send_num, 1, MPI_INT, dest, 0, MPI_COMM_WORLD); | ||
std::cout << "> " <<node_name<<" Sent " << send_num << " To node"<< dest << std::endl; | ||
} | ||
if(rank == dest){ | ||
std::cout << " hello from "<< node_name<< std::endl; | ||
MPI_Recv(&received, 1, MPI_INT, src, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); | ||
std::cout << "> Number: " << received << " Received by "<< node_name<< std::endl; | ||
} | ||
MPI_Finalize(); | ||
} | ||
|
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,10 @@ | ||
#!/bin/bash | ||
# This script can take multiple parameters | ||
# The first is the executable (required) any others would be passed as paremeter# to that executable | ||
|
||
if [ "$1" == "" ]; then | ||
echo "Positional parameter 1 is empty" | ||
else | ||
mpirun -hostfile /etc/pdsh/machines --map-by ppr:1 node $1 $2 $3 | ||
|
||
fi |