Skip to content
Permalink
Browse files
update
  • Loading branch information
carey committed Mar 18, 2020
1 parent db8d1aa commit d5bcea529256c6ac46ac428e0ff9168ca7e0d2ba
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
@@ -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)
@@ -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();
}

@@ -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

0 comments on commit d5bcea5

Please sign in to comment.