From a5f3ed981f4caad1e2a6e0387947c4f93cbd087d Mon Sep 17 00:00:00 2001 From: Fabio Durastante Date: Tue, 23 Apr 2024 17:31:10 +0200 Subject: [PATCH] Added other example --- Makefile | 5 ++++- hamlet.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 hamlet.c diff --git a/Makefile b/Makefile index 2b69e95..eccd070 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ MPICC = mpicc #The wrapper for the compiler CFLAGS += -g #Useful for debug symbols -all: helloworld +all: helloworld hamlet helloworld: helloworld.c $(MPICC) $(CFLAGS) $(LDFLAGS) $? $(LDLIBS) -o $@ +hamlet: hamlet.c + $(MPICC) $(CFLAGS) $(LDFLAGS) $? $(LDLIBS) -o $@ + clean: rm -f helloworld diff --git a/hamlet.c b/hamlet.c new file mode 100644 index 0000000..5a71b06 --- /dev/null +++ b/hamlet.c @@ -0,0 +1,13 @@ +#include "mpi.h" +#include + +int main( int argc, char **argv ){ + int rank, size; + MPI_Init( &argc, &argv ); + MPI_Comm_rank( MPI_COMM_WORLD, &rank ); + MPI_Comm_size( MPI_COMM_WORLD, &size ); + printf( "Hello world! I'm process %d of %d\n",rank, size ); + MPI_Finalize(); + + return 0; +}