DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
DNDS::Serializer::SerializerH5 Class Reference

MPI-parallel HDF5 serializer; all ranks collectively read/write a single .h5 file. More...

#include <SerializerH5.hpp>

Inheritance diagram for DNDS::Serializer::SerializerH5:
[legend]
Collaboration diagram for DNDS::Serializer::SerializerH5:
[legend]

Public Member Functions

 SerializerH5 (const MPIInfo &_mpi)
 
void SetChunkAndDeflate (int64_t n_chunksize, int n_deflateLevel)
 
void SetCollectiveRW (bool metadata, bool data)
 
void OpenFile (const std::string &fName, bool read) override
 Open a backing file (H5 file or JSON file depending on subclass).
 
void CloseFile () override
 Close the backing file, flushing buffers.
 
void CloseFileNonVirtual ()
 
void CreatePath (const std::string &p) override
 Create a sub-path (H5 group / JSON object) at the current location.
 
void GoToPath (const std::string &p) override
 Navigate to an existing path. Supports / -separated segments.
 
bool IsPerRank () override
 Whether this serializer is per-rank (JSON-file-per-rank) or collective (shared H5 file). Controls which API entry points are used.
 
std::string GetCurrentPath () override
 String form of the current path.
 
std::set< std::string > ListCurrentPath () override
 Names of direct children of the current path.
 
int GetMPIRank () override
 Rank index cached by the serializer (relevant for collective I/O).
 
int GetMPISize () override
 Rank count cached by the serializer.
 
const MPIInfogetMPI () override
 MPI context the serializer was opened with.
 
void WriteInt (const std::string &name, int v) override
 Write a scalar int under name at the current path.
 
void WriteIndex (const std::string &name, index v) override
 Write a scalar index under name.
 
void WriteReal (const std::string &name, real v) override
 Write a scalar real under name.
 
void WriteString (const std::string &name, const std::string &v) override
 Write a UTF-8 string under name.
 
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_Parts, explicit offset, etc.).
 
void WriteRowsizeVector (const std::string &name, const std::vector< rowsize > &v, ArrayGlobalOffset offset) override
 Write a rowsize vector (collective for H5).
 
void WriteRealVector (const std::string &name, const std::vector< real > &v, ArrayGlobalOffset offset) override
 Write a real vector (collective for H5).
 
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 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 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-rank slab; otherwise the buffer is treated according to the offset's sentinel.
 
void WriteIndexVectorPerRank (const std::string &name, const std::vector< index > &v) override
 Write a per-rank index vector (replicated name, independent values).
 
void ReadInt (const std::string &name, int &v) override
 Read a scalar int into v.
 
void ReadIndex (const std::string &name, index &v) override
 Read a scalar index into v.
 
void ReadReal (const std::string &name, real &v) override
 Read a scalar real into v.
 
void ReadString (const std::string &name, std::string &v) override
 Read a UTF-8 string into v.
 
void ReadIndexVector (const std::string &name, std::vector< index > &v, ArrayGlobalOffset &offset) override
 
void ReadRowsizeVector (const std::string &name, std::vector< rowsize > &v, ArrayGlobalOffset &offset) override
 
void ReadRealVector (const std::string &name, std::vector< real > &v, ArrayGlobalOffset &offset) override
 
void ReadSharedIndexVector (const std::string &name, ssp< host_device_vector< index > > &v, ArrayGlobalOffset &offset) override
 
void ReadSharedRowsizeVector (const std::string &name, ssp< host_device_vector< rowsize > > &v, ArrayGlobalOffset &offset) override
 
void ReadUint8Array (const std::string &name, uint8_t *data, index &size, ArrayGlobalOffset &offset) override
 Two-pass byte array read.
 
 ~SerializerH5 () override
 
- Public Member Functions inherited from DNDS::Serializer::SerializerBase
virtual ~SerializerBase ()
 

Additional Inherited Members

- Protected Member Functions inherited from DNDS::Serializer::SerializerBase
template<class T >
bool dedupLookup (const ssp< T > &v, std::string &outPath)
 Check if a shared pointer was already written; if so return its path.
 
template<class T >
void dedupRegister (const ssp< T > &v, const std::string &path)
 Register a shared pointer after writing its data.
 
void dedupClear ()
 Clear all dedup state (call on CloseFile).
 
- Protected Attributes inherited from DNDS::Serializer::SerializerBase
std::map< void *, std::pair< std::shared_ptr< void >, std::string > > ptr_2_pth
 
std::map< std::string, void * > pth_2_ssp
 Reverse map for read-side dedup: path -> raw pointer to the ssp local variable.
 

Detailed Description

MPI-parallel HDF5 serializer; all ranks collectively read/write a single .h5 file.

Definition at line 52 of file SerializerH5.hpp.

Constructor & Destructor Documentation

◆ SerializerH5()

DNDS::Serializer::SerializerH5::SerializerH5 ( const MPIInfo _mpi)
inline

Definition at line 70 of file SerializerH5.hpp.

◆ ~SerializerH5()

DNDS::Serializer::SerializerH5::~SerializerH5 ( )
inlineoverride

Definition at line 132 of file SerializerH5.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ CloseFile()

void DNDS::Serializer::SerializerH5::CloseFile ( )
overridevirtual

Close the backing file, flushing buffers.

Implements DNDS::Serializer::SerializerBase.

Definition at line 125 of file SerializerH5.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CloseFileNonVirtual()

void DNDS::Serializer::SerializerH5::CloseFileNonVirtual ( )

Definition at line 129 of file SerializerH5.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreatePath()

void DNDS::Serializer::SerializerH5::CreatePath ( const std::string &  p)
overridevirtual

Create a sub-path (H5 group / JSON object) at the current location.

Implements DNDS::Serializer::SerializerBase.

Definition at line 138 of file SerializerH5.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCurrentPath()

std::string DNDS::Serializer::SerializerH5::GetCurrentPath ( )
overridevirtual

String form of the current path.

Implements DNDS::Serializer::SerializerBase.

Definition at line 165 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ getMPI()

const MPIInfo & DNDS::Serializer::SerializerH5::getMPI ( )
inlineoverridevirtual

MPI context the serializer was opened with.

Implements DNDS::Serializer::SerializerBase.

Definition at line 99 of file SerializerH5.hpp.

◆ GetMPIRank()

int DNDS::Serializer::SerializerH5::GetMPIRank ( )
inlineoverridevirtual

Rank index cached by the serializer (relevant for collective I/O).

Implements DNDS::Serializer::SerializerBase.

Definition at line 97 of file SerializerH5.hpp.

◆ GetMPISize()

int DNDS::Serializer::SerializerH5::GetMPISize ( )
inlineoverridevirtual

Rank count cached by the serializer.

Implements DNDS::Serializer::SerializerBase.

Definition at line 98 of file SerializerH5.hpp.

◆ GoToPath()

void DNDS::Serializer::SerializerH5::GoToPath ( const std::string &  p)
overridevirtual

Navigate to an existing path. Supports / -separated segments.

Implements DNDS::Serializer::SerializerBase.

Definition at line 153 of file SerializerH5.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsPerRank()

bool DNDS::Serializer::SerializerH5::IsPerRank ( )
inlineoverridevirtual

Whether this serializer is per-rank (JSON-file-per-rank) or collective (shared H5 file). Controls which API entry points are used.

Implements DNDS::Serializer::SerializerBase.

Definition at line 94 of file SerializerH5.hpp.

◆ ListCurrentPath()

std::set< std::string > DNDS::Serializer::SerializerH5::ListCurrentPath ( )
overridevirtual

Names of direct children of the current path.

Implements DNDS::Serializer::SerializerBase.

Definition at line 261 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ OpenFile()

void DNDS::Serializer::SerializerH5::OpenFile ( const std::string &  fName,
bool  read 
)
overridevirtual

Open a backing file (H5 file or JSON file depending on subclass).

Parameters
readtrue for reading, false for writing.

Implements DNDS::Serializer::SerializerBase.

Definition at line 109 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ ReadIndex()

void DNDS::Serializer::SerializerH5::ReadIndex ( const std::string &  name,
index v 
)
overridevirtual

Read a scalar index into v.

Implements DNDS::Serializer::SerializerBase.

Definition at line 598 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ ReadIndexVector()

void DNDS::Serializer::SerializerH5::ReadIndexVector ( const std::string &  name,
std::vector< index > &  v,
ArrayGlobalOffset offset 
)
overridevirtual

Read methods resize the output container and populate it. Internally these use a two-pass HDF5 pattern (size query, then data read). Both passes are collective. When the local size is 0, a dummy non-null pointer is passed to the second pass so the rank participates in H5Dread.

Implements DNDS::Serializer::SerializerBase.

Definition at line 828 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ ReadInt()

void DNDS::Serializer::SerializerH5::ReadInt ( const std::string &  name,
int &  v 
)
overridevirtual

Read a scalar int into v.

Implements DNDS::Serializer::SerializerBase.

Definition at line 594 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ ReadReal()

void DNDS::Serializer::SerializerH5::ReadReal ( const std::string &  name,
real v 
)
overridevirtual

Read a scalar real into v.

Implements DNDS::Serializer::SerializerBase.

Definition at line 602 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ ReadRealVector()

void DNDS::Serializer::SerializerH5::ReadRealVector ( const std::string &  name,
std::vector< real > &  v,
ArrayGlobalOffset offset 
)
overridevirtual

Implements DNDS::Serializer::SerializerBase.

Definition at line 846 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ ReadRowsizeVector()

void DNDS::Serializer::SerializerH5::ReadRowsizeVector ( const std::string &  name,
std::vector< rowsize > &  v,
ArrayGlobalOffset offset 
)
overridevirtual

Implements DNDS::Serializer::SerializerBase.

Definition at line 837 of file SerializerH5.cpp.

◆ ReadSharedIndexVector()

void DNDS::Serializer::SerializerH5::ReadSharedIndexVector ( const std::string &  name,
ssp< host_device_vector< index > > &  v,
ArrayGlobalOffset offset 
)
overridevirtual

Implements DNDS::Serializer::SerializerBase.

Definition at line 859 of file SerializerH5.cpp.

Here is the call graph for this function:

◆ ReadSharedRowsizeVector()

void DNDS::Serializer::SerializerH5::ReadSharedRowsizeVector ( const std::string &  name,
ssp< host_device_vector< rowsize > > &  v,
ArrayGlobalOffset offset 
)
overridevirtual

Implements DNDS::Serializer::SerializerBase.

Definition at line 893 of file SerializerH5.cpp.

Here is the call graph for this function:

◆ ReadString()

void DNDS::Serializer::SerializerH5::ReadString ( const std::string &  name,
std::string &  v 
)
overridevirtual

Read a UTF-8 string into v.

Implements DNDS::Serializer::SerializerBase.

Definition at line 855 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ ReadUint8Array()

void DNDS::Serializer::SerializerH5::ReadUint8Array ( const std::string &  name,
uint8_t *  data,
index size,
ArrayGlobalOffset offset 
)
overridevirtual

Two-pass byte array read.

Pass 1 (data == nullptr): queries the local element count into size and resolves offset. Pass 2 (data != nullptr): reads size bytes into data.

Warning
When size is 0 after pass 1, the caller must still pass a non-null data pointer on pass 2 so the rank participates in the collective HDF5 read. Use a stack dummy (uint8_t dummy; ... &dummy).

Implements DNDS::Serializer::SerializerBase.

Definition at line 931 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ SetChunkAndDeflate()

void DNDS::Serializer::SerializerH5::SetChunkAndDeflate ( int64_t  n_chunksize,
int  n_deflateLevel 
)
inline

Definition at line 75 of file SerializerH5.hpp.

◆ SetCollectiveRW()

void DNDS::Serializer::SerializerH5::SetCollectiveRW ( bool  metadata,
bool  data 
)
inline

Definition at line 83 of file SerializerH5.hpp.

◆ WriteIndex()

void DNDS::Serializer::SerializerH5::WriteIndex ( const std::string &  name,
index  v 
)
overridevirtual

Write a scalar index under name.

Implements DNDS::Serializer::SerializerBase.

Definition at line 345 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ WriteIndexVector()

void DNDS::Serializer::SerializerH5::WriteIndexVector ( const std::string &  name,
const std::vector< index > &  v,
ArrayGlobalOffset  offset 
)
overridevirtual

Write an index vector (collective for H5). offset carries the distribution mode (ArrayGlobalOffset_Parts, explicit offset, etc.).

Implements DNDS::Serializer::SerializerBase.

Definition at line 466 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ WriteIndexVectorPerRank()

void DNDS::Serializer::SerializerH5::WriteIndexVectorPerRank ( const std::string &  name,
const std::vector< index > &  v 
)
inlineoverridevirtual

Write a per-rank index vector (replicated name, independent values).

Every rank writes its own vector under name; in the H5 case each rank's slab is placed in a separate dataset.

Parameters
nameDataset name (identical on every rank).
vRank-local vector; size may differ between ranks.

Implements DNDS::Serializer::SerializerBase.

Definition at line 114 of file SerializerH5.hpp.

Here is the call graph for this function:

◆ WriteInt()

void DNDS::Serializer::SerializerH5::WriteInt ( const std::string &  name,
int  v 
)
overridevirtual

Write a scalar int under name at the current path.

Implements DNDS::Serializer::SerializerBase.

Definition at line 341 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ WriteReal()

void DNDS::Serializer::SerializerH5::WriteReal ( const std::string &  name,
real  v 
)
overridevirtual

Write a scalar real under name.

Implements DNDS::Serializer::SerializerBase.

Definition at line 349 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ WriteRealVector()

void DNDS::Serializer::SerializerH5::WriteRealVector ( const std::string &  name,
const std::vector< real > &  v,
ArrayGlobalOffset  offset 
)
overridevirtual

Write a real vector (collective for H5).

Implements DNDS::Serializer::SerializerBase.

Definition at line 474 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ WriteRowsizeVector()

void DNDS::Serializer::SerializerH5::WriteRowsizeVector ( const std::string &  name,
const std::vector< rowsize > &  v,
ArrayGlobalOffset  offset 
)
overridevirtual

Write a rowsize vector (collective for H5).

Implements DNDS::Serializer::SerializerBase.

Definition at line 470 of file SerializerH5.cpp.

◆ WriteSharedIndexVector()

void DNDS::Serializer::SerializerH5::WriteSharedIndexVector ( const std::string &  name,
const ssp< host_device_vector< index > > &  v,
ArrayGlobalOffset  offset 
)
overridevirtual

Write a shared index vector; deduplicated across multiple writes that share the same shared_ptr.

Implements DNDS::Serializer::SerializerBase.

Definition at line 482 of file SerializerH5.cpp.

Here is the call graph for this function:

◆ WriteSharedRowsizeVector()

void DNDS::Serializer::SerializerH5::WriteSharedRowsizeVector ( const std::string &  name,
const ssp< host_device_vector< rowsize > > &  v,
ArrayGlobalOffset  offset 
)
overridevirtual

Write a shared rowsize vector; deduplicated across multiple writes.

Implements DNDS::Serializer::SerializerBase.

Definition at line 495 of file SerializerH5.cpp.

Here is the call graph for this function:

◆ WriteString()

void DNDS::Serializer::SerializerH5::WriteString ( const std::string &  name,
const std::string &  v 
)
overridevirtual

Write a UTF-8 string under name.

Implements DNDS::Serializer::SerializerBase.

Definition at line 478 of file SerializerH5.cpp.

Here is the caller graph for this function:

◆ WriteUint8Array()

void DNDS::Serializer::SerializerH5::WriteUint8Array ( const std::string &  name,
const uint8_t *  data,
index  size,
ArrayGlobalOffset  offset 
)
overridevirtual

Write a raw byte buffer under name. offset.isDist() = true means the caller provides the exact per-rank slab; otherwise the buffer is treated according to the offset's sentinel.

Implements DNDS::Serializer::SerializerBase.

Definition at line 927 of file SerializerH5.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: