-
Notifications
You must be signed in to change notification settings - Fork 21
/
point-to-point.cpp
106 lines (95 loc) · 2.75 KB
/
point-to-point.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifdef DIY_MPI_AS_LIB
#include "point-to-point.hpp"
#endif
namespace diy
{
namespace mpi
{
#ifdef DIY_MPI_AS_LIB
# ifdef _MSC_VER
# define EXPORT_MACRO DIY_MPI_EXPORT
# else
# define EXPORT_MACRO
# endif
EXPORT_MACRO const int any_source = MPI_ANY_SOURCE;
EXPORT_MACRO const int any_tag = MPI_ANY_TAG;
# undef EXPORT_MACRO
#endif
namespace detail
{
void send(DIY_MPI_Comm comm, int dest, int tag, const void* data, int count, const datatype& type)
{
#if DIY_HAS_MPI
MPI_Send(data, count, mpi_cast(type.handle), dest, tag, mpi_cast(comm));
#else
(void) comm; (void) dest; (void) tag; (void) data; (void) count; (void) type;
DIY_UNSUPPORTED_MPI_CALL(MPI_Send);
#endif
}
void ssend(DIY_MPI_Comm comm, int dest, int tag, const void* data, int count, const datatype& type)
{
#if DIY_HAS_MPI
MPI_Ssend(data, count, mpi_cast(type.handle), dest, tag, mpi_cast(comm));
#else
(void) comm; (void) dest; (void) tag; (void) data; (void) count; (void) type;
DIY_UNSUPPORTED_MPI_CALL(MPI_Ssend);
#endif
}
status probe(DIY_MPI_Comm comm, int source, int tag)
{
#if DIY_HAS_MPI
status s;
MPI_Probe(source, tag, mpi_cast(comm), &mpi_cast(s.handle));
return s;
#else
(void) comm; (void) source; (void) tag;
DIY_UNSUPPORTED_MPI_CALL(MPI_Probe);
#endif
}
status recv(DIY_MPI_Comm comm, int source, int tag, void* data, int count, const datatype& type)
{
#if DIY_HAS_MPI
status s;
MPI_Recv(data, count, mpi_cast(type.handle), source, tag, mpi_cast(comm), &mpi_cast(s.handle));
return s;
#else
(void) comm; (void) source; (void) tag; (void) data; (void) count; (void) type;
DIY_UNSUPPORTED_MPI_CALL(MPI_Recv);
#endif
}
request isend(DIY_MPI_Comm comm, int dest, int tag, const void* data, int count, const datatype& type)
{
#if DIY_HAS_MPI
request r;
MPI_Isend(data, count, mpi_cast(type.handle), dest, tag, mpi_cast(comm), &mpi_cast(r.handle));
return r;
#else
(void) comm; (void) dest; (void) tag; (void) data; (void) count; (void) type;
DIY_UNSUPPORTED_MPI_CALL(MPI_Isend);
#endif
}
request issend(DIY_MPI_Comm comm, int dest, int tag, const void* data, int count, const datatype& type)
{
#if DIY_HAS_MPI
request r;
MPI_Issend(data, count, mpi_cast(type.handle), dest, tag, mpi_cast(comm), &mpi_cast(r.handle));
return r;
#else
(void) comm; (void) dest; (void) tag; (void) data; (void) count; (void) type;
DIY_UNSUPPORTED_MPI_CALL(MPI_Issend);
#endif
}
request irecv(DIY_MPI_Comm comm, int source, int tag, void* data, int count, const datatype& type)
{
#if DIY_HAS_MPI
request r;
MPI_Irecv(data, count, mpi_cast(type.handle), source, tag, mpi_cast(comm), &mpi_cast(r.handle));
return r;
#else
(void) comm; (void) source; (void) tag; (void) data; (void) count; (void) type;
DIY_UNSUPPORTED_MPI_CALL(MPI_Irecv);
#endif
}
}
}
} // diy::mpi::detail