FasTensor  1.0.0
Transform Supercomputing for AI
ft_endpoint_pnetcdf.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_PNETCDF_H
83 #define END_POINT_PNETCDF_H
84 
85 #include "ft_type.h"
86 #include "ft_endpoint.h"
87 #include <string>
88 #include <iostream>
89 #include <vector>
90 #include <math.h>
91 
92 #ifdef HAS_PNETCDF_END_POINT
93 
94 #include "ft_mpi.h"
95 #include "pnetcdf.h"
96 
97 class EndpointPnetCDF : public Endpoint
98 {
99 private:
100  std::string fn_str, vn_str; //file name and variable name
101  MPI_Datatype element_type_mpi; //PnetCDF use MPI type
102  nc_type element_type_nc; //PnetCDF's native type
103  int ncfile, ncvar;
104 
105 public:
111  EndpointPnetCDF(std::string endpoint_info_p)
112  {
113  endpoint_info = endpoint_info_p;
115 
116  SetOpenFlag(false);
117  SetCreateFlag(false);
118  }
120  {
121  }
127  int ExtractMeta() override;
133  int PrintInfo() override;
134 
140  int Create() override;
141 
147  int Open() override;
148 
157  int Read(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) override;
158 
167  int Write(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) override;
168 
174  int Close() override;
175 
176  void Map2MyType() override;
177 
178  int ParseEndpointInfo() override;
179 };
180 #else
181 class EndpointPnetCDF : public Endpoint
182 {
183 private:
184 public:
190  EndpointPnetCDF(std::string endpoint_info_p)
191  {
192  std::cout << "EndpointADIOS is not configured and compiled ! \n";
193  }
195  {
196  Close();
197  }
198 
199  int ParseEndpointInfo() override
200  {
201  return -1;
202  }
203 
204  int ExtractMeta() override
205  {
206  return -1;
207  }
208 
209  int PrintInfo() override
210  {
211  return -1;
212  }
213 
214  int Create() override
215  {
216  return -1;
217  }
218 
219  int Open() override
220  {
221  return -1;
222  }
223 
224  void Map2MyType() override
225  {
226  }
227 
228  int Read(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) override
229  {
230  return -1;
231  }
232 
233  int Write(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) override
234  {
235  return -1;
236  }
237 
238  int Close() override
239  {
240  return -1;
241  }
242 };
243 #endif
244 #endif
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
Definition: ft_endpoint_pnetcdf.h:182
int Create() override
create the endpoint
Definition: ft_endpoint_pnetcdf.h:214
EndpointPnetCDF(std::string endpoint_info_p)
Construct a new EndpointHDF5 object.
Definition: ft_endpoint_pnetcdf.h:190
int PrintInfo() override
print information about the endpoint
Definition: ft_endpoint_pnetcdf.h:209
int ParseEndpointInfo() override
parse endpoint_info to my own info
Definition: ft_endpoint_pnetcdf.h:199
int Open() override
open the endpoint
Definition: ft_endpoint_pnetcdf.h:219
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_pnetcdf.h:228
void Map2MyType() override
call the finalize to close everything (like call Destractor)
Definition: ft_endpoint_pnetcdf.h:224
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_pnetcdf.h:233
int ExtractMeta() override
extracts metadata, possbile endpoint_ranks/endpoint_dim_size/other ep_type dependents ones
Definition: ft_endpoint_pnetcdf.h:204
~EndpointPnetCDF()
Definition: ft_endpoint_pnetcdf.h:194
int Close() override
close the end-point
Definition: ft_endpoint_pnetcdf.h:238