FasTensor  1.0.0
Transform Supercomputing for AI
ft_endpoint_adios.h
Go to the documentation of this file.
1 /*
2 ****************************
3 
4 FasTensor (FT) Copyright (c) 2021, The Regents of the University of
5 California, through Lawrence Berkeley National Laboratory (subject to
6 receipt of any required approvals from the U.S. Dept. of Energy).
7 All rights reserved.
8 
9 If you have questions about your rights to use or distribute this software,
10 please contact Berkeley Lab's Intellectual Property Office at
12 
13 NOTICE. This Software was developed under funding from the U.S. Department
14 of Energy and the U.S. Government consequently retains certain rights. As
15 such, the U.S. Government has been granted for itself and others acting on
16 its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the
17 Software to reproduce, distribute copies to the public, prepare derivative
18 works, and perform publicly and display publicly, and to permit others to do so.
19 
20 
21 ****************************
22 
23 
24 *** License Agreement ***
25 
26 FasTensor (FT) Copyright (c) 2021, The Regents of the University of
27 California, through Lawrence Berkeley National Laboratory (subject to
28 receipt of any required approvals from the U.S. Dept. of Energy).
29 All rights reserved.
30 
31 Redistribution and use in source and binary forms, with or without
32 modification, are permitted provided that the following conditions are met:
33 
34 (1) Redistributions of source code must retain the above copyright notice,
35 this list of conditions and the following disclaimer.
36 
37 (2) Redistributions in binary form must reproduce the above copyright
38 notice, this list of conditions and the following disclaimer in the
39 documentation and/or other materials provided with the distribution.
40 
41 (3) Neither the name of the University of California, Lawrence Berkeley
42 National Laboratory, U.S. Dept. of Energy nor the names of its contributors
43 may be used to endorse or promote products derived from this software
44 without specific prior written permission.
45 
46 
47 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
51 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
52 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
53 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
54 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
55 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
57 POSSIBILITY OF SUCH DAMAGE.
58 
59 You are under no obligation whatsoever to provide any bug fixes, patches,
60 or upgrades to the features, functionality or performance of the source
61 code ("Enhancements") to anyone; however, if you choose to make your
62 Enhancements available either publicly, or directly to Lawrence Berkeley
63 National Laboratory, without imposing a separate written license agreement
64 for such Enhancements, then you hereby grant the following license: a
65 non-exclusive, royalty-free perpetual license to install, use, modify,
66 prepare derivative works, incorporate into other computer software,
67 distribute, and sublicense such enhancements or derivative works thereof,
68 in binary and source code form.
69 */
70 
80 #ifndef END_POINT_ADIOS_H
81 #define END_POINT_ADIOS_H
82 
83 #include "ft_type.h"
84 #include "ft_endpoint.h"
85 #include <string>
86 #include <iostream>
87 #include <vector>
88 #include <math.h>
89 
90 //#define HAS_ADIOS_END_POINT 1
91 
92 #ifdef HAS_ADIOS_END_POINT
93 
94 #include <adios2_c.h>
95 class EndpointADIOS : public Endpoint
96 {
97 private:
98  std::string fn_str, vn_str; //file name and variable name
99  adios2_type adios2_data_element_type;
100  //adios2_variable *v;
101  std::vector<size_t> adios_shape, adios_start, adios_count;
102 
103  adios2_adios *adios;
104  adios2_io *rw_io;
105  adios2_variable *rw_variable;
106  adios2_engine *rw_engine;
107 
108 public:
114  EndpointADIOS(std::string endpoint_info_p)
115  {
116  endpoint_info = endpoint_info_p;
118 
119  adios = adios2_init(MPI_COMM_WORLD, adios2_debug_mode_on);
120  if (adios == NULL)
121  {
122  printf("ERROR: invalid %s handler at line %d \n", "adios2_init", __LINE__);
123  exit(EXIT_FAILURE);
124  }
125 
126  rw_io = adios2_declare_io(adios, "SomeName");
127  if (rw_io == NULL)
128  {
129  printf("ERROR: invalid %s handler at line %d \n", "adios2_declare_io", __LINE__);
130  exit(EXIT_FAILURE);
131  }
132 
133  //std::cout << "Init done \n";
134  SetOpenFlag(false);
135  SetCreateFlag(false);
136  }
138  {
139  Close();
140  adios2_finalize(adios);
141  //std::cout << "Close done \n";
142  }
148  int ExtractMeta() override;
154  int PrintInfo() override;
155 
161  int Create() override;
162 
168  int Open() override;
169 
178  int Read(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) override;
179 
188  int Write(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) override;
189 
195  int Close() override;
196 
197  void Map2MyType() override;
198 
199  int ParseEndpointInfo() override;
200 };
201 #else
202 class EndpointADIOS : public Endpoint
203 {
204 private:
205 public:
211  EndpointADIOS(std::string endpoint_info_p)
212  {
213  std::cout << "EndpointADIOS is not configured and compiled ! \n";
214  AU_EXIT(-1);
215  }
217  {
218  Close();
219  }
220 
221  int ParseEndpointInfo() override
222  {
223  return -1;
224  }
225 
226  int ExtractMeta() override
227  {
228  return -1;
229  }
230 
231  int PrintInfo() override
232  {
233  return -1;
234  }
235 
236  int Create() override
237  {
238  return -1;
239  }
240 
241  int Open() override
242  {
243  return -1;
244  }
245 
246  void Map2MyType() override
247  {
248  }
249 
250  int Read(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) override
251  {
252  return -1;
253  }
254 
255  int Write(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) override
256  {
257  return -1;
258  }
259 
260  int Close() override
261  {
262  return -1;
263  }
264 };
265 #endif
266 #endif
Definition: ft_endpoint_adios.h:203
int Close() override
close the end-point
Definition: ft_endpoint_adios.h:260
int ParseEndpointInfo() override
parse endpoint_info to my own info
Definition: ft_endpoint_adios.h:221
int Create() override
create the endpoint
Definition: ft_endpoint_adios.h:236
int PrintInfo() override
print information about the endpoint
Definition: ft_endpoint_adios.h:231
int Write(std::vector< unsigned long long > start, std::vector< unsigned long long > end, void *data) override
write the data to the end-point
Definition: ft_endpoint_adios.h:255
int Open() override
open the endpoint
Definition: ft_endpoint_adios.h:241
int ExtractMeta() override
extracts metadata, possbile endpoint_ranks/endpoint_dim_size/other ep_type dependents ones
Definition: ft_endpoint_adios.h:226
~EndpointADIOS()
Definition: ft_endpoint_adios.h:216
EndpointADIOS(std::string endpoint_info_p)
Construct a new EndpointHDF5 object.
Definition: ft_endpoint_adios.h:211
void Map2MyType() override
call the finalize to close everything (like call Destractor)
Definition: ft_endpoint_adios.h:246
int Read(std::vector< unsigned long long > start, std::vector< unsigned long long > end, void *data) override
read the data from end-point
Definition: ft_endpoint_adios.h:250
Define the class for the Endpoint used by ArrayUDF to store the data. It contains basic infomation fo...
Definition: ft_endpoint.h:106
void SetCreateFlag(bool open_flag_p)
Definition: ft_endpoint.cpp:166
void SetOpenFlag(bool open_flag_p)
Definition: ft_endpoint.cpp:156
std::string endpoint_info
Definition: ft_endpoint.h:109
#define AU_EXIT(info)
Definition: ft_utility_macro.h:147