Sheet 7 - 1

This commit is contained in:
Georg Thomas Mandl 2026-01-07 00:58:59 +01:00
commit 4c107a5c28
5 changed files with 181 additions and 0 deletions

35
Sheet_7/bsp_7_2/main.cpp Normal file
View file

@ -0,0 +1,35 @@
// MPI code in C++.
// See [Gropp/Lusk/Skjellum, "Using MPI", p.33/41 etc.]
// and /opt/mpich/include/mpi2c++/comm.h for details
#include "greetings.h"
#include <iostream> // MPI
#include <mpi.h>
using namespace std;
int main(int argc, char *argv[])
{
MPI_Comm icomm = MPI_COMM_WORLD;
MPI_Init(&argc, &argv); // E2
int myrank, numprocs;
MPI_Comm_rank(icomm, &myrank); // my MPI-rank, process-ID
MPI_Comm_size(icomm, &numprocs); // number of all processes
// cout << "\n Process nr. " << myrank << " says, there are " << numprocs << " processes running.\n \n"; //
// E3
if (0==myrank) {
cout << "\n Process nr. " << myrank << " says, there are " << numprocs << " processes running.\n \n";
}
//greetings(icomm);
greetings_cpp(icomm); // E4
MPI_Finalize(); // E2
return 0;
}