DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
test_Serializer.cpp File Reference

Doctest-based unit tests for DNDS Serializer classes. More...

#include "doctest.h"
#include "DNDS/SerializerJSON.hpp"
#include "DNDS/SerializerH5.hpp"
#include "DNDS/ArrayPair.hpp"
#include "DNDS/MPI.hpp"
#include <filesystem>
#include <numeric>
#include <algorithm>
Include dependency graph for test_Serializer.cpp:

Go to the source code of this file.

Classes

struct  FileGuard
 
struct  LayoutStaticFixed
 
struct  LayoutDynamic
 
struct  LayoutCSR
 
struct  RedistTag< T, Layout, RS >
 

Macros

#define DOCTEST_CONFIG_IMPLEMENT
 
#define REDIST_TAG_STR(T, L, RS)   TYPE_TO_STRING(RedistTag<T, L, RS>)
 
#define REDIST_ALL_TAGS
 

Functions

int main (int argc, char **argv)
 
 TEST_CASE ("SerializerJSON scalar round-trip")
 
 TEST_CASE ("ArrayPair redistribute — same np round-trip")
 
 TEST_CASE ("ArrayPair redistribute — shuffled partition same np")
 
template<class T >
MakeTestValue (DNDS::index origIdx, DNDS::rowsize col)
 
 REDIST_TAG_STR (DNDS::real, LayoutStaticFixed, 1)
 
 REDIST_TAG_STR (DNDS::real, LayoutStaticFixed, 3)
 
 REDIST_TAG_STR (DNDS::real, LayoutStaticFixed, 7)
 
 REDIST_TAG_STR (DNDS::real, LayoutDynamic, 1)
 
 REDIST_TAG_STR (DNDS::real, LayoutDynamic, 3)
 
 REDIST_TAG_STR (DNDS::real, LayoutDynamic, 7)
 
 REDIST_TAG_STR (DNDS::real, LayoutCSR, 0)
 
 REDIST_TAG_STR (DNDS::index, LayoutStaticFixed, 1)
 
 REDIST_TAG_STR (DNDS::index, LayoutStaticFixed, 3)
 
 REDIST_TAG_STR (DNDS::index, LayoutStaticFixed, 7)
 
 REDIST_TAG_STR (DNDS::index, LayoutDynamic, 1)
 
 REDIST_TAG_STR (DNDS::index, LayoutDynamic, 3)
 
 REDIST_TAG_STR (DNDS::index, LayoutDynamic, 7)
 
 REDIST_TAG_STR (DNDS::index, LayoutCSR, 0)
 
 REDIST_TAG_STR (uint16_t, LayoutStaticFixed, 1)
 
 REDIST_TAG_STR (uint16_t, LayoutStaticFixed, 3)
 
 REDIST_TAG_STR (uint16_t, LayoutStaticFixed, 7)
 
 REDIST_TAG_STR (uint16_t, LayoutDynamic, 1)
 
 REDIST_TAG_STR (uint16_t, LayoutDynamic, 3)
 
 REDIST_TAG_STR (uint16_t, LayoutDynamic, 7)
 
 REDIST_TAG_STR (uint16_t, LayoutCSR, 0)
 
 REDIST_TAG_STR (int32_t, LayoutStaticFixed, 1)
 
 REDIST_TAG_STR (int32_t, LayoutStaticFixed, 3)
 
 REDIST_TAG_STR (int32_t, LayoutStaticFixed, 7)
 
 REDIST_TAG_STR (int32_t, LayoutDynamic, 1)
 
 REDIST_TAG_STR (int32_t, LayoutDynamic, 3)
 
 REDIST_TAG_STR (int32_t, LayoutDynamic, 7)
 
 REDIST_TAG_STR (int32_t, LayoutCSR, 0)
 
 REDIST_TAG_STR (uint8_t, LayoutStaticFixed, 1)
 
 REDIST_TAG_STR (uint8_t, LayoutStaticFixed, 3)
 
 REDIST_TAG_STR (uint8_t, LayoutStaticFixed, 7)
 
 REDIST_TAG_STR (uint8_t, LayoutDynamic, 1)
 
 REDIST_TAG_STR (uint8_t, LayoutDynamic, 3)
 
 REDIST_TAG_STR (uint8_t, LayoutDynamic, 7)
 
 REDIST_TAG_STR (uint8_t, LayoutCSR, 0)
 
 TEST_CASE_TEMPLATE ("redistribute", Tag, REDIST_ALL_TAGS)
 
template<class T , class L , DNDS::rowsize RS>
void TestDifferentNp (int npWrite, DNDS::index baseSize)
 
 TEST_CASE_TEMPLATE ("redistribute different-np", Tag, REDIST_ALL_TAGS)
 
 TEST_CASE ("SerializerJSON vector round-trip")
 
 TEST_CASE ("SerializerJSON uint8 array round-trip")
 
 TEST_CASE ("SerializerJSON path operations")
 
 TEST_CASE ("SerializerJSON shared pointer deduplication")
 
 TEST_CASE ("SerializerH5 scalar round-trip")
 
 TEST_CASE ("SerializerH5 vector round-trip")
 
 TEST_CASE ("SerializerH5 distributed vector")
 
 TEST_CASE ("SerializerH5 uint8 distributed round-trip")
 
 TEST_CASE ("SerializerH5 path operations")
 
 TEST_CASE ("SerializerH5 string round-trip")
 

Detailed Description

Doctest-based unit tests for DNDS Serializer classes.

Covers SerializerJSON (per-rank, no MPI needed for logic) and SerializerH5 (parallel HDF5, requires MPI). The JSON tests verify scalar, vector, uint8 (with/without codec), path operations, and shared-pointer deduplication. The H5 tests verify scalar, vector, distributed vector (non-uniform per-rank sizes), uint8 (two-pass read), path operations, and string round-trips.

Note
H5 parallel I/O requires all MPI ranks to open the same file. The TmpH5() helper broadcasts rank 0's PID so that the filename is identical across all ranks. FileGuard uses shared=true for H5 files so only rank 0 deletes the file, followed by an MPI_Barrier.

Build: cmake --build . -t dnds_test_serializer -j8 Run: mpirun -np 1 ./dnds_test_serializer (JSON + H5 single rank) mpirun -np 4 ./dnds_test_serializer (H5 distributed tests)

See also
DNDS Core Unit Tests for the full test-suite overview.
Test:
SerializerJSON scalar/vector/uint8/path/pointer round-trip, SerializerH5 scalar/vector/distributed/uint8/path/string round-trip.

Definition in file test_Serializer.cpp.

Macro Definition Documentation

◆ DOCTEST_CONFIG_IMPLEMENT

#define DOCTEST_CONFIG_IMPLEMENT

Definition at line 26 of file test_Serializer.cpp.

◆ REDIST_ALL_TAGS

#define REDIST_ALL_TAGS
Value:

Definition at line 329 of file test_Serializer.cpp.

◆ REDIST_TAG_STR

#define REDIST_TAG_STR (   T,
  L,
  RS 
)    TYPE_TO_STRING(RedistTag<T, L, RS>)

Definition at line 291 of file test_Serializer.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 40 of file test_Serializer.cpp.

◆ MakeTestValue()

template<class T >
T MakeTestValue ( DNDS::index  origIdx,
DNDS::rowsize  col 
)

Definition at line 242 of file test_Serializer.cpp.

◆ REDIST_TAG_STR() [1/35]

REDIST_TAG_STR ( DNDS::index  ,
LayoutCSR  ,
 
)

◆ REDIST_TAG_STR() [2/35]

REDIST_TAG_STR ( DNDS::index  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [3/35]

REDIST_TAG_STR ( DNDS::index  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [4/35]

REDIST_TAG_STR ( DNDS::index  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [5/35]

REDIST_TAG_STR ( DNDS::index  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [6/35]

REDIST_TAG_STR ( DNDS::index  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [7/35]

REDIST_TAG_STR ( DNDS::index  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [8/35]

REDIST_TAG_STR ( DNDS::real  ,
LayoutCSR  ,
 
)

◆ REDIST_TAG_STR() [9/35]

REDIST_TAG_STR ( DNDS::real  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [10/35]

REDIST_TAG_STR ( DNDS::real  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [11/35]

REDIST_TAG_STR ( DNDS::real  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [12/35]

REDIST_TAG_STR ( DNDS::real  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [13/35]

REDIST_TAG_STR ( DNDS::real  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [14/35]

REDIST_TAG_STR ( DNDS::real  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [15/35]

REDIST_TAG_STR ( int32_t  ,
LayoutCSR  ,
 
)

◆ REDIST_TAG_STR() [16/35]

REDIST_TAG_STR ( int32_t  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [17/35]

REDIST_TAG_STR ( int32_t  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [18/35]

REDIST_TAG_STR ( int32_t  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [19/35]

REDIST_TAG_STR ( int32_t  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [20/35]

REDIST_TAG_STR ( int32_t  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [21/35]

REDIST_TAG_STR ( int32_t  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [22/35]

REDIST_TAG_STR ( uint16_t  ,
LayoutCSR  ,
 
)

◆ REDIST_TAG_STR() [23/35]

REDIST_TAG_STR ( uint16_t  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [24/35]

REDIST_TAG_STR ( uint16_t  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [25/35]

REDIST_TAG_STR ( uint16_t  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [26/35]

REDIST_TAG_STR ( uint16_t  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [27/35]

REDIST_TAG_STR ( uint16_t  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [28/35]

REDIST_TAG_STR ( uint16_t  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [29/35]

REDIST_TAG_STR ( uint8_t  ,
LayoutCSR  ,
 
)

◆ REDIST_TAG_STR() [30/35]

REDIST_TAG_STR ( uint8_t  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [31/35]

REDIST_TAG_STR ( uint8_t  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [32/35]

REDIST_TAG_STR ( uint8_t  ,
LayoutDynamic  ,
 
)

◆ REDIST_TAG_STR() [33/35]

REDIST_TAG_STR ( uint8_t  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [34/35]

REDIST_TAG_STR ( uint8_t  ,
LayoutStaticFixed  ,
 
)

◆ REDIST_TAG_STR() [35/35]

REDIST_TAG_STR ( uint8_t  ,
LayoutStaticFixed  ,
 
)

◆ TEST_CASE() [1/13]

TEST_CASE ( "ArrayPair redistribute — same np round-trip"  )

Definition at line 125 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [2/13]

TEST_CASE ( "ArrayPair redistribute — shuffled partition same np"  )

Definition at line 174 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [3/13]

TEST_CASE ( "SerializerH5 distributed vector"  )

Definition at line 1034 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [4/13]

TEST_CASE ( "SerializerH5 path operations"  )

Definition at line 1170 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [5/13]

TEST_CASE ( "SerializerH5 scalar round-trip"  )

Definition at line 918 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [6/13]

TEST_CASE ( "SerializerH5 string round-trip"  )

Definition at line 1222 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [7/13]

TEST_CASE ( "SerializerH5 uint8 distributed round-trip"  )

Definition at line 1113 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [8/13]

TEST_CASE ( "SerializerH5 vector round-trip"  )

Definition at line 969 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [9/13]

TEST_CASE ( "SerializerJSON path operations"  )

Definition at line 816 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [10/13]

TEST_CASE ( "SerializerJSON scalar round-trip"  )

Definition at line 101 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [11/13]

TEST_CASE ( "SerializerJSON shared pointer deduplication"  )

Definition at line 862 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [12/13]

TEST_CASE ( "SerializerJSON uint8 array round-trip"  )

Definition at line 731 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [13/13]

TEST_CASE ( "SerializerJSON vector round-trip"  )

Definition at line 672 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TEST_CASE_TEMPLATE() [1/2]

TEST_CASE_TEMPLATE ( "redistribute different-np"  ,
Tag  ,
REDIST_ALL_TAGS   
)

Definition at line 648 of file test_Serializer.cpp.

◆ TEST_CASE_TEMPLATE() [2/2]

TEST_CASE_TEMPLATE ( "redistribute"  ,
Tag  ,
REDIST_ALL_TAGS   
)

Definition at line 346 of file test_Serializer.cpp.

Here is the call graph for this function:

◆ TestDifferentNp()

template<class T , class L , DNDS::rowsize RS>
void TestDifferentNp ( int  npWrite,
DNDS::index  baseSize 
)

Definition at line 495 of file test_Serializer.cpp.

Here is the call graph for this function: