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

Per-rank JSON file serializer; each MPI rank writes its own .json file. More...

#include <SerializerJSON.hpp>

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

Public Member Functions

void SetUseCodecOnUint8 (bool v)
 
void SetDeflateLevel (int v)
 
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.
 
 ~SerializerJSON () 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

Per-rank JSON file serializer; each MPI rank writes its own .json file.

Definition at line 25 of file SerializerJSON.hpp.

Constructor & Destructor Documentation

◆ ~SerializerJSON()

DNDS::Serializer::SerializerJSON::~SerializerJSON ( )
inlineoverride

Definition at line 86 of file SerializerJSON.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ CloseFile()

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

Close the backing file, flushing buffers.

Implements DNDS::Serializer::SerializerBase.

Definition at line 48 of file SerializerJSON.cpp.

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

◆ CloseFileNonVirtual()

void DNDS::Serializer::SerializerJSON::CloseFileNonVirtual ( )

Definition at line 52 of file SerializerJSON.cpp.

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

◆ CreatePath()

void DNDS::Serializer::SerializerJSON::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 62 of file SerializerJSON.cpp.

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

◆ GetCurrentPath()

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

String form of the current path.

Implements DNDS::Serializer::SerializerBase.

Definition at line 85 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ getMPI()

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

MPI context the serializer was opened with.

Implements DNDS::Serializer::SerializerBase.

Definition at line 53 of file SerializerJSON.hpp.

◆ GetMPIRank()

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

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

Implements DNDS::Serializer::SerializerBase.

Definition at line 51 of file SerializerJSON.hpp.

◆ GetMPISize()

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

Rank count cached by the serializer.

Implements DNDS::Serializer::SerializerBase.

Definition at line 52 of file SerializerJSON.hpp.

◆ GoToPath()

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

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

Implements DNDS::Serializer::SerializerBase.

Definition at line 73 of file SerializerJSON.cpp.

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

◆ IsPerRank()

bool DNDS::Serializer::SerializerJSON::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 48 of file SerializerJSON.hpp.

◆ ListCurrentPath()

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

Names of direct children of the current path.

Implements DNDS::Serializer::SerializerBase.

Definition at line 90 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ OpenFile()

void DNDS::Serializer::SerializerJSON::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 34 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ ReadIndex()

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

Read a scalar index into v.

Implements DNDS::Serializer::SerializerBase.

Definition at line 167 of file SerializerJSON.cpp.

◆ ReadIndexVector()

void DNDS::Serializer::SerializerJSON::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 179 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ ReadInt()

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

Read a scalar int into v.

Implements DNDS::Serializer::SerializerBase.

Definition at line 161 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ ReadReal()

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

Read a scalar real into v.

Implements DNDS::Serializer::SerializerBase.

Definition at line 173 of file SerializerJSON.cpp.

◆ ReadRealVector()

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

Implements DNDS::Serializer::SerializerBase.

Definition at line 193 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ ReadRowsizeVector()

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

Implements DNDS::Serializer::SerializerBase.

Definition at line 186 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ ReadSharedIndexVector()

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

Implements DNDS::Serializer::SerializerBase.

Definition at line 206 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ ReadSharedRowsizeVector()

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

Implements DNDS::Serializer::SerializerBase.

Definition at line 235 of file SerializerJSON.cpp.

◆ ReadString()

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

Read a UTF-8 string into v.

Implements DNDS::Serializer::SerializerBase.

Definition at line 200 of file SerializerJSON.cpp.

◆ ReadUint8Array()

void DNDS::Serializer::SerializerJSON::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 292 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ SetDeflateLevel()

void DNDS::Serializer::SerializerJSON::SetDeflateLevel ( int  v)
inline

Definition at line 41 of file SerializerJSON.hpp.

Here is the caller graph for this function:

◆ SetUseCodecOnUint8()

void DNDS::Serializer::SerializerJSON::SetUseCodecOnUint8 ( bool  v)
inline

Definition at line 40 of file SerializerJSON.hpp.

Here is the caller graph for this function:

◆ WriteIndex()

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

Write a scalar index under name.

Implements DNDS::Serializer::SerializerBase.

Definition at line 106 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ WriteIndexVector()

void DNDS::Serializer::SerializerJSON::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 116 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ WriteIndexVectorPerRank()

void DNDS::Serializer::SerializerJSON::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 68 of file SerializerJSON.hpp.

Here is the call graph for this function:

◆ WriteInt()

void DNDS::Serializer::SerializerJSON::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 101 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ WriteReal()

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

Write a scalar real under name.

Implements DNDS::Serializer::SerializerBase.

Definition at line 111 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ WriteRealVector()

void DNDS::Serializer::SerializerJSON::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 126 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ WriteRowsizeVector()

void DNDS::Serializer::SerializerJSON::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 121 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ WriteSharedIndexVector()

void DNDS::Serializer::SerializerJSON::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 136 of file SerializerJSON.cpp.

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

◆ WriteSharedRowsizeVector()

void DNDS::Serializer::SerializerJSON::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 148 of file SerializerJSON.cpp.

Here is the call graph for this function:

◆ WriteString()

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

Write a UTF-8 string under name.

Implements DNDS::Serializer::SerializerBase.

Definition at line 131 of file SerializerJSON.cpp.

Here is the caller graph for this function:

◆ WriteUint8Array()

void DNDS::Serializer::SerializerJSON::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 264 of file SerializerJSON.cpp.

Here is the caller graph for this function:

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