1 | #include "ep_lib.hpp" |
---|
2 | #include <mpi.h> |
---|
3 | #include "ep_declaration.hpp" |
---|
4 | #include <iostream> |
---|
5 | #include <fstream> |
---|
6 | #include "ep_mpi.hpp" |
---|
7 | |
---|
8 | using namespace std; |
---|
9 | |
---|
10 | |
---|
11 | namespace ep_lib |
---|
12 | { |
---|
13 | |
---|
14 | ep_intercomm::ep_intercomm() |
---|
15 | { |
---|
16 | intercomm_rank_map = NULL; |
---|
17 | local_rank_map = NULL; |
---|
18 | remote_rank_map = NULL; |
---|
19 | mpi_inter_comm = new ::MPI_Comm; |
---|
20 | } |
---|
21 | |
---|
22 | bool ep_intercomm::operator == (ep_intercomm right) |
---|
23 | { |
---|
24 | bool a = intercomm_rank_map == right.intercomm_rank_map; |
---|
25 | bool b = local_rank_map == right.local_rank_map; |
---|
26 | bool c = remote_rank_map == right.remote_rank_map; |
---|
27 | bool d = *(static_cast< ::MPI_Comm*>(mpi_inter_comm)) == *(static_cast< ::MPI_Comm*>(right.mpi_inter_comm)); |
---|
28 | bool e = size_rank_info == right.size_rank_info; |
---|
29 | bool f = intercomm_tag == right.intercomm_tag; |
---|
30 | return a&&b&&c&&d&&e&&f; |
---|
31 | } |
---|
32 | |
---|
33 | bool ep_intercomm::operator != (ep_intercomm right) |
---|
34 | { |
---|
35 | bool a = intercomm_rank_map != right.intercomm_rank_map; |
---|
36 | bool b = local_rank_map != right.local_rank_map; |
---|
37 | bool c = remote_rank_map != right.remote_rank_map; |
---|
38 | bool d = *(static_cast< ::MPI_Comm*>(mpi_inter_comm)) != *(static_cast< ::MPI_Comm*>(right.mpi_inter_comm)); |
---|
39 | bool e = size_rank_info != right.size_rank_info; |
---|
40 | bool f = intercomm_tag != right.intercomm_tag; |
---|
41 | return a||b||c||d||e||f; |
---|
42 | } |
---|
43 | |
---|
44 | ep_communicator::ep_communicator() |
---|
45 | { |
---|
46 | comm_list = NULL; |
---|
47 | message_queue = NULL; |
---|
48 | intercomm = NULL; |
---|
49 | } |
---|
50 | |
---|
51 | MPI_Message::MPI_Message(void* message) |
---|
52 | { |
---|
53 | mpi_message = new ::MPI_Message; |
---|
54 | *(static_cast< ::MPI_Message*>(mpi_message)) = *(static_cast< ::MPI_Message*>(message)); |
---|
55 | } |
---|
56 | |
---|
57 | MPI_Info::MPI_Info(void* info) |
---|
58 | { |
---|
59 | mpi_info = new ::MPI_Info; |
---|
60 | *(static_cast< ::MPI_Info*>(mpi_info)) = *(static_cast< ::MPI_Info*>(info)); |
---|
61 | } |
---|
62 | |
---|
63 | // MPI_Request::MPI_Request(void* request) |
---|
64 | // { |
---|
65 | // mpi_request = new ::MPI_Request; |
---|
66 | // *(static_cast< ::MPI_Request*>(mpi_request)) = *(static_cast< ::MPI_Request*>(request)); |
---|
67 | // } |
---|
68 | |
---|
69 | |
---|
70 | bool ep_communicator::operator == (ep_communicator right) |
---|
71 | { |
---|
72 | bool a = size_rank_info == right.size_rank_info; |
---|
73 | bool b = comm_label == right.comm_label; |
---|
74 | bool c = intercomm == right.intercomm; |
---|
75 | return a&&b&&c; |
---|
76 | } |
---|
77 | |
---|
78 | bool ep_communicator::operator != (ep_communicator right) |
---|
79 | { |
---|
80 | bool a = size_rank_info != right.size_rank_info; |
---|
81 | bool b = comm_label != right.comm_label; |
---|
82 | bool c = intercomm != right.intercomm; |
---|
83 | return a||b||c; |
---|
84 | } |
---|
85 | |
---|
86 | MPI_Comm::MPI_Comm() |
---|
87 | { |
---|
88 | is_ep = true; |
---|
89 | is_intercomm = false; |
---|
90 | my_buffer = NULL; |
---|
91 | ep_barrier = NULL; |
---|
92 | rank_map = NULL; |
---|
93 | ep_comm_ptr = NULL; |
---|
94 | mem_bridge = NULL; |
---|
95 | mpi_bridge = NULL; |
---|
96 | mpi_comm = new ::MPI_Comm; |
---|
97 | } |
---|
98 | |
---|
99 | |
---|
100 | |
---|
101 | MPI_Comm::MPI_Comm(void* comm) |
---|
102 | { |
---|
103 | is_ep = false; |
---|
104 | is_intercomm = false; |
---|
105 | my_buffer = NULL; |
---|
106 | ep_barrier = NULL; |
---|
107 | rank_map = NULL; |
---|
108 | ep_comm_ptr = NULL; |
---|
109 | mem_bridge = NULL; |
---|
110 | mpi_bridge = NULL; |
---|
111 | mpi_comm = new ::MPI_Comm; |
---|
112 | *(static_cast< ::MPI_Comm*>(mpi_comm)) = *(static_cast< ::MPI_Comm*>(comm)); |
---|
113 | } |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | bool MPI_Comm::operator == (MPI_Comm right) |
---|
118 | { |
---|
119 | bool a = is_ep == right.is_ep; |
---|
120 | bool b = is_intercomm == right.is_intercomm; |
---|
121 | bool c = *(static_cast< ::MPI_Comm*>(mpi_comm)) == *(static_cast< ::MPI_Comm*>(right.mpi_comm)); |
---|
122 | bool d = is_ep ? ep_comm_ptr == right.ep_comm_ptr : true; |
---|
123 | return a&&b&&c&&d; |
---|
124 | } |
---|
125 | |
---|
126 | bool MPI_Comm::operator != (MPI_Comm right) |
---|
127 | { |
---|
128 | bool a = is_ep != right.is_ep; |
---|
129 | bool b = is_intercomm != right.is_intercomm; |
---|
130 | bool c = *(static_cast< ::MPI_Comm*>(mpi_comm)) != *(static_cast< ::MPI_Comm*>(right.mpi_comm)); |
---|
131 | bool d = is_ep ? ep_comm_ptr != right.ep_comm_ptr : true; |
---|
132 | return a||b||c||d; |
---|
133 | } |
---|
134 | |
---|
135 | bool MPI_Request::operator == (MPI_Request right) |
---|
136 | { |
---|
137 | bool b = type == right.type; |
---|
138 | bool c = buf == right.buf; |
---|
139 | bool d = ep_src == right.ep_src; |
---|
140 | bool e = ep_tag == right.ep_tag; |
---|
141 | bool f = ep_datatype == right.ep_datatype; |
---|
142 | return b&&c&&d&&e&&f; |
---|
143 | } |
---|
144 | |
---|
145 | |
---|
146 | } |
---|
147 | |
---|
148 | |
---|
149 | |
---|
150 | |
---|
151 | |
---|
152 | |
---|
153 | |
---|
154 | |
---|
155 | |
---|