29 void Init(
const std::string &IOName){}
32 void Open(
const std::string &StreamName,
const XGC_IO_Mode mode,
const MPI_Comm &comm){}
40 inline View<T*, HostType, Kokkos::MemoryTraits<Kokkos::Unmanaged>>
scalar_view_wrap(T& scalar){
41 return View<T*, HostType, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(&scalar, 1);
47 virtual void adios_def_and_shape(
const ADIOS2Stream& stream)
const = 0;
48 virtual void adios_put(
const ADIOS2Stream& stream)
const = 0;
64 IOScalar(
const std::string& name_in, T& value_in)
71 IOScalar(
const std::string& name_in,
const T& value_in)
77 void adios_def_and_shape(
const ADIOS2Stream& stream)
const {
78 if(!stream.
io->InquireVariable<T>(
name)){
79 stream.
io->DefineVariable<T>(
name);
88 if(
var_is_const) printf(
"\nError: Tried to read into const variable\n");
96 std::vector<size_t>
vec;
100 template <
typename... Args>
105 template <
typename First,
typename... Rest>
107 vec.push_back(static_cast<size_t>(first));
108 if constexpr (
sizeof...(rest) > 0) {
139 int dim_offset =
size.size() - T::rank;
141 for(
int i=0; i<
size.size(); i++){
142 if(i - dim_offset >= 0){
143 size[i] =
view.extent(i - dim_offset);
151 IOArray(
const std::string& name_in,
const T& view_in)
159 for(
int i=0; i<
size.size(); i++){
168 void adios_def_and_shape(
const ADIOS2Stream& stream)
const {
169 auto TAG = stream.
io->InquireVariable<
typename T::value_type>(
name);
178 auto TAG = stream.
io->InquireVariable<
typename T::value_type>(
name);
180 stream.
engine->Put<
typename T::value_type>(TAG,
view.data(), adios2::Mode::Sync);
184 auto TAG = stream.
io->InquireVariable<
typename T::value_type>(
name);
186 stream.
engine->Get<
typename T::value_type>(TAG,
view.data());
199 void add(
const T& new_data){
200 io_data.push_back(std::make_unique<T>(new_data));
204 template<
class T,
class... Ts>
205 void add(
const T& new_data,
const Ts&... new_data_rest){
207 add(new_data_rest...);
214 for(
int i=0; i<
io_data.size(); i++)
215 io_data[i]->adios_def_and_shape(stream);
218 for(
int i=0; i<
io_data.size(); i++)
222 stream.engine->PerformPuts();
230 for(
int i=0; i<
io_data.size(); i++)
234 stream.engine->PerformGets();
242 if(stream.io->InquireVariable<T>(varname))
return true;
Definition: xgc_io.hpp:95
void write(const XGC_IO_Stream &stream) const
Definition: xgc_io.hpp:211
void Open(const std::string &StreamName, const XGC_IO_Mode mode)
Definition: xgc_io.hpp:30
IOScalar(const std::string &name_in, T &value_in)
Definition: xgc_io.hpp:64
Definition: xgc_io.hpp:44
Definition: xgc_io.hpp:192
dim_type size
Definition: xgc_io.hpp:126
dim_type offsets
Definition: xgc_io.hpp:125
std::vector< std::unique_ptr< IOData > > io_data
Definition: xgc_io.hpp:193
std::vector< size_t > vec
Definition: xgc_io.hpp:96
IOScalar(const std::string &name_in, const T &value_in)
Definition: xgc_io.hpp:71
Definition: xgc_io.hpp:56
void read(const XGC_IO_Stream &stream)
Definition: xgc_io.hpp:227
IOArray(const std::string &name_in, const T &view_in, const UpcastVector &full_size_in, const UpcastVector &offsets_in)
Definition: xgc_io.hpp:131
XGC_IO_Stream()
Definition: xgc_io.hpp:26
bool var_is_const
Definition: xgc_io.hpp:61
void add(const T &new_data)
Definition: xgc_io.hpp:199
std::string name
Definition: xgc_io.hpp:58
void addValues(First first, Rest...rest)
Definition: xgc_io.hpp:106
virtual ~IOData()
Definition: xgc_io.hpp:51
T view_type
Definition: xgc_io.hpp:118
value_type value
Definition: xgc_io.hpp:60
View< T *, HostType, Kokkos::MemoryTraits< Kokkos::Unmanaged > > scalar_view_wrap(T &scalar)
Definition: xgc_io.hpp:40
Definition: xgc_io.hpp:117
UpcastVector(Args...args)
Definition: xgc_io.hpp:101
EnginePtr engine
Definition: adios2.hpp:30
Definition: adios2.hpp:26
static bool is_present(const XGC_IO_Stream &stream, const std::string &varname)
Definition: xgc_io.hpp:240
std::vector< size_t > dim_type
Definition: xgc_io.hpp:119
XGC_IO_Stream(const std::string &IOName)
Definition: xgc_io.hpp:27
void add(const T &new_data, const Ts &...new_data_rest)
Definition: xgc_io.hpp:205
Definition: xgc_io.hpp:24
XGC_IO_Mode
Definition: xgc_io.hpp:17
IOArray(const std::string &name_in, const T &view_in)
Definition: xgc_io.hpp:151
std::string name
Definition: xgc_io.hpp:120
IOPtr io
Definition: adios2.hpp:29
void Close()
Definition: xgc_io.hpp:34
T value_type
Definition: xgc_io.hpp:57
void Init(const std::string &IOName)
Definition: xgc_io.hpp:29
view_type view
Definition: xgc_io.hpp:121
value_type * value_addr
Definition: xgc_io.hpp:59
dim_type full_size
Definition: xgc_io.hpp:124