55 std::vector<std::string> cPathSplit;
60 MPI_Comm commDup{MPI_COMM_NULL};
66 bool collectiveMetadataRW =
true;
67 bool collectiveDataRW =
false;
72 MPI_Comm_dup(mpi.comm, &commDup);
77 if (n_deflateLevel > 0)
78 DNDS_assert_info(n_chunksize > 0,
"chunksize must be positive when using deflate!");
79 chunksize = n_chunksize;
80 deflateLevel = n_deflateLevel;
85 collectiveMetadataRW = metadata;
86 collectiveDataRW = data;
89 void OpenFile(
const std::string &fName,
bool read)
override;
92 void CreatePath(
const std::string &p)
override;
93 void GoToPath(
const std::string &p)
override;
101 void WriteInt(
const std::string &name,
int v)
override;
104 void WriteString(
const std::string &name,
const std::string &
v)
override;
119 void ReadInt(
const std::string &name,
int &
v)
override;
122 void ReadString(
const std::string &name, std::string &
v)
override;
135 MPI_Comm_free(&commDup);
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
Base types and abstract interface for array serialization.
Describes one rank's window into a globally-distributed dataset.
Abstract interface for reading/writing scalars, vectors, and byte arrays.
MPI-parallel HDF5 serializer; all ranks collectively read/write a single .h5 file.
void WriteIndex(const std::string &name, index v) override
Write a scalar index under name.
void ReadRealVector(const std::string &name, std::vector< real > &v, ArrayGlobalOffset &offset) override
std::string GetCurrentPath() override
String form of the current path.
void WriteSharedIndexVector(const std::string &name, const ssp< host_device_vector< index > > &v, ArrayGlobalOffset offset) override
Write a shared index vector; deduplicated across multiple writes that share the same shared_ptr.
void ReadSharedRowsizeVector(const std::string &name, ssp< host_device_vector< rowsize > > &v, ArrayGlobalOffset &offset) override
void ReadIndexVector(const std::string &name, std::vector< index > &v, ArrayGlobalOffset &offset) override
void ReadIndex(const std::string &name, index &v) override
Read a scalar index into v.
void WriteInt(const std::string &name, int v) override
Write a scalar int under name at the current path.
void WriteUint8Array(const std::string &name, const uint8_t *data, index size, ArrayGlobalOffset offset) override
Write a raw byte buffer under name. offset.isDist() = true means the caller provides the exact per-ra...
std::set< std::string > ListCurrentPath() override
Names of direct children of the current path.
int GetMPISize() override
Rank count cached by the serializer.
void ReadInt(const std::string &name, int &v) override
Read a scalar int into v.
SerializerH5(const MPIInfo &_mpi)
void OpenFile(const std::string &fName, bool read) override
Open a backing file (H5 file or JSON file depending on subclass).
void WriteRealVector(const std::string &name, const std::vector< real > &v, ArrayGlobalOffset offset) override
Write a real vector (collective for H5).
const MPIInfo & getMPI() override
MPI context the serializer was opened with.
void GoToPath(const std::string &p) override
Navigate to an existing path. Supports / -separated segments.
void WriteReal(const std::string &name, real v) override
Write a scalar real under name.
void ReadReal(const std::string &name, real &v) override
Read a scalar real into v.
bool IsPerRank() override
Whether this serializer is per-rank (JSON-file-per-rank) or collective (shared H5 file)....
void ReadRowsizeVector(const std::string &name, std::vector< rowsize > &v, ArrayGlobalOffset &offset) override
void CloseFile() override
Close the backing file, flushing buffers.
int GetMPIRank() override
Rank index cached by the serializer (relevant for collective I/O).
void WriteString(const std::string &name, const std::string &v) override
Write a UTF-8 string under name.
void CreatePath(const std::string &p) override
Create a sub-path (H5 group / JSON object) at the current location.
void WriteIndexVectorPerRank(const std::string &name, const std::vector< index > &v) override
Write a per-rank index vector (replicated name, independent values).
void SetChunkAndDeflate(int64_t n_chunksize, int n_deflateLevel)
void SetCollectiveRW(bool metadata, bool data)
void ReadString(const std::string &name, std::string &v) override
Read a UTF-8 string into v.
void WriteSharedRowsizeVector(const std::string &name, const ssp< host_device_vector< rowsize > > &v, ArrayGlobalOffset offset) override
Write a shared rowsize vector; deduplicated across multiple writes.
void WriteRowsizeVector(const std::string &name, const std::vector< rowsize > &v, ArrayGlobalOffset offset) override
Write a rowsize vector (collective for H5).
void CloseFileNonVirtual()
void ReadSharedIndexVector(const std::string &name, ssp< host_device_vector< index > > &v, ArrayGlobalOffset &offset) override
void WriteIndexVector(const std::string &name, const std::vector< index > &v, ArrayGlobalOffset offset) override
Write an index vector (collective for H5). offset carries the distribution mode (ArrayGlobalOffset_Pa...
void ReadUint8Array(const std::string &name, uint8_t *data, index &size, ArrayGlobalOffset &offset) override
Two-pass byte array read.
Host + optional device vector of trivially copyable T.
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
std::shared_ptr< T > ssp
Shortened alias for std::shared_ptr used pervasively in DNDSR.
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
Lightweight bundle of an MPI communicator and the calling rank's coordinates.
Eigen::Matrix< real, 5, 1 > v