-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpiWork.c
39 lines (37 loc) · 955 Bytes
/
mpiWork.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#include "kernel.h"
int main(int argc, char** argv) {
int rank;
int worldSz;
double t0;
#ifdef THREAD_MULTIPLE
int provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
if( provided != MPI_THREAD_MULTIPLE ) {
fprintf(stderr, "Error: MPI MPI_THREAD_MULTIPLE not supported\n");
return 0;
}
#else
MPI_Init(&argc, &argv);
#endif
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &worldSz);
thdata* data = (thdata*) calloc(1,sizeof(thdata));
t0 = MPI_Wtime();
data->rank = rank;
data->commsz = worldSz;
data->id = rank;
data->peers = 1;
kernelComm((void*) data);
MPI_Barrier(MPI_COMM_WORLD);
if( !rank )
fprintf(stderr, "realTime %.3f\n", MPI_Wtime()-t0);
free(data);
MPI_Finalize();
return 0;
}