-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmpiBaseTest31.cc
More file actions
38 lines (31 loc) · 975 Bytes
/
mpiBaseTest31.cc
File metadata and controls
38 lines (31 loc) · 975 Bytes
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
#include <omp.h>
#include <mpi.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
double doTest31( int rank, int numIterations, char* sendBuf, char* recvBuf, int numThreads, size_t threadPart )
{
int other = (rank + 1) % 2;
double start;
#pragma omp parallel shared(rank,numIterations,sendBuf,recvBuf,numThreads,threadPart,other,start) num_threads(numThreads)
{
int tid = omp_get_thread_num();
int rc;
int iteration;
#pragma omp master
start = MPI_Wtime();
for ( iteration = 0; iteration < numIterations; iteration++ ) {
#pragma omp barrier
if ( 0 == rank ) {
rc = MPI_Send( (char*) sendBuf + tid * threadPart, threadPart, MPI_CHAR, other, tid, MPI_COMM_WORLD );
assert( rc == MPI_SUCCESS );
} else {
rc = MPI_Recv( (char*) recvBuf + tid * threadPart, threadPart, MPI_CHAR, other, tid, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
assert( rc == MPI_SUCCESS );
}
}
}
return MPI_Wtime() - start;
}