source: XIOS/dev/branch_openmp/extern/ep_dev/ep_type.cpp @ 1500

Last change on this file since 1500 was 1500, checked in by yushan, 3 years ago

save dev

File size: 4.7 KB
Line 
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
8using namespace std;
9
10
11namespace 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  ep_message::ep_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  ep_info::ep_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  ep_info::ep_info()
64  {
65    mpi_info = new ::MPI_Info;
66    *(static_cast< ::MPI_Info*>(mpi_info)) = *(static_cast< ::MPI_Info*>(MPI_INFO_NULL->mpi_info));
67  }
68 
69  ep_request::ep_request(void* request)
70  {
71    mpi_request = new ::MPI_Request;
72    *(static_cast< ::MPI_Request*>(mpi_request)) = *static_cast< ::MPI_Request*>(request);
73  }
74 
75  ep_status::ep_status(void* status)
76  {
77    mpi_status = new ::MPI_Status;
78    *(static_cast< ::MPI_Status*>(mpi_status)) = *static_cast< ::MPI_Status*>(status);
79  }
80 
81  MPI_Aint::MPI_Aint(void* aint)
82  {
83    mpi_aint = new ::MPI_Aint;
84    *(static_cast< ::MPI_Aint*>(mpi_aint)) = *(static_cast< ::MPI_Aint*>(aint));
85  }
86
87  MPI_Aint::MPI_Aint(int aint)
88  {
89    mpi_aint = new ::MPI_Aint;
90    *(static_cast< ::MPI_Aint*>(mpi_aint)) = aint;
91  }
92
93  MPI_Aint MPI_Aint::operator=(int a)
94  {
95    mpi_aint = new ::MPI_Aint;
96    *(static_cast< int*>(mpi_aint)) = a; 
97  }
98 
99  MPI_Fint::MPI_Fint(void* fint)
100  {
101    mpi_fint = new ::MPI_Fint;
102    *(static_cast< ::MPI_Fint*>(mpi_fint)) = *(static_cast< ::MPI_Fint*>(fint));
103  }
104
105  bool ep_communicator::operator == (ep_communicator right)
106  {
107    bool a = size_rank_info == right.size_rank_info;
108    bool b = comm_label == right.comm_label;
109    bool c = intercomm == right.intercomm;
110    return a&&b&&c;
111  }
112
113  bool ep_communicator::operator != (ep_communicator right)
114  {
115    bool a = size_rank_info != right.size_rank_info;
116    bool b = comm_label != right.comm_label;
117    bool c = intercomm != right.intercomm;
118    return a||b||c;
119  }
120
121  ep_comm::ep_comm()
122  {
123    is_ep = true;
124    is_intercomm = false;
125    my_buffer = NULL;
126    ep_barrier = NULL;
127    rank_map = NULL;
128    ep_comm_ptr = NULL;
129    mem_bridge = NULL;
130    mpi_bridge = NULL;
131    mpi_comm = new ::MPI_Comm;
132  }
133
134 
135
136  ep_comm::ep_comm(void* comm)
137  {
138    is_ep = false;
139    is_intercomm = false;
140    my_buffer = NULL;
141    ep_barrier = NULL;
142    rank_map = NULL;
143    ep_comm_ptr = NULL;
144    mem_bridge = NULL;
145    mpi_bridge = NULL;
146    mpi_comm = new ::MPI_Comm;
147    *(static_cast< ::MPI_Comm*>(mpi_comm)) = *(static_cast< ::MPI_Comm*>(comm));
148  }
149
150 
151
152  bool ep_comm::operator == (ep_comm right)
153  {
154    bool a = is_ep == right.is_ep;
155    bool b = is_intercomm == right.is_intercomm;
156    bool c = *(static_cast< ::MPI_Comm*>(mpi_comm)) == *(static_cast< ::MPI_Comm*>(right.mpi_comm));
157    bool d = is_ep ? ep_comm_ptr == right.ep_comm_ptr : true;
158    return a&&b&&c&&d;
159  }
160
161  bool ep_comm::operator != (ep_comm right)
162  {
163    bool a = is_ep != right.is_ep;
164    bool b = is_intercomm != right.is_intercomm;
165    bool c = *(static_cast< ::MPI_Comm*>(mpi_comm)) != *(static_cast< ::MPI_Comm*>(right.mpi_comm));
166    bool d = is_ep ? ep_comm_ptr != right.ep_comm_ptr : true;
167    return a||b||c||d;
168  }
169
170  bool ep_request::operator == (ep_request right)
171  {
172    bool b = type == right.type;
173    bool c = buf == right.buf;
174    bool d = ep_src == right.ep_src;
175    bool e = ep_tag == right.ep_tag;
176    bool f = ep_datatype == right.ep_datatype;
177    return b&&c&&d&&e&&f;
178  }
179
180
181}
182
183
184
185
186
187
188
189
190
Note: See TracBrowser for help on using the repository browser.