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

Comprehensive doctest-based unit tests for DNDS::ArrayTransformer ghost/halo communication, run under mpirun with 1, 2, and 4 ranks. More...

#include "doctest.h"
#include "DNDS/Array.hpp"
#include "DNDS/ArrayTransformer.hpp"
#include <cstdint>
#include <memory>
#include <vector>
#include <cstdlib>
#include <numeric>
Include dependency graph for test_ArrayTransformer.cpp:

Go to the source code of this file.

Classes

struct  LayoutStaticFixed
 
struct  LayoutDynamic
 
struct  LayoutCSR
 
struct  TransTag< T, Layout, RS >
 

Macros

#define DOCTEST_CONFIG_IMPLEMENT
 
#define TRANS_TAG_STR(T, L, RS)   TYPE_TO_STRING(TransTag<T, L, RS>)
 
#define TRANS_ALL_TAGS
 

Functions

int main (int argc, char **argv)
 
 TEST_CASE ("ParArray basics")
 
 TEST_CASE ("ArrayTransformer pull - TABLE_StaticFixed")
 
father Resize (nLocal, dynCols)
 
father createGlobalMapping ()
 
for(DNDS::index i=0;i< nLocal;i++) for(DNDS j< dynCols;j++)(*father)(i, j)=(gOff+i) *0.1+j *0.001;DNDS::index gSize=father-> globalSize ()
 
std::vector< DNDS::indexpullAll (gSize)
 
trans setFatherSon (father, son)
 
trans createFatherGlobalMapping ()
 
trans createGhostMapping (std::vector< DNDS::index >(pullAll))
 
trans createMPITypes ()
 
trans pullOnce ()
 
 CHECK (son->Size()==gSize)
 
 CHECK ((*son)(g, j)==doctest::Approx(expected))
 
 TEST_CASE ("ArrayTransformer pull - CSR layout")
 
 TEST_CASE ("ArrayTransformer pull - std::array elements")
 
 TEST_CASE ("ArrayTransformer persistent pull")
 
 TEST_CASE ("ArrayTransformer BorrowGGIndexing")
 
 TEST_CASE ("ArrayTransformer push")
 
 TRANS_TAG_STR (DNDS::real, LayoutStaticFixed, 1)
 
 TRANS_TAG_STR (DNDS::real, LayoutStaticFixed, 3)
 
 TRANS_TAG_STR (DNDS::real, LayoutStaticFixed, 7)
 
 TRANS_TAG_STR (DNDS::real, LayoutDynamic, 1)
 
 TRANS_TAG_STR (DNDS::real, LayoutDynamic, 3)
 
 TRANS_TAG_STR (DNDS::real, LayoutDynamic, 7)
 
 TRANS_TAG_STR (DNDS::real, LayoutCSR, 0)
 
 TRANS_TAG_STR (DNDS::index, LayoutStaticFixed, 1)
 
 TRANS_TAG_STR (DNDS::index, LayoutStaticFixed, 3)
 
 TRANS_TAG_STR (DNDS::index, LayoutStaticFixed, 7)
 
 TRANS_TAG_STR (DNDS::index, LayoutDynamic, 1)
 
 TRANS_TAG_STR (DNDS::index, LayoutDynamic, 3)
 
 TRANS_TAG_STR (DNDS::index, LayoutDynamic, 7)
 
 TRANS_TAG_STR (DNDS::index, LayoutCSR, 0)
 
 TRANS_TAG_STR (uint16_t, LayoutStaticFixed, 1)
 
 TRANS_TAG_STR (uint16_t, LayoutStaticFixed, 3)
 
 TRANS_TAG_STR (uint16_t, LayoutStaticFixed, 7)
 
 TRANS_TAG_STR (uint16_t, LayoutDynamic, 1)
 
 TRANS_TAG_STR (uint16_t, LayoutDynamic, 3)
 
 TRANS_TAG_STR (uint16_t, LayoutDynamic, 7)
 
 TRANS_TAG_STR (uint16_t, LayoutCSR, 0)
 
 TRANS_TAG_STR (int32_t, LayoutStaticFixed, 1)
 
 TRANS_TAG_STR (int32_t, LayoutStaticFixed, 3)
 
 TRANS_TAG_STR (int32_t, LayoutStaticFixed, 7)
 
 TRANS_TAG_STR (int32_t, LayoutDynamic, 1)
 
 TRANS_TAG_STR (int32_t, LayoutDynamic, 3)
 
 TRANS_TAG_STR (int32_t, LayoutDynamic, 7)
 
 TRANS_TAG_STR (int32_t, LayoutCSR, 0)
 
 TEST_CASE_TEMPLATE ("ArrayTransformer pull", Tag, TRANS_ALL_TAGS)
 

Variables

constexpr DNDS::index nLocal = 50
 
constexpr DNDS::rowsize dynCols = 5
 
auto father = std::make_shared<ParArray<DNDS::real, DynamicSize>>(mpi)
 
DNDS::index gOff = (*father->pLGlobalMapping)(mpi.rank, 0)
 
auto son = std::make_shared<ParArray<DNDS::real, DynamicSize>>(mpi)
 
ArrayTransformer< DNDS::real, DynamicSize > trans
 
for(DNDS::index g=0;g< son->Size();g++) for(DNDS j< dynCols;j++) { DNDS::index ghostGlobal=trans.pLGhostMapping-> ghostIndex [g]
 
DNDS::real expected = ghostGlobal * 0.1 + j * 0.001
 

Detailed Description

Comprehensive doctest-based unit tests for DNDS::ArrayTransformer ghost/halo communication, run under mpirun with 1, 2, and 4 ranks.

Tests pull-based and push-based ghost exchange for TABLE_StaticFixed, TABLE_Fixed, CSR, and compound element types. Also covers persistent communication and BorrowGGIndexing.

See also
DNDS Core Unit Tests for the full test-suite overview.
Test:
ParArray basics, pull (StaticFixed, Fixed, CSR, std::array), persistent pull, BorrowGGIndexing, push.

Definition in file test_ArrayTransformer.cpp.

Macro Definition Documentation

◆ DOCTEST_CONFIG_IMPLEMENT

#define DOCTEST_CONFIG_IMPLEMENT

Definition at line 15 of file test_ArrayTransformer.cpp.

◆ TRANS_ALL_TAGS

◆ TRANS_TAG_STR

#define TRANS_TAG_STR (   T,
  L,
  RS 
)    TYPE_TO_STRING(TransTag<T, L, RS>)

Definition at line 491 of file test_ArrayTransformer.cpp.

Function Documentation

◆ CHECK() [1/2]

CHECK ( (*)(g, j)  son = =doctest::Approx(expected))

◆ CHECK() [2/2]

CHECK ( son->  Size() = =gSize)
Here is the caller graph for this function:

◆ createFatherGlobalMapping()

trans createFatherGlobalMapping ( )

◆ createGhostMapping()

trans createGhostMapping ( std::vector< DNDS::index pullAll)

◆ createGlobalMapping()

father createGlobalMapping ( )

◆ createMPITypes()

trans createMPITypes ( )

◆ globalSize()

for(DNDS::index i=0;i< nLocal;i++) for(DNDS j< dynCols;j++)(*father)(i, j)=(gOff+i) *0.1+j *0.001; DNDS::index gSize=father-> globalSize ( )
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 27 of file test_ArrayTransformer.cpp.

◆ pullAll()

std::vector< DNDS::index > pullAll ( gSize  )

◆ pullOnce()

trans pullOnce ( )

◆ Resize()

father Resize ( nLocal  ,
dynCols   
)

◆ setFatherSon()

trans setFatherSon ( father  ,
son   
)

◆ TEST_CASE() [1/7]

TEST_CASE ( "ArrayTransformer BorrowGGIndexing"  )

Definition at line 343 of file test_ArrayTransformer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [2/7]

TEST_CASE ( "ArrayTransformer persistent pull"  )

Definition at line 283 of file test_ArrayTransformer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [3/7]

TEST_CASE ( "ArrayTransformer pull - CSR layout"  )

Definition at line 190 of file test_ArrayTransformer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [4/7]

TEST_CASE ( "ArrayTransformer pull - std::array elements"  )

Definition at line 238 of file test_ArrayTransformer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [5/7]

TEST_CASE ( "ArrayTransformer pull - TABLE_StaticFixed"  )

Definition at line 103 of file test_ArrayTransformer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [6/7]

TEST_CASE ( "ArrayTransformer push"  )

Definition at line 395 of file test_ArrayTransformer.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [7/7]

TEST_CASE ( "ParArray basics"  )

Definition at line 68 of file test_ArrayTransformer.cpp.

Here is the call graph for this function:

◆ TEST_CASE_TEMPLATE()

TEST_CASE_TEMPLATE ( "ArrayTransformer pull"  ,
Tag  ,
TRANS_ALL_TAGS   
)

Definition at line 558 of file test_ArrayTransformer.cpp.

Here is the call graph for this function:

◆ TRANS_TAG_STR() [1/28]

TRANS_TAG_STR ( DNDS::index  ,
LayoutCSR  ,
 
)

◆ TRANS_TAG_STR() [2/28]

TRANS_TAG_STR ( DNDS::index  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [3/28]

TRANS_TAG_STR ( DNDS::index  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [4/28]

TRANS_TAG_STR ( DNDS::index  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [5/28]

TRANS_TAG_STR ( DNDS::index  ,
LayoutStaticFixed  ,
 
)

◆ TRANS_TAG_STR() [6/28]

TRANS_TAG_STR ( DNDS::index  ,
LayoutStaticFixed  ,
 
)

◆ TRANS_TAG_STR() [7/28]

TRANS_TAG_STR ( DNDS::index  ,
LayoutStaticFixed  ,
 
)

◆ TRANS_TAG_STR() [8/28]

TRANS_TAG_STR ( DNDS::real  ,
LayoutCSR  ,
 
)

◆ TRANS_TAG_STR() [9/28]

TRANS_TAG_STR ( DNDS::real  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [10/28]

TRANS_TAG_STR ( DNDS::real  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [11/28]

TRANS_TAG_STR ( DNDS::real  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [12/28]

TRANS_TAG_STR ( DNDS::real  ,
LayoutStaticFixed  ,
 
)

◆ TRANS_TAG_STR() [13/28]

TRANS_TAG_STR ( DNDS::real  ,
LayoutStaticFixed  ,
 
)

◆ TRANS_TAG_STR() [14/28]

TRANS_TAG_STR ( DNDS::real  ,
LayoutStaticFixed  ,
 
)

◆ TRANS_TAG_STR() [15/28]

TRANS_TAG_STR ( int32_t  ,
LayoutCSR  ,
 
)

◆ TRANS_TAG_STR() [16/28]

TRANS_TAG_STR ( int32_t  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [17/28]

TRANS_TAG_STR ( int32_t  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [18/28]

TRANS_TAG_STR ( int32_t  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [19/28]

TRANS_TAG_STR ( int32_t  ,
LayoutStaticFixed  ,
 
)

◆ TRANS_TAG_STR() [20/28]

TRANS_TAG_STR ( int32_t  ,
LayoutStaticFixed  ,
 
)

◆ TRANS_TAG_STR() [21/28]

TRANS_TAG_STR ( int32_t  ,
LayoutStaticFixed  ,
 
)

◆ TRANS_TAG_STR() [22/28]

TRANS_TAG_STR ( uint16_t  ,
LayoutCSR  ,
 
)

◆ TRANS_TAG_STR() [23/28]

TRANS_TAG_STR ( uint16_t  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [24/28]

TRANS_TAG_STR ( uint16_t  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [25/28]

TRANS_TAG_STR ( uint16_t  ,
LayoutDynamic  ,
 
)

◆ TRANS_TAG_STR() [26/28]

TRANS_TAG_STR ( uint16_t  ,
LayoutStaticFixed  ,
 
)

◆ TRANS_TAG_STR() [27/28]

TRANS_TAG_STR ( uint16_t  ,
LayoutStaticFixed  ,
 
)

◆ TRANS_TAG_STR() [28/28]

TRANS_TAG_STR ( uint16_t  ,
LayoutStaticFixed  ,
 
)

Variable Documentation

◆ dynCols

constexpr DNDS::rowsize dynCols = 5
constexpr

Definition at line 152 of file test_ArrayTransformer.cpp.

◆ expected

DNDS::real expected = ghostGlobal * 0.1 + j * 0.001

Definition at line 184 of file test_ArrayTransformer.cpp.

◆ father

auto father = std::make_shared<ParArray<DNDS::real, DynamicSize>>(mpi)

Definition at line 154 of file test_ArrayTransformer.cpp.

◆ ghostIndex

for (DNDS::index g = 0; g < son->Size(); g++) for (DNDS j< dynCols; j++) { DNDS::index ghostGlobal = trans.pLGhostMapping-> ghostIndex[g]

Definition at line 183 of file test_ArrayTransformer.cpp.

◆ gOff

DNDS::index gOff = (*father->pLGlobalMapping)(mpi.rank, 0)

Definition at line 158 of file test_ArrayTransformer.cpp.

◆ nLocal

constexpr DNDS::index nLocal = 50
constexpr

Definition at line 151 of file test_ArrayTransformer.cpp.

◆ son

auto son = std::make_shared<ParArray<DNDS::real, DynamicSize>>(mpi)

Definition at line 168 of file test_ArrayTransformer.cpp.

◆ trans

ArrayTransformer<DNDS::real, DynamicSize> trans

Definition at line 169 of file test_ArrayTransformer.cpp.