From 437e951db62848dcd75bfbc60542e243d45a5aa7 Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Thu, 7 Sep 2023 17:57:30 -0500 Subject: [PATCH] Update mpi test program. --- tests/hellompi/Makefile | 7 ++++--- tests/hellompi/{hellompi.c => hellompi.cpp} | 12 ++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) rename tests/hellompi/{hellompi.c => hellompi.cpp} (63%) diff --git a/tests/hellompi/Makefile b/tests/hellompi/Makefile index f0faa27..0fbbc00 100644 --- a/tests/hellompi/Makefile +++ b/tests/hellompi/Makefile @@ -1,10 +1,11 @@ EXECS=hellompi -MPICC=/usr/lib64/mpi/gcc/openmpi4/bin/mpicc +#MPICC=/usr/lib64/mpi/gcc/openmpi4/bin/mpicc +MPI=/usr/lib64/mpi/gcc/mpich all: ${EXECS} -hellompi: hellompi.c - ${MPICC} -g -o hellompi hellompi.c +hellompi: hellompi.cpp + g++ -g -I${MPI}/include -L${MPI}/lib64 -lmpi -o hellompi hellompi.cpp clean: rm ${EXECS} diff --git a/tests/hellompi/hellompi.c b/tests/hellompi/hellompi.cpp similarity index 63% rename from tests/hellompi/hellompi.c rename to tests/hellompi/hellompi.cpp index a6e4d66..75d7ed6 100644 --- a/tests/hellompi/hellompi.c +++ b/tests/hellompi/hellompi.cpp @@ -1,5 +1,7 @@ #include -#include +#include +#include +#include int main(int argc, char** argv) { @@ -20,7 +22,13 @@ int main(int argc, char** argv) { MPI_Get_processor_name(processor_name, &name_len); // Print off a hello world message - printf("Hello world from processor %s, rank %d out of %d processors\n", processor_name, world_rank, world_size); + std::cout << "Hello world from processor " << processor_name << " rank " << world_rank << " size " << world_size << std::endl; + + std::cout << "Waiting for debugger to be attached, PID: " << getpid() << std::endl; + + bool attached = false; + + while (!attached) sleep(1); // Finalize the MPI environment. MPI_Finalize();