FasTensor  1.0.0
Transform Supercomputing for AI
ft_endpoint.h
Go to the documentation of this file.
1 
2 
3 /*
4 ****************************
5 
6 FasTensor (FT) Copyright (c) 2021, The Regents of the University of
7 California, through Lawrence Berkeley National Laboratory (subject to
8 receipt of any required approvals from the U.S. Dept. of Energy).
9 All rights reserved.
10 
11 If you have questions about your rights to use or distribute this software,
12 please contact Berkeley Lab's Intellectual Property Office at
14 
15 NOTICE. This Software was developed under funding from the U.S. Department
16 of Energy and the U.S. Government consequently retains certain rights. As
17 such, the U.S. Government has been granted for itself and others acting on
18 its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the
19 Software to reproduce, distribute copies to the public, prepare derivative
20 works, and perform publicly and display publicly, and to permit others to do so.
21 
22 
23 ****************************
24 
25 
26 *** License Agreement ***
27 
28 FasTensor (FT) Copyright (c) 2021, The Regents of the University of
29 California, through Lawrence Berkeley National Laboratory (subject to
30 receipt of any required approvals from the U.S. Dept. of Energy).
31 All rights reserved.
32 
33 Redistribution and use in source and binary forms, with or without
34 modification, are permitted provided that the following conditions are met:
35 
36 (1) Redistributions of source code must retain the above copyright notice,
37 this list of conditions and the following disclaimer.
38 
39 (2) Redistributions in binary form must reproduce the above copyright
40 notice, this list of conditions and the following disclaimer in the
41 documentation and/or other materials provided with the distribution.
42 
43 (3) Neither the name of the University of California, Lawrence Berkeley
44 National Laboratory, U.S. Dept. of Energy nor the names of its contributors
45 may be used to endorse or promote products derived from this software
46 without specific prior written permission.
47 
48 
49 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
50 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
53 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
54 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
55 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
56 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
57 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
58 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
59 POSSIBILITY OF SUCH DAMAGE.
60 
61 You are under no obligation whatsoever to provide any bug fixes, patches,
62 or upgrades to the features, functionality or performance of the source
63 code ("Enhancements") to anyone; however, if you choose to make your
64 Enhancements available either publicly, or directly to Lawrence Berkeley
65 National Laboratory, without imposing a separate written license agreement
66 for such Enhancements, then you hereby grant the following license: a
67 non-exclusive, royalty-free perpetual license to install, use, modify,
68 prepare derivative works, incorporate into other computer software,
69 distribute, and sublicense such enhancements or derivative works thereof,
70 in binary and source code form.
71 */
72 
82 #ifndef END_POINT_H
83 #define END_POINT_H
84 
85 #include "ft_utility.h"
86 #include "ft_type.h"
87 #include <string>
88 #include <iostream>
89 #include <vector>
90 #include <math.h>
91 
92 using namespace std;
93 
94 //Todo:
95 //This might be general command
96 #define OP_CREATE_VIS_SCRIPT 4
97 #define OP_LIST_TAG 5
98 
105 class Endpoint
106 {
107 protected:
109  std::string endpoint_info;
110  std::vector<unsigned long long> endpoint_size;
111 
114  std::string data_endpoint_orig;
115 
116  bool set_endpoint_dim_size_flag = false;
117  bool open_flag = false;
118  bool create_flag = false;
119  unsigned read_write_flag;
120 
121 public:
122  Endpoint(){};
123  virtual ~Endpoint(){};
124 
130  std::vector<unsigned long long> GetDimensions();
131 
137  void SetDimensions(std::vector<unsigned long long> endpoint_dim_size_p);
138 
144  void SetDataElementType(AuEndpointDataType data_element_type_p);
145 
151  AuEndpointDataType GetDataElementType();
152 
158  int GetDataElementTypeSize();
159 
165  void SetEndpointType(AuEndpointType endpoint_type_p);
166 
172  AuEndpointType GetEndpointType();
173 
174  bool GetOpenFlag();
175 
176  void SetOpenFlag(bool open_flag_p);
177 
178  bool GetCreateFlag();
179 
180  void SetCreateFlag(bool open_flag_p);
181 
182  void SetRwFlag(unsigned read_write_flag_p);
183 
184  unsigned GetRwFlag();
185 
192  std::vector<AuEndpointDataTypeUnion> Void2Union(void *vp, size_t n_elements);
193 
200  void *Union2Void(std::vector<AuEndpointDataTypeUnion> &data_vector_in_union_type);
201 
207  void SetEndpointInfo(std::string endpoint_info_p);
208 
214  std::string GetEndpointInfo();
215 
221  virtual int ParseEndpointInfo() = 0;
222 
228  virtual int ExtractMeta() = 0;
234  virtual int PrintInfo() = 0;
235 
241  virtual int Create() = 0;
242 
248  virtual int Open() = 0;
249 
258  virtual int Read(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) = 0;
259 
268  virtual int Write(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) = 0;
269 
277  virtual int WriteAttribute(const std::string &name, const void *data, FTDataType data_type_p, const size_t &data_length_p = 0);
278 
286  virtual int ReadAttribute(const std::string &name, void *data, FTDataType data_type_p, const size_t &data_length_p = 0);
287 
288  virtual int GetAttributeSize(const std::string &name, FTDataType data_type_p);
289 
295  virtual int Close() = 0;
296 
302  //virtual int Finalize() = 0;
303 
304  virtual void Map2MyType() = 0;
305 
306  virtual void EnableCollectiveIO();
307 
308  virtual void DisableCollectiveIO();
309 
315  virtual std::vector<std::string> GetDirFileVector();
316 
322  virtual void SetDirFileVector(std::vector<std::string> &file_list);
323 
329  virtual std::vector<int> GetDirChunkSize();
330 
336  virtual void SetDirChunkSize(std::vector<int> &dir_chunk_size_p);
337 
344  //virtual int SpecialOperator(int opt_code, std::string parameter);
345 
353  //virtual int SpecialOperator(int opt_code, std::vector<std::string> parameter_v);
354  virtual int Control(int opt_code, std::vector<std::string> &parameter_v);
361  virtual int MapOpStr2Int(std::string op_cmd_str);
362 
369  virtual std::string MapOpInt2Str(int op_int);
370 };
371 
372 #endif
Define the class for the Endpoint used by ArrayUDF to store the data. It contains basic infomation fo...
Definition: ft_endpoint.h:106
std::string data_endpoint_orig
Definition: ft_endpoint.h:114
AuEndpointType endpoint_type
Definition: ft_endpoint.h:108
Endpoint()
Definition: ft_endpoint.h:122
int endpoint_ranks
Definition: ft_endpoint.h:112
virtual int Read(std::vector< unsigned long long > start, std::vector< unsigned long long > end, void *data)=0
read the data from end-point
std::vector< unsigned long long > endpoint_size
Definition: ft_endpoint.h:110
virtual ~Endpoint()
Definition: ft_endpoint.h:123
virtual int ExtractMeta()=0
extracts metadata, possbile endpoint_ranks/endpoint_dim_size/other ep_type dependents ones
virtual int Open()=0
open the endpoint
virtual int Write(std::vector< unsigned long long > start, std::vector< unsigned long long > end, void *data)=0
write the data to the end-point
virtual void Map2MyType()=0
call the finalize to close everything (like call Destractor)
virtual int Close()=0
close the end-point
unsigned read_write_flag
Definition: ft_endpoint.h:119
virtual int ParseEndpointInfo()=0
parse endpoint_info to my own info
AuEndpointDataType data_element_type
Definition: ft_endpoint.h:113
std::string endpoint_info
Definition: ft_endpoint.h:109
virtual int Create()=0
create the endpoint
virtual int PrintInfo()=0
print information about the endpoint
AuEndpointType
Definition: ft_type.h:95
AuEndpointDataType
Definition: ft_type.h:118