Update mpi test program.

This commit is contained in:
Ernie Pasveer
2023-09-07 17:57:30 -05:00
parent 4b369f7ae0
commit 437e951db6
2 changed files with 14 additions and 5 deletions
+4 -3
View File
@@ -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}
@@ -1,5 +1,7 @@
#include <mpi.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <iostream>
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();