-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCudaMPI.cpp
89 lines (76 loc) · 2.66 KB
/
CudaMPI.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <iostream>
#include "mpi_utils.h"
#include "cuda_utils.h"
#include "CudaMPI.h"
/*
int CudaMPI::Isend(void *buf, int count, int dest, int tag, MPI_Request *request, void *h_buf) {
if (CudaAware) {
return MPI_Isend(buf, count, MPI_BYTE, dest, tag, comm, request);
} else {
copy_DtoH<char>((char *)buf, (char *)h_buf, count);
return MPI_Isend(h_buf, count, MPI_BYTE, dest, tag, comm, request);
}
}
int CudaMPI::Irecv(void *buf, int count, int source, int tag, MPI_Request *request, void *h_buf) {
if (CudaAware) {
return MPI_Irecv(buf, count, MPI_BYTE, source, tag, comm, request);
} else {
int retval = MPI_Irecv(h_buf, count, MPI_BYTE, source, tag, comm, request);
copy_HtoD<char>((char *)h_buf, (char *)buf, count);
return retval;
}
}
int CudaMPI::Waitall(int nrequest, MPI_Request *request) {
int retval = MPI_Waitall(nrequest, request, MPI_STATUSES_IGNORE);
if (!CudaAware) {
}
retval;
}
*/
int CudaMPI::Sendrecv(void *sendbuf, int sendcount, int dest, int sendtag,
void *recvbuf, int recvcount, int source, int recvtag, MPI_Status *status,
void *h_sendbuf, void *h_recvbuf) {
int retval;
if (CudaAware) {
gpu_range_start("MPI_Sendrecv (CudaAware)");
retval = MPI_Sendrecv(sendbuf, sendcount, MPI_BYTE, dest, sendtag,
recvbuf, recvcount, MPI_BYTE, source, recvtag, comm, status);
gpu_range_stop();
} else {
copy_DtoH_sync<char>((char *)sendbuf, (char *)h_sendbuf, sendcount);
gpu_range_start("MPI_Sendrecv");
retval= MPI_Sendrecv(h_sendbuf, sendcount, MPI_BYTE, dest, sendtag,
h_recvbuf, recvcount, MPI_BYTE, source, recvtag, comm, status);
gpu_range_stop();
copy_HtoD_sync<char>((char *)h_recvbuf, (char *)recvbuf, recvcount);
}
return retval;
}
int CudaMPI::Send(void *buf, int count, int dest, int tag, void *h_buf) {
int retval;
if (CudaAware) {
gpu_range_start("MPI_Send (CudaAware)");
retval = MPI_Send(buf, count, MPI_BYTE, dest, tag, comm);
gpu_range_stop();
} else {
copy_DtoH_sync<char>((char *)buf, (char *)h_buf, count);
gpu_range_start("MPI_Send");
retval = MPI_Send(h_buf, count, MPI_BYTE, dest, tag, comm);
gpu_range_stop();
}
return retval;
}
int CudaMPI::Recv(void *buf, int count, int source, int tag, MPI_Status *status, void *h_buf) {
int retval;
if (CudaAware) {
gpu_range_start("MPI_Recv (CudaAware)");
retval = MPI_Recv(buf, count, MPI_BYTE, source, tag, comm, status);
gpu_range_stop();
} else {
gpu_range_start("MPI_Recv");
retval = MPI_Recv(h_buf, count, MPI_BYTE, source, tag, comm, status);
gpu_range_stop();
copy_HtoD_sync<char>((char *)h_buf, (char *)buf, count);
}
return retval;
}