diff --git a/19-20/mpi_examples/basic_send_omp/.#main.cpp b/19-20/mpi_examples/basic_send_omp/.#main.cpp new file mode 120000 index 0000000..6e84add --- /dev/null +++ b/19-20/mpi_examples/basic_send_omp/.#main.cpp @@ -0,0 +1 @@ +ab0475@holly.coventry.ac.uk.69549 \ No newline at end of file diff --git a/19-20/mpi_examples/basic_send_omp/main.cpp b/19-20/mpi_examples/basic_send_omp/main.cpp index abfaaa7..c71f848 100755 --- a/19-20/mpi_examples/basic_send_omp/main.cpp +++ b/19-20/mpi_examples/basic_send_omp/main.cpp @@ -22,9 +22,21 @@ int rank,size, namelen; std::cout << "> " < Number: " << received << " Received by "<< node_name<< std::endl; + + MPI_Send(&send_num, 1, MPI_INT, dest, 0, MPI_COMM_WORLD); + std::cout << "> " < +#include "mpi.h" +#include "omp.h" + +#include +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 << "> " < Number: " << received << " Received by "<< node_name<< std::endl; + + MPI_Send(&send_num, 1, MPI_INT, dest, 0, MPI_COMM_WORLD); + std::cout << "> " <