From ef7879dccf05ec469c02debfc4b37a85db1e96dc Mon Sep 17 00:00:00 2001 From: Carl Pearson Date: Wed, 16 Oct 2019 12:10:12 -0500 Subject: [PATCH] first commit --- Makefile | 6 ++++++ README.md | 1 + main.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 Makefile create mode 100644 README.md create mode 100644 main.cpp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..94238dc --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +TARGETS = main + +all: ${TARGETS} + +main: main.cpp + mpicxx -Wall -Wextra $< -o $@ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e05ca7e --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# mpi_test diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..bc60f0d --- /dev/null +++ b/main.cpp @@ -0,0 +1,27 @@ +#include +#include + +int main(int argc, char **argv) { + // Initialize the MPI environment + MPI_Init(NULL, NULL); + + // Get the number of processes + int world_size; + MPI_Comm_size(MPI_COMM_WORLD, &world_size); + + // Get the rank of the process + int world_rank; + MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); + + // Get the name of the processor + char processor_name[MPI_MAX_PROCESSOR_NAME]; + int name_len; + MPI_Get_processor_name(processor_name, &name_len); + + // Print off a hello world message + printf("Hello world from %s, rank %d out of %d processors\n", processor_name, + world_rank, world_size); + + // Finalize the MPI environment. + MPI_Finalize(); +}