diff --git a/bindings/C/adios2/c/adios2_c_engine.cpp b/bindings/C/adios2/c/adios2_c_engine.cpp index db3f36347f..2b019d7f5e 100644 --- a/bindings/C/adios2/c/adios2_c_engine.cpp +++ b/bindings/C/adios2/c/adios2_c_engine.cpp @@ -685,31 +685,66 @@ adios2_varinfo *adios2_inquire_blockinfo(adios2_engine *engine, { varinfo = (adios2_varinfo *)malloc(sizeof(adios2_varinfo)); varinfo->nblocks = minBlocksInfo->BlocksInfo.size(); + varinfo->Shape = NULL; varinfo->BlocksInfo = (adios2_blockinfo *)malloc( varinfo->nblocks * sizeof(adios2_blockinfo)); auto *b = varinfo->BlocksInfo; varinfo->Dims = minBlocksInfo->Dims; - varinfo->Shape = minBlocksInfo->Shape; + if (minBlocksInfo->WasLocalVar) + { + varinfo->Shape = (size_t *)malloc(sizeof(size_t)); + varinfo->Shape[0] = (intptr_t)minBlocksInfo->Shape; + } + else + { + if (minBlocksInfo->Shape) + { + varinfo->Shape = + (size_t *)malloc(sizeof(size_t) * minBlocksInfo->Dims); + memcpy(varinfo->Shape, minBlocksInfo->Shape, + sizeof(size_t) * minBlocksInfo->Dims); + } + } varinfo->IsValue = (int)minBlocksInfo->IsValue; varinfo->IsReverseDims = (int)minBlocksInfo->IsReverseDims; for (size_t i = 0; i < varinfo->nblocks; ++i) { b[i].WriterID = minBlocksInfo->BlocksInfo[i].WriterID; b[i].BlockID = minBlocksInfo->BlocksInfo[i].BlockID; - b[i].Start = minBlocksInfo->BlocksInfo[i].Start; - b[i].Count = minBlocksInfo->BlocksInfo[i].Count; + if (minBlocksInfo->WasLocalVar) + { + b[i].Start = (size_t *)malloc(sizeof(size_t)); + b[i].Start[0] = + (intptr_t)minBlocksInfo->BlocksInfo[i].Start; + b[i].Count = (size_t *)malloc(sizeof(size_t)); + b[i].Count[0] = + (intptr_t)minBlocksInfo->BlocksInfo[i].Count; + } + else + { + b[i].Start = + (size_t *)malloc(sizeof(size_t) * minBlocksInfo->Dims); + memcpy(b[i].Start, minBlocksInfo->BlocksInfo[i].Start, + sizeof(size_t) * minBlocksInfo->Dims); + b[i].Count = + (size_t *)malloc(sizeof(size_t) * minBlocksInfo->Dims); + memcpy(b[i].Count, minBlocksInfo->BlocksInfo[i].Count, + sizeof(size_t) * minBlocksInfo->Dims); + } if (minBlocksInfo->IsValue) { - b[i].Value.uint64 = 0; - // = *((T *)minBlocksInfo->BlocksInfo[i].BufferP); + memcpy(&b[i].Value, minBlocksInfo->BlocksInfo[i].BufferP, + sizeof(b[i].Value)); } else { - b[i].MinUnion.uint64 = 0; - // = minBlocksInfo->BlocksInfo[i].MinUnion; - b[i].MaxUnion.uint64 = 0; - // = minBlocksInfo->BlocksInfo[i].MaxUnion; + memcpy(&b[i].MinUnion, + &minBlocksInfo->BlocksInfo[i].MinMax.MinUnion, + sizeof(b[i].MinUnion)); + memcpy(&b[i].MaxUnion, + &minBlocksInfo->BlocksInfo[i].MinMax.MaxUnion, + sizeof(b[i].MaxUnion)); } } delete minBlocksInfo; diff --git a/bindings/CXX11/adios2/cxx11/Engine.cpp b/bindings/CXX11/adios2/cxx11/Engine.cpp index eb69869bed..1bf94fb89d 100644 --- a/bindings/CXX11/adios2/cxx11/Engine.cpp +++ b/bindings/CXX11/adios2/cxx11/Engine.cpp @@ -12,6 +12,7 @@ #include "Engine.tcc" #include "adios2/core/Engine.h" + #include "adios2/helper/adiosFunctions.h" namespace adios2 diff --git a/bindings/CXX11/adios2/cxx11/Engine.h b/bindings/CXX11/adios2/cxx11/Engine.h index 76ded5466f..0da16291b4 100644 --- a/bindings/CXX11/adios2/cxx11/Engine.h +++ b/bindings/CXX11/adios2/cxx11/Engine.h @@ -27,6 +27,7 @@ class Query; // friend namespace core { class Engine; // private implementation + } /// \endcond diff --git a/bindings/CXX11/adios2/cxx11/Engine.tcc b/bindings/CXX11/adios2/cxx11/Engine.tcc index 3a032d94bd..93c6d2e48c 100644 --- a/bindings/CXX11/adios2/cxx11/Engine.tcc +++ b/bindings/CXX11/adios2/cxx11/Engine.tcc @@ -59,56 +59,6 @@ ToBlocksInfo(const std::vector -static std::vector::Info> -ToBlocksInfo(const core::Engine::MinVarInfo *coreVarInfo) -{ - auto coreBlocksInfo = coreVarInfo->BlocksInfo; - - std::vector::Info> blocksInfo; - blocksInfo.reserve(coreBlocksInfo.size()); - - for (auto &coreBlockInfo : coreBlocksInfo) - { - typename Variable::Info blockInfo; - - if (coreVarInfo->Shape) - { - blockInfo.Start.reserve(coreVarInfo->Dims); - blockInfo.Count.reserve(coreVarInfo->Dims); - for (int i = 0; i < coreVarInfo->Dims; i++) - { - blockInfo.Start.push_back(coreBlockInfo.Start[i]); - blockInfo.Count.push_back(coreBlockInfo.Count[i]); - } - } - else - { - blockInfo.Count.reserve(coreVarInfo->Dims); - for (int i = 0; i < coreVarInfo->Dims; i++) - { - blockInfo.Count.push_back(coreBlockInfo.Count[i]); - } - } - blockInfo.WriterID = coreBlockInfo.WriterID; - - blockInfo.IsValue = coreVarInfo->IsValue; - blockInfo.IsReverseDims = coreVarInfo->IsReverseDims; - if (blockInfo.IsValue) - { - blockInfo.Value = *((T *)coreBlockInfo.BufferP); - } - else - { - blockInfo.Min = *(T *)&coreBlockInfo.MinMax.MinUnion; - blockInfo.Max = *(T *)&coreBlockInfo.MinMax.MaxUnion; - } - blockInfo.BlockID = coreBlockInfo.BlockID; - blocksInfo.push_back(blockInfo); - } - - return blocksInfo; -} } // end empty namespace template @@ -358,6 +308,15 @@ Engine::AllStepsBlocksInfo(const Variable variable) const variable.m_Variable, "for variable in call to Engine::AllStepsBlocksInfo"); + try + { + auto Info = variable.AllStepsBlocksInfoMap(); + return Info; + } + catch (...) + { + } + const std::map::BPInfo>> coreAllStepsBlockInfo = m_Engine->AllStepsBlocksInfo(*variable.m_Variable); @@ -403,7 +362,7 @@ Engine::BlocksInfo(const Variable variable, const size_t step) const if (minBlocksInfo) { std::vector::Info> Ret = - ToBlocksInfo(minBlocksInfo); + variable.ToBlocksInfoMin(minBlocksInfo); delete minBlocksInfo; return Ret; } diff --git a/bindings/CXX11/adios2/cxx11/Variable.cpp b/bindings/CXX11/adios2/cxx11/Variable.cpp index 641aacb8da..cbf30b8bd6 100644 --- a/bindings/CXX11/adios2/cxx11/Variable.cpp +++ b/bindings/CXX11/adios2/cxx11/Variable.cpp @@ -235,6 +235,13 @@ namespace adios2 } \ \ template <> \ + std::map::Info>> \ + Variable::AllStepsBlocksInfoMap() const \ + { \ + return DoAllStepsBlocksInfoMap(); \ + } \ + \ + template <> \ const T *Variable::Info::Data() const \ { \ const core::Variable::BPInfo *coreInfo = \ diff --git a/bindings/CXX11/adios2/cxx11/Variable.h b/bindings/CXX11/adios2/cxx11/Variable.h index ac5888ca65..92b606ee08 100644 --- a/bindings/CXX11/adios2/cxx11/Variable.h +++ b/bindings/CXX11/adios2/cxx11/Variable.h @@ -26,6 +26,8 @@ class Group; // friend namespace core { +class VariableBase; + template class Variable; // private implementation @@ -376,6 +378,14 @@ class Variable */ std::vector::Info>> AllStepsBlocksInfo(); + /** + */ + std::map::Info>> + AllStepsBlocksInfoMap() const; + + std::vector::Info> + ToBlocksInfoMin(const MinVarInfo *coreVarInfo) const; + using Span = adios2::detail::Span; private: @@ -383,6 +393,8 @@ class Variable core::Variable *m_Variable = nullptr; std::vector::Info>> DoAllStepsBlocksInfo(); + std::map::Info>> + DoAllStepsBlocksInfoMap() const; }; template diff --git a/bindings/CXX11/adios2/cxx11/Variable.tcc b/bindings/CXX11/adios2/cxx11/Variable.tcc index d36da51743..c269d91c3b 100644 --- a/bindings/CXX11/adios2/cxx11/Variable.tcc +++ b/bindings/CXX11/adios2/cxx11/Variable.tcc @@ -11,8 +11,9 @@ #ifndef ADIOS2_BINDINGS_CXX11_CXX11_VARIABLE_TCC_ #define ADIOS2_BINDINGS_CXX11_CXX11_VARIABLE_TCC_ +#include "Engine.h" #include "Variable.h" - +#include "adios2/core/Engine.h" #include "adios2/helper/adiosFunctions.h" namespace adios2 @@ -61,6 +62,37 @@ ToBlocksInfo(const std::vector +std::map::Info>> +Variable::DoAllStepsBlocksInfoMap() const +{ + MinVarInfo *minBlocksInfo = nullptr; + minBlocksInfo = m_Variable->m_Engine->MinBlocksInfo(*m_Variable, 0); + if (!minBlocksInfo) + throw std::logic_error("no implemented"); + std::map::Info>> + allStepsBlocksInfo; + + size_t gotCount = 1; + size_t curStep = 1; + allStepsBlocksInfo.insert({0, ToBlocksInfoMin(minBlocksInfo)}); + delete (minBlocksInfo); + while (gotCount < m_Variable->m_AvailableStepsCount) + { + minBlocksInfo = + m_Variable->m_Engine->MinBlocksInfo(*m_Variable, curStep); + if (minBlocksInfo) + { + allStepsBlocksInfo.insert( + {curStep, ToBlocksInfoMin(minBlocksInfo)}); + delete (minBlocksInfo); + gotCount++; + } + curStep++; + } + return allStepsBlocksInfo; +} + template std::vector::Info>> Variable::DoAllStepsBlocksInfo() @@ -68,6 +100,37 @@ Variable::DoAllStepsBlocksInfo() helper::CheckForNullptr(m_Variable, "in call to Variable::AllStepsBlocksInfo"); + MinVarInfo *minBlocksInfo = nullptr; + if (m_Variable->m_Engine) + { + minBlocksInfo = m_Variable->m_Engine->MinBlocksInfo( + *m_Variable, m_Variable->m_AvailableStepsStart); + if (minBlocksInfo) + { + std::vector::Info>> + allStepsBlocksInfo; + // PUBLIC OUTPUT + size_t gotCount = 1; + size_t curStep = m_Variable->m_AvailableStepsStart + 1; + allStepsBlocksInfo.push_back(ToBlocksInfoMin(minBlocksInfo)); + delete (minBlocksInfo); + while (gotCount < m_Variable->m_AvailableStepsCount) + { + minBlocksInfo = + m_Variable->m_Engine->MinBlocksInfo(*m_Variable, curStep); + if (minBlocksInfo) + { + allStepsBlocksInfo.push_back( + ToBlocksInfoMin(minBlocksInfo)); + delete (minBlocksInfo); + gotCount++; + } + curStep++; + } + return allStepsBlocksInfo; + } + } + // PRIVATE INPUT const std::vector::BPInfo>> coreAllStepsBlocksInfo = m_Variable->AllStepsBlocksInfo(); @@ -85,6 +148,76 @@ Variable::DoAllStepsBlocksInfo() return allStepsBlocksInfo; } +template +std::vector::Info> +Variable::ToBlocksInfoMin(const MinVarInfo *coreVarInfo) const +{ + auto coreBlocksInfo = coreVarInfo->BlocksInfo; + size_t Step = coreVarInfo->Step; + + std::vector::Info> blocksInfo; + blocksInfo.reserve(coreBlocksInfo.size()); + + for (auto &coreBlockInfo : coreBlocksInfo) + { + typename Variable::Info blockInfo; + + blockInfo.Step = Step; + if (coreVarInfo->Shape) + { + blockInfo.Start.reserve(coreVarInfo->Dims); + blockInfo.Count.reserve(coreVarInfo->Dims); + if (coreVarInfo->WasLocalVar) + { + /* Start and count are really values, not pointers */ + blockInfo.Start.push_back((size_t)coreBlockInfo.Start); + blockInfo.Count.push_back((size_t)coreBlockInfo.Count); + } + else + { + for (int i = 0; i < coreVarInfo->Dims; i++) + { + blockInfo.Start.push_back(coreBlockInfo.Start[i]); + blockInfo.Count.push_back(coreBlockInfo.Count[i]); + } + } + } + else + { + blockInfo.Count.reserve(coreVarInfo->Dims); + for (int i = 0; i < coreVarInfo->Dims; i++) + { + blockInfo.Count.push_back(coreBlockInfo.Count[i]); + } + } + blockInfo.WriterID = coreBlockInfo.WriterID; + + blockInfo.IsValue = coreVarInfo->IsValue; + blockInfo.IsReverseDims = coreVarInfo->IsReverseDims; + if (blockInfo.IsValue) + { + if (std::is_same::value) + { + std::string *Tmp = (std::string *)&blockInfo.Value; + Tmp->assign(*(const char **)coreBlockInfo.BufferP); + } + else + { + blockInfo.Value = *((T *)coreBlockInfo.BufferP); + } + } + else + { + blockInfo.Min = *(T *)&coreBlockInfo.MinMax.MinUnion; + blockInfo.Max = *(T *)&coreBlockInfo.MinMax.MaxUnion; + } + blockInfo.BlockID = coreBlockInfo.BlockID; + blocksInfo.push_back(blockInfo); + } + + return blocksInfo; +} + template std::string ToString(const Variable &variable) { diff --git a/source/adios2/common/ADIOSTypes.cpp b/source/adios2/common/ADIOSTypes.cpp index 9720359aa2..9fa4c6e9a7 100644 --- a/source/adios2/common/ADIOSTypes.cpp +++ b/source/adios2/common/ADIOSTypes.cpp @@ -10,6 +10,10 @@ */ #include "ADIOSTypes.h" +#include "float.h" +#include "iostream" +#include "limits.h" +#include namespace adios2 { @@ -245,4 +249,122 @@ std::string ToString(const Box &box) return s; } +void MinMaxStruct::Init(DataType Type) +{ + std::memset(this, 0, sizeof(struct MinMaxStruct)); + switch (Type) + { + case DataType::None: + break; + case DataType::Int8: + MinUnion.field_int8 = INT8_MAX; + MaxUnion.field_int8 = INT8_MIN; + break; + case DataType::Int16: + MinUnion.field_int16 = INT16_MAX; + MaxUnion.field_int16 = INT16_MIN; + break; + case DataType::Int32: + MinUnion.field_int32 = INT32_MAX; + MaxUnion.field_int32 = INT32_MIN; + break; + case DataType::Int64: + MinUnion.field_int64 = INT64_MAX; + MaxUnion.field_int64 = INT64_MIN; + break; + case DataType::Char: + case DataType::UInt8: + MinUnion.field_uint8 = UINT8_MAX; + MaxUnion.field_uint8 = 0; + break; + case DataType::UInt16: + MinUnion.field_uint16 = UINT16_MAX; + MaxUnion.field_uint16 = 0; + break; + case DataType::UInt32: + MinUnion.field_uint32 = UINT32_MAX; + MaxUnion.field_uint32 = 0; + break; + case DataType::UInt64: + MinUnion.field_uint64 = UINT64_MAX; + MaxUnion.field_uint64 = 0; + break; + case DataType::Float: + MinUnion.field_float = FLT_MAX; + MaxUnion.field_float = -FLT_MAX; + break; + case DataType::Double: + MinUnion.field_double = DBL_MAX; + MaxUnion.field_double = -DBL_MAX; + break; + case DataType::LongDouble: + MinUnion.field_ldouble = LDBL_MAX; + MaxUnion.field_ldouble = -LDBL_MAX; + break; + case DataType::FloatComplex: + case DataType::DoubleComplex: + case DataType::String: + case DataType::Compound: + break; + } +} + +void MinMaxStruct::Dump(DataType Type) +{ + switch (Type) + { + case DataType::None: + break; + case DataType::Int8: + std::cout << "Min : " << MinUnion.field_int8 + << ", Max : " << MaxUnion.field_int8; + break; + case DataType::Int16: + std::cout << "Min : " << MinUnion.field_int16 + << ", Max : " << MaxUnion.field_int16; + break; + case DataType::Int32: + std::cout << "Min : " << MinUnion.field_int32 + << ", Max : " << MaxUnion.field_int32; + break; + case DataType::Int64: + std::cout << "Min : " << MinUnion.field_int64 + << ", Max : " << MaxUnion.field_int64; + break; + case DataType::Char: + case DataType::UInt8: + std::cout << "Min : " << MinUnion.field_uint8 + << ", Max : " << MaxUnion.field_uint8; + break; + case DataType::UInt16: + std::cout << "Min : " << MinUnion.field_uint16 + << ", Max : " << MaxUnion.field_uint16; + break; + case DataType::UInt32: + std::cout << "Min : " << MinUnion.field_uint32 + << ", Max : " << MaxUnion.field_uint32; + break; + case DataType::UInt64: + std::cout << "Min : " << MinUnion.field_uint64 + << ", Max : " << MaxUnion.field_uint64; + break; + case DataType::Float: + std::cout << "Min : " << MinUnion.field_float + << ", Max : " << MaxUnion.field_float; + break; + case DataType::Double: + std::cout << "Min : " << MinUnion.field_double + << ", Max : " << MaxUnion.field_double; + break; + case DataType::LongDouble: + std::cout << "Min : " << MinUnion.field_ldouble + << ", Max : " << MaxUnion.field_ldouble; + break; + case DataType::FloatComplex: + case DataType::DoubleComplex: + case DataType::String: + case DataType::Compound: + break; + } +} } // end namespace adios2 diff --git a/source/adios2/common/ADIOSTypes.h b/source/adios2/common/ADIOSTypes.h index 69d7dddc98..02705bfac3 100644 --- a/source/adios2/common/ADIOSTypes.h +++ b/source/adios2/common/ADIOSTypes.h @@ -181,6 +181,52 @@ constexpr size_t MaxSizeT = std::numeric_limits::max(); constexpr size_t DefaultSizeT = std::numeric_limits::max(); constexpr size_t EngineCurrentStep = std::numeric_limits::max(); +union PrimitiveStdtypeUnion +{ + int8_t field_int8; + uint8_t field_uint8; + int16_t field_int16; + uint16_t field_uint16; + int32_t field_int32; + uint32_t field_uint32; + int64_t field_int64; + uint64_t field_uint64; + float field_float; + double field_double; + long double field_ldouble; +}; + +struct MinMaxStruct +{ + union PrimitiveStdtypeUnion MinUnion; + union PrimitiveStdtypeUnion MaxUnion; + void Init(DataType Type); + void Dump(DataType Type); +}; +struct MinBlockInfo +{ + int WriterID = 0; + size_t BlockID = 0; + size_t *Start; + size_t *Count; + MinMaxStruct MinMax; + void *BufferP = NULL; +}; +struct MinVarInfo +{ + size_t Step; + bool WasLocalVar; + int Dims; + size_t *Shape; + bool IsValue = false; + bool IsReverseDims = false; + std::vector BlocksInfo; + MinVarInfo(int D, size_t *S) + : Dims(D), Shape(S), IsValue(false), IsReverseDims(false), BlocksInfo({}) + { + } +}; + // adios defaults #ifdef _WIN32 const std::string DefaultFileLibrary("fstream"); diff --git a/source/adios2/core/Engine.h b/source/adios2/core/Engine.h index d9b2d2ec23..28c5e30fb8 100644 --- a/source/adios2/core/Engine.h +++ b/source/adios2/core/Engine.h @@ -452,158 +452,6 @@ class Engine /* for adios2 internal testing */ virtual size_t DebugGetDataBufferSize() const; - union PrimitiveStdtypeUnion - { -#define declare_field(T, N) T field_##N; - ADIOS2_FOREACH_MINMAX_STDTYPE_2ARGS(declare_field) -#undef declare_field - }; - - struct MinMaxStruct - { - union PrimitiveStdtypeUnion MinUnion; - union PrimitiveStdtypeUnion MaxUnion; - void Init(DataType Type) - { - memset(this, 0, sizeof(struct MinMaxStruct)); - switch (Type) - { - case DataType::None: - break; - case DataType::Int8: - MinUnion.field_int8 = INT8_MAX; - MaxUnion.field_int8 = INT8_MIN; - break; - case DataType::Int16: - MinUnion.field_int16 = INT16_MAX; - MaxUnion.field_int16 = INT16_MIN; - break; - case DataType::Int32: - MinUnion.field_int32 = INT32_MAX; - MaxUnion.field_int32 = INT32_MIN; - break; - case DataType::Int64: - MinUnion.field_int64 = INT64_MAX; - MaxUnion.field_int64 = INT64_MIN; - break; - case DataType::Char: - case DataType::UInt8: - MinUnion.field_uint8 = UINT8_MAX; - MaxUnion.field_uint8 = 0; - break; - case DataType::UInt16: - MinUnion.field_uint16 = UINT16_MAX; - MaxUnion.field_uint16 = 0; - break; - case DataType::UInt32: - MinUnion.field_uint32 = UINT32_MAX; - MaxUnion.field_uint32 = 0; - break; - case DataType::UInt64: - MinUnion.field_uint64 = UINT64_MAX; - MaxUnion.field_uint64 = 0; - break; - case DataType::Float: - MinUnion.field_float = FLT_MAX; - MaxUnion.field_float = -FLT_MAX; - break; - case DataType::Double: - MinUnion.field_double = DBL_MAX; - MaxUnion.field_double = -DBL_MAX; - break; - case DataType::LongDouble: - MinUnion.field_ldouble = LDBL_MAX; - MaxUnion.field_ldouble = -LDBL_MAX; - break; - case DataType::FloatComplex: - case DataType::DoubleComplex: - case DataType::String: - case DataType::Compound: - break; - } - } - void Dump(DataType Type) - { - switch (Type) - { - case DataType::None: - break; - case DataType::Int8: - std::cout << "Min : " << MinUnion.field_int8 - << ", Max : " << MaxUnion.field_int8; - break; - case DataType::Int16: - std::cout << "Min : " << MinUnion.field_int16 - << ", Max : " << MaxUnion.field_int16; - break; - case DataType::Int32: - std::cout << "Min : " << MinUnion.field_int32 - << ", Max : " << MaxUnion.field_int32; - break; - case DataType::Int64: - std::cout << "Min : " << MinUnion.field_int64 - << ", Max : " << MaxUnion.field_int64; - break; - case DataType::Char: - case DataType::UInt8: - std::cout << "Min : " << MinUnion.field_uint8 - << ", Max : " << MaxUnion.field_uint8; - break; - case DataType::UInt16: - std::cout << "Min : " << MinUnion.field_uint16 - << ", Max : " << MaxUnion.field_uint16; - break; - case DataType::UInt32: - std::cout << "Min : " << MinUnion.field_uint32 - << ", Max : " << MaxUnion.field_uint32; - break; - case DataType::UInt64: - std::cout << "Min : " << MinUnion.field_uint64 - << ", Max : " << MaxUnion.field_uint64; - break; - case DataType::Float: - std::cout << "Min : " << MinUnion.field_float - << ", Max : " << MaxUnion.field_float; - break; - case DataType::Double: - std::cout << "Min : " << MinUnion.field_double - << ", Max : " << MaxUnion.field_double; - break; - case DataType::LongDouble: - std::cout << "Min : " << MinUnion.field_ldouble - << ", Max : " << MaxUnion.field_ldouble; - break; - case DataType::FloatComplex: - case DataType::DoubleComplex: - case DataType::String: - case DataType::Compound: - break; - } - } - }; - struct MinBlockInfo - { - int WriterID = 0; - size_t BlockID = 0; - size_t *Start; - size_t *Count; - MinMaxStruct MinMax; - void *BufferP = NULL; - }; - struct MinVarInfo - { - int Dims; - size_t *Shape; - bool IsValue = false; - bool IsReverseDims = false; - std::vector BlocksInfo; - MinVarInfo(int D, size_t *S) - : Dims(D), Shape(S), IsValue(false), IsReverseDims(false), - BlocksInfo({}) - { - } - }; - // in this call, Step is RELATIVE, not absolute virtual MinVarInfo *MinBlocksInfo(const VariableBase &, const size_t Step) const diff --git a/source/adios2/core/Variable.tcc b/source/adios2/core/Variable.tcc index 33660e0d6b..8e65474ecf 100644 --- a/source/adios2/core/Variable.tcc +++ b/source/adios2/core/Variable.tcc @@ -128,7 +128,7 @@ std::pair Variable::DoMinMax(const size_t step) const if (m_Engine != nullptr) { - Engine::MinMaxStruct MM; + MinMaxStruct MM; if (m_Engine->VariableMinMax(*this, step, MM)) { minMax.first = *(T *)&MM.MinUnion; diff --git a/source/adios2/core/VariableBase.h b/source/adios2/core/VariableBase.h index 90984e1a0f..36090231e8 100644 --- a/source/adios2/core/VariableBase.h +++ b/source/adios2/core/VariableBase.h @@ -13,6 +13,9 @@ #define ADIOS2_CORE_VARIABLEBASE_H_ /// \cond EXCLUDE_FROM_DOXYGEN +#include +#include +#include #include #include #include diff --git a/source/adios2/engine/bp5/BP5Reader.cpp b/source/adios2/engine/bp5/BP5Reader.cpp index a22e73a2ed..39774fc923 100644 --- a/source/adios2/engine/bp5/BP5Reader.cpp +++ b/source/adios2/engine/bp5/BP5Reader.cpp @@ -426,14 +426,14 @@ void BP5Reader::OpenFiles(TimePoint &timeoutInstant, const Seconds &pollSeconds, */ } -Engine::MinVarInfo *BP5Reader::MinBlocksInfo(const VariableBase &Var, - const size_t Step) const +MinVarInfo *BP5Reader::MinBlocksInfo(const VariableBase &Var, + const size_t Step) const { return m_BP5Deserializer->MinBlocksInfo(Var, Step); } bool BP5Reader::VariableMinMax(const VariableBase &Var, const size_t Step, - Engine::MinMaxStruct &MinMax) + MinMaxStruct &MinMax) { return m_BP5Deserializer->VariableMinMax(Var, Step, MinMax); } diff --git a/source/adios2/engine/bp5/BP5Writer.cpp b/source/adios2/engine/bp5/BP5Writer.cpp index 726adc1b82..3c93ce95ab 100644 --- a/source/adios2/engine/bp5/BP5Writer.cpp +++ b/source/adios2/engine/bp5/BP5Writer.cpp @@ -377,18 +377,22 @@ void BP5Writer::WriteMetadataFileIndex(uint64_t MetaDataPos, FlushPosSizeInfo.clear(); } +void BP5Writer::NotifyEngineAttribute(std::string name, DataType type) noexcept +{ + m_MarshalAttributesNecessary = true; +} + void BP5Writer::MarshalAttributes() { PERFSTUBS_SCOPED_TIMER_FUNC(); const auto &attributes = m_IO.GetAttributes(); - const uint32_t attributesCount = static_cast(attributes.size()); - // if there are no new attributes, nothing to do - if (attributesCount == m_MarshaledAttributesCount) + if (!m_MarshalAttributesNecessary) { return; } + m_MarshalAttributesNecessary = false; for (const auto &attributePair : attributes) { @@ -448,7 +452,6 @@ void BP5Writer::MarshalAttributes() ADIOS2_FOREACH_PRIMITIVE_STDTYPE_1ARG(declare_type) #undef declare_type } - m_MarshaledAttributesCount = attributesCount; } void BP5Writer::EndStep() @@ -1249,11 +1252,6 @@ void BP5Writer::InitBPBuffer() } } -void BP5Writer::NotifyEngineAttribute(std::string name, DataType type) noexcept -{ - m_MarshaledAttributesCount = 0; -} - void BP5Writer::EnterComputationBlock() noexcept { if (m_Parameters.AsyncWrite && !m_BetweenStepPairs) diff --git a/source/adios2/engine/bp5/BP5Writer.h b/source/adios2/engine/bp5/BP5Writer.h index d452de2c3b..17a60f361d 100644 --- a/source/adios2/engine/bp5/BP5Writer.h +++ b/source/adios2/engine/bp5/BP5Writer.h @@ -111,6 +111,9 @@ class BP5Writer : public BP5Engine, public core::Engine /** Allocates memory and starts a PG group */ void InitBPBuffer(); void NotifyEngineAttribute(std::string name, DataType type) noexcept; + /** Notify the engine when a new attribute is defined or modified. Called + * from IO.tcc + */ void EnterComputationBlock() noexcept; /** Inform about computation block through User->ADIOS->IO */ @@ -227,8 +230,7 @@ class BP5Writer : public BP5Engine, public core::Engine */ std::vector m_WriterDataPos; - uint32_t m_MarshaledAttributesCount = - 0; // updated during EndStep/MarshalAttributes + bool m_MarshalAttributesNecessary = true; // where each writer rank writes its data, init in InitBPBuffer; std::vector m_Assignment; diff --git a/source/adios2/engine/sst/SstReader.cpp b/source/adios2/engine/sst/SstReader.cpp index 932dfb90af..bbf0c4f14b 100644 --- a/source/adios2/engine/sst/SstReader.cpp +++ b/source/adios2/engine/sst/SstReader.cpp @@ -179,7 +179,7 @@ SstReader::SstReader(IO &io, const std::string &name, const Mode mode, class SstReader::SstReader *Reader = reinterpret_cast(reader); size_t currentStep = SstCurrentStep(Reader->m_Input); - struct MinBlockInfo BI; + /* * setup shape of array variable as global (I.E. Count == Shape, * Start == 0) @@ -234,8 +234,8 @@ SstReader::SstReader(IO &io, const std::string &name, const Mode mode, auto arrayMinBlocksInfoCallback = [](void *reader, void *MV, const int type, int WriterRank, int DimCount, size_t *Shape, size_t *Start, size_t *Count) { - struct MinBlockInfo MBI; - struct MinVarInfo *MinVar = (struct MinVarInfo *)MV; + MinBlockInfo MBI; + MinVarInfo *MinVar = (MinVarInfo *)MV; MBI.WriterID = WriterRank; MBI.BlockID = 0; @@ -740,8 +740,8 @@ void SstReader::PerformGets() void SstReader::DoClose(const int transportIndex) { SstReaderClose(m_Input); } -Engine::MinVarInfo *SstReader::MinBlocksInfo(const VariableBase &Var, - const size_t Step) const +MinVarInfo *SstReader::MinBlocksInfo(const VariableBase &Var, + const size_t Step) const { if (m_WriterMarshalMethod == SstMarshalBP) { @@ -749,12 +749,11 @@ Engine::MinVarInfo *SstReader::MinBlocksInfo(const VariableBase &Var, } else if (m_WriterMarshalMethod == SstMarshalFFS) { - return (Engine::MinVarInfo *)SstFFSGetBlocksInfo(m_Input, (void *)&Var); + return (MinVarInfo *)SstFFSGetBlocksInfo(m_Input, (void *)&Var); } else if (m_WriterMarshalMethod == SstMarshalBP5) { - return (Engine::MinVarInfo *)m_BP5Deserializer->MinBlocksInfo(Var, - Step); + return (MinVarInfo *)m_BP5Deserializer->MinBlocksInfo(Var, Step); } throw std::invalid_argument( "ERROR: Unknown marshal mechanism in MinBlocksInfo\n"); diff --git a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp index 9f2d9f193f..888ecf24da 100644 --- a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp +++ b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp @@ -43,7 +43,7 @@ namespace adios2 { namespace format { -static void ApplyElementMinMax(Engine::MinMaxStruct &MinMax, DataType Type, +static void ApplyElementMinMax(MinMaxStruct &MinMax, DataType Type, void *Element); void BP5Deserializer::InstallMetaMetaData(MetaMetaInfoBlock &MM) @@ -646,7 +646,7 @@ void BP5Deserializer::InstallMetaData(void *MetadataBlock, size_t BlockLen, } if (VarRec->MinMaxOffset != SIZE_MAX) { - core::Engine::MinMaxStruct MinMax; + MinMaxStruct MinMax; MinMax.Init(VarRec->Type); for (size_t B = 0; B < BlockCount; B++) { @@ -946,7 +946,6 @@ bool BP5Deserializer::QueueGetSingle(core::VariableBase &variable, if (VarRec->OrigShapeID == ShapeID::LocalValue) { // Shows up as global array with one element per writer rank - DestData = (char *)DestData + variable.m_Start[0] * VarRec->ElementSize; for (size_t WriterRank = variable.m_Start[0]; WriterRank < variable.m_Count[0] + variable.m_Start[0]; WriterRank++) @@ -982,10 +981,10 @@ bool BP5Deserializer::QueueGetSingle(core::VariableBase &variable, Req.VarRec = VarByKey[&variable]; Req.RequestType = Local; Req.BlockID = variable.m_BlockID; - Req.Count = variable.m_Count; if (variable.m_SelectionType == adios2::SelectionType::BoundingBox) { Req.Start = variable.m_Start; + Req.Count = variable.m_Count; } Req.Data = DestData; Req.Step = Step; @@ -993,6 +992,8 @@ bool BP5Deserializer::QueueGetSingle(core::VariableBase &variable, } else { + std::cout << "Missed get type " << variable.m_SelectionType << " shape " + << variable.m_ShapeID << std::endl; } return true; } @@ -1154,7 +1155,7 @@ void BP5Deserializer::FinalizeGets(std::vector Requests) std::vector ZeroRankOffset(DimCount); std::vector ZeroGlobalDimensions(DimCount); const size_t *SelOffset = NULL; - const size_t *SelSize = Req.Count.data(); + const size_t *SelSize = NULL; int ReqIndex = 0; while (Requests[ReqIndex].WriterRank != static_cast(WriterRank) || @@ -1191,6 +1192,10 @@ void BP5Deserializer::FinalizeGets(std::vector Requests) { SelOffset = Req.Start.data(); } + if (Req.Count.size()) + { + SelSize = Req.Count.data(); + } if (Req.RequestType == Local) { int LocalBlockID = Req.BlockID - NodeFirst; @@ -1200,6 +1205,10 @@ void BP5Deserializer::FinalizeGets(std::vector Requests) RankOffset = ZeroRankOffset.data(); GlobalDimensions = ZeroGlobalDimensions.data(); + if (SelSize == NULL) + { + SelSize = RankSize; + } if (SelOffset == NULL) { SelOffset = ZeroSel.data(); @@ -1587,41 +1596,57 @@ void *BP5Deserializer::GetMetadataBase(BP5VarRec *VarRec, size_t Step, return writer_meta_base; } -Engine::MinVarInfo *BP5Deserializer::MinBlocksInfo(const VariableBase &Var, - size_t Step) +MinVarInfo *BP5Deserializer::MinBlocksInfo(const VariableBase &Var, size_t Step) { BP5VarRec *VarRec = LookupVarByKey((void *)&Var); - Engine::MinVarInfo *MV = - new Engine::MinVarInfo(VarRec->DimCount, VarRec->GlobalDims); + MinVarInfo *MV = new MinVarInfo(VarRec->DimCount, VarRec->GlobalDims); const size_t writerCohortSize = WriterCohortSize(Step); + size_t Id = 0; + MV->Step = Step; MV->Dims = VarRec->DimCount; MV->Shape = VarRec->GlobalDims; MV->IsReverseDims = ((MV->Dims > 1) && (m_WriterIsRowMajor != m_ReaderIsRowMajor)); + MV->WasLocalVar = (VarRec->OrigShapeID == ShapeID::LocalValue); if ((VarRec->OrigShapeID == ShapeID::LocalValue) || (VarRec->OrigShapeID == ShapeID::GlobalValue)) { - MV->IsValue = true; + if (VarRec->OrigShapeID == ShapeID::LocalValue) + { + // appear as an array locally + MV->IsValue = false; + MV->Dims = 1; + MV->Shape = (size_t *)writerCohortSize; + } + else + { + MV->IsValue = true; + } MV->BlocksInfo.reserve(writerCohortSize); + for (size_t WriterRank = 0; WriterRank < writerCohortSize; WriterRank++) { MetaArrayRec *writer_meta_base = (MetaArrayRec *)GetMetadataBase(VarRec, Step, WriterRank); if (writer_meta_base) { - Engine::MinBlockInfo Blk; + MinBlockInfo Blk; Blk.WriterID = WriterRank; - Blk.BlockID = 0; + Blk.BlockID = Id++; Blk.BufferP = writer_meta_base; + if (VarRec->OrigShapeID == ShapeID::LocalValue) + { + Blk.Count = (size_t *)1; + Blk.Start = (size_t *)WriterRank; + } MV->BlocksInfo.push_back(Blk); } } return MV; } - size_t Id = 0; for (size_t WriterRank = 0; WriterRank < writerCohortSize; WriterRank++) { MetaArrayRec *writer_meta_base = @@ -1647,11 +1672,11 @@ Engine::MinVarInfo *BP5Deserializer::MinBlocksInfo(const VariableBase &Var, continue; size_t WriterBlockCount = MV->Dims ? writer_meta_base->DBCount / MV->Dims : 1; - core::Engine::MinMaxStruct *MMs = NULL; + MinMaxStruct *MMs = NULL; if (VarRec->MinMaxOffset != SIZE_MAX) { - MMs = *(core::Engine::MinMaxStruct **)(((char *)writer_meta_base) + - VarRec->MinMaxOffset); + MMs = *(MinMaxStruct **)(((char *)writer_meta_base) + + VarRec->MinMaxOffset); } for (size_t i = 0; i < WriterBlockCount; i++) { @@ -1661,7 +1686,7 @@ Engine::MinVarInfo *BP5Deserializer::MinBlocksInfo(const VariableBase &Var, Offsets = writer_meta_base->Offsets + (i * MV->Dims); if (writer_meta_base->Count) Count = writer_meta_base->Count + (i * MV->Dims); - Engine::MinBlockInfo Blk; + MinBlockInfo Blk; Blk.WriterID = WriterRank; Blk.BlockID = Id++; Blk.Start = Offsets; @@ -1686,7 +1711,7 @@ Engine::MinVarInfo *BP5Deserializer::MinBlocksInfo(const VariableBase &Var, return MV; } -static void ApplyElementMinMax(Engine::MinMaxStruct &MinMax, DataType Type, +static void ApplyElementMinMax(MinMaxStruct &MinMax, DataType Type, void *Element) { switch (Type) @@ -1804,7 +1829,7 @@ size_t BP5Deserializer::RelativeToAbsoluteStep(const BP5VarRec *VarRec, } bool BP5Deserializer::VariableMinMax(const VariableBase &Var, const size_t Step, - Engine::MinMaxStruct &MinMax) + MinMaxStruct &MinMax) { BP5VarRec *VarRec = LookupVarByKey((void *)&Var); if ((VarRec->OrigShapeID == ShapeID::LocalArray) || diff --git a/source/adios2/toolkit/format/bp5/BP5Deserializer.h b/source/adios2/toolkit/format/bp5/BP5Deserializer.h index bdfb53a565..9697821e75 100644 --- a/source/adios2/toolkit/format/bp5/BP5Deserializer.h +++ b/source/adios2/toolkit/format/bp5/BP5Deserializer.h @@ -61,12 +61,11 @@ class BP5Deserializer : virtual public BP5Base std::vector GenerateReadRequests(); void FinalizeGets(std::vector); - Engine::MinVarInfo *AllRelativeStepsMinBlocksInfo(const VariableBase &var); - Engine::MinVarInfo *AllStepsMinBlocksInfo(const VariableBase &var); - Engine::MinVarInfo *MinBlocksInfo(const VariableBase &Var, - const size_t Step); + MinVarInfo *AllRelativeStepsMinBlocksInfo(const VariableBase &var); + MinVarInfo *AllStepsMinBlocksInfo(const VariableBase &var); + MinVarInfo *MinBlocksInfo(const VariableBase &Var, const size_t Step); bool VariableMinMax(const VariableBase &var, const size_t Step, - Engine::MinMaxStruct &MinMax); + MinMaxStruct &MinMax); const bool m_WriterIsRowMajor; const bool m_ReaderIsRowMajor; diff --git a/source/adios2/toolkit/format/bp5/BP5Serializer.cpp b/source/adios2/toolkit/format/bp5/BP5Serializer.cpp index 0902be3bf8..04176317c6 100644 --- a/source/adios2/toolkit/format/bp5/BP5Serializer.cpp +++ b/source/adios2/toolkit/format/bp5/BP5Serializer.cpp @@ -570,7 +570,7 @@ void BP5Serializer::DumpDeferredBlocks(bool forceCopyDeferred) } static void GetMinMax(const void *Data, size_t ElemCount, const DataType Type, - core::Engine::MinMaxStruct &MinMax, MemorySpace MemSpace) + MinMaxStruct &MinMax, MemorySpace MemSpace) { MinMax.Init(Type); if (ElemCount == 0) @@ -677,7 +677,7 @@ void BP5Serializer::Marshal(void *Variable, const char *Name, "BP5Serializer:: Marshall without Prior Init"); } - core::Engine::MinMaxStruct MinMax; + MinMaxStruct MinMax; MinMax.Init(Type); if ((m_StatsLevel > 0) && !Span) { diff --git a/source/utils/bpls/bpls.cpp b/source/utils/bpls/bpls.cpp index 94f53d8d9f..5eb0299444 100644 --- a/source/utils/bpls/bpls.cpp +++ b/source/utils/bpls/bpls.cpp @@ -1090,7 +1090,7 @@ int printVariableInfo(core::Engine *fp, core::IO *io, { if (timestep == false) { - core::Engine::MinMaxStruct MinMax; + MinMaxStruct MinMax; if (fp->VariableMinMax(*variable, DefaultSizeT, MinMax)) { fprintf(outf, " = "); diff --git a/testing/adios2/engine/bp/CMakeLists.txt b/testing/adios2/engine/bp/CMakeLists.txt index cde7507145..0e1720c98e 100644 --- a/testing/adios2/engine/bp/CMakeLists.txt +++ b/testing/adios2/engine/bp/CMakeLists.txt @@ -84,8 +84,8 @@ bp3_bp4_gtest_add_tests_helper(WriteReadAsStreamADIOS2_Threads MPI_ALLOW) bp_gtest_add_tests_helper(WriteReadAttributes MPI_ALLOW) bp3_bp4_gtest_add_tests_helper(FStreamWriteReadHighLevelAPI MPI_ALLOW) bp3_bp4_gtest_add_tests_helper(WriteFlushRead MPI_ALLOW) -bp3_bp4_gtest_add_tests_helper(WriteMultiblockRead MPI_ALLOW) -bp3_bp4_gtest_add_tests_helper(WriteReadMultiblock MPI_ALLOW) +bp_gtest_add_tests_helper(WriteMultiblockRead MPI_ALLOW) +bp_gtest_add_tests_helper(WriteReadMultiblock MPI_ALLOW) bp_gtest_add_tests_helper(WriteReadVector MPI_ALLOW) bp_gtest_add_tests_helper(WriteReadAttributesMultirank MPI_ALLOW) bp_gtest_add_tests_helper(LargeMetadata MPI_ALLOW) @@ -101,7 +101,7 @@ bp_gtest_add_tests_helper(WriteReadLocalVariables MPI_ALLOW) bp_gtest_add_tests_helper(WriteReadLocalVariablesSel MPI_ALLOW) bp3_bp4_gtest_add_tests_helper(WriteReadLocalVariablesSelHighLevel MPI_ALLOW) bp_gtest_add_tests_helper(ChangingShape MPI_ALLOW) -bp3_bp4_gtest_add_tests_helper(WriteReadBlockInfo MPI_ALLOW) +bp_gtest_add_tests_helper(WriteReadBlockInfo MPI_ALLOW) bp_gtest_add_tests_helper(WriteReadVariableSpan MPI_ALLOW) bp3_bp4_gtest_add_tests_helper(TimeAggregation MPI_ALLOW) bp_gtest_add_tests_helper(NoXMLRecovery MPI_ALLOW) diff --git a/testing/adios2/engine/bp/TestBPWriteMultiblockRead.cpp b/testing/adios2/engine/bp/TestBPWriteMultiblockRead.cpp index ed11883911..867bde2f7b 100644 --- a/testing/adios2/engine/bp/TestBPWriteMultiblockRead.cpp +++ b/testing/adios2/engine/bp/TestBPWriteMultiblockRead.cpp @@ -208,7 +208,8 @@ TEST_F(BPWriteMultiblockReadTest, ADIOS2BPWriteMultiblockRead1D8) io.SetEngine(engineName); } - adios2::Engine bpReader = io.Open(fname, adios2::Mode::Read); + adios2::Engine bpReader = + io.Open(fname, adios2::Mode::ReadRandomAccess); auto var_iString = io.InquireVariable("iString"); EXPECT_TRUE(var_iString); @@ -551,7 +552,8 @@ TEST_F(BPWriteMultiblockReadTest, ADIOS2BPWriteMultiblockRead2D2x4) io.SetEngine(engineName); } - adios2::Engine bpReader = io.Open(fname, adios2::Mode::Read); + adios2::Engine bpReader = + io.Open(fname, adios2::Mode::ReadRandomAccess); auto var_iString = io.InquireVariable("iString"); EXPECT_TRUE(var_iString); @@ -898,7 +900,8 @@ TEST_F(BPWriteMultiblockReadTest, ADIOS2BPWriteMultiblockRead2D4x2) io.SetEngine(engineName); } - adios2::Engine bpReader = io.Open(fname, adios2::Mode::Read); + adios2::Engine bpReader = + io.Open(fname, adios2::Mode::ReadRandomAccess); auto var_i8 = io.InquireVariable("i8"); EXPECT_TRUE(var_i8); @@ -1245,7 +1248,8 @@ TEST_F(BPWriteMultiblockReadTest, ADIOS2BPWriteRead1D8ZeroBlock) io.SetEngine(engineName); } - adios2::Engine bpReader = io.Open(fname, adios2::Mode::Read); + adios2::Engine bpReader = + io.Open(fname, adios2::Mode::ReadRandomAccess); auto var_iString = io.InquireVariable("iString"); EXPECT_TRUE(var_iString); diff --git a/testing/adios2/engine/bp/TestBPWriteReadMultiblock.cpp b/testing/adios2/engine/bp/TestBPWriteReadMultiblock.cpp index 156961cb04..f04e472d62 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadMultiblock.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadMultiblock.cpp @@ -359,7 +359,7 @@ TEST_F(BPWriteReadMultiblockTest, ADIOS2BPWriteReadMultiblock1D8) EXPECT_EQ(cr32AllInfo.size(), NSteps); EXPECT_EQ(cr64AllInfo.size(), NSteps); - while (bpReader.BeginStep() == adios2::StepStatus::OK) + for (size_t CurrentStep = 0; CurrentStep < NSteps; CurrentStep++) { const std::vector::Info> &iStringInfo = iStringAllInfo.at(t); @@ -717,83 +717,90 @@ TEST_F(BPWriteReadMultiblockTest, ADIOS2BPWriteReadMultiblock1D8) EXPECT_EQ(r32Info[i].Max, r32Max); EXPECT_EQ(r64Info[i].Min, r64Min); EXPECT_EQ(r64Info[i].Max, r64Max); - - EXPECT_EQ(cr32Info[i].Min, cr32Min); - EXPECT_EQ(cr32Info[i].Max, cr32Max); - EXPECT_EQ(cr64Info[i].Min, cr64Min); - EXPECT_EQ(cr64Info[i].Max, cr64Max); } // Generate test data for each rank uniquely SmallTestData currentTestData = generateNewSmallTestData( m_TestData, static_cast(t), mpiRank, mpiSize); + var_iString.SetStepSelection({CurrentStep, 1}); bpReader.Get(var_iString, IString); + var_i8.SetStepSelection({CurrentStep, 1}); var_i8.SetSelection(sel1); bpReader.Get(var_i8, I8.data()); var_i8.SetSelection(sel2); bpReader.Get(var_i8, I8.data() + Nx / 2); + var_i16.SetStepSelection({CurrentStep, 1}); var_i16.SetSelection(sel1); bpReader.Get(var_i16, I16.data()); var_i16.SetSelection(sel2); bpReader.Get(var_i16, I16.data() + Nx / 2); + var_i32.SetStepSelection({CurrentStep, 1}); var_i32.SetSelection(sel1); bpReader.Get(var_i32, I32.data()); var_i32.SetSelection(sel2); bpReader.Get(var_i32, I32.data() + Nx / 2); + var_i64.SetStepSelection({CurrentStep, 1}); var_i64.SetSelection(sel1); bpReader.Get(var_i64, I64.data()); var_i64.SetSelection(sel2); bpReader.Get(var_i64, I64.data() + Nx / 2); + var_u8.SetStepSelection({CurrentStep, 1}); var_u8.SetSelection(sel1); bpReader.Get(var_u8, U8.data()); var_u8.SetSelection(sel2); bpReader.Get(var_u8, U8.data() + Nx / 2); + var_u16.SetStepSelection({CurrentStep, 1}); var_u16.SetSelection(sel1); bpReader.Get(var_u16, U16.data()); var_u16.SetSelection(sel2); bpReader.Get(var_u16, U16.data() + Nx / 2); + var_u32.SetStepSelection({CurrentStep, 1}); var_u32.SetSelection(sel1); bpReader.Get(var_u32, U32.data()); var_u32.SetSelection(sel2); bpReader.Get(var_u32, U32.data() + Nx / 2); + var_u64.SetStepSelection({CurrentStep, 1}); var_u64.SetSelection(sel1); bpReader.Get(var_u64, U64.data()); var_u64.SetSelection(sel2); bpReader.Get(var_u64, U64.data() + Nx / 2); + var_r32.SetStepSelection({CurrentStep, 1}); var_r32.SetSelection(sel1); bpReader.Get(var_r32, R32.data()); var_r32.SetSelection(sel2); bpReader.Get(var_r32, R32.data() + Nx / 2); + var_r64.SetStepSelection({CurrentStep, 1}); var_r64.SetSelection(sel1); bpReader.Get(var_r64, R64.data()); var_r64.SetSelection(sel2); bpReader.Get(var_r64, R64.data() + Nx / 2); + var_cr32.SetStepSelection({CurrentStep, 1}); var_cr32.SetSelection(sel1); bpReader.Get(var_cr32, CR32.data()); var_cr32.SetSelection(sel2); bpReader.Get(var_cr32, CR32.data() + Nx / 2); + var_cr64.SetStepSelection({CurrentStep, 1}); var_cr64.SetSelection(sel1); bpReader.Get(var_cr64, CR64.data()); var_cr64.SetSelection(sel2); bpReader.Get(var_cr64, CR64.data() + Nx / 2); - bpReader.EndStep(); - EXPECT_EQ(IString, currentTestData.S1); + bpReader.PerformGets(); for (size_t i = 0; i < Nx; ++i) { std::stringstream ss; @@ -1129,71 +1136,84 @@ TEST_F(BPWriteReadMultiblockTest, ADIOS2BPWriteReadMultiblock2D2x4) size_t t = 0; - while (bpReader.BeginStep() == adios2::StepStatus::OK) + for (size_t CurrentStep = 0; CurrentStep < NSteps; CurrentStep++) { + var_iString.SetStepSelection({CurrentStep, 1}); bpReader.Get(var_iString, IString); + var_i8.SetStepSelection({CurrentStep, 1}); var_i8.SetSelection(sel1); bpReader.Get(var_i8, I8.data()); var_i8.SetSelection(sel2); bpReader.Get(var_i8, I8.data() + Ny * Nx / 2); + var_i16.SetStepSelection({CurrentStep, 1}); var_i16.SetSelection(sel1); bpReader.Get(var_i16, I16.data()); var_i16.SetSelection(sel2); bpReader.Get(var_i16, I16.data() + Ny * Nx / 2); + var_i32.SetStepSelection({CurrentStep, 1}); var_i32.SetSelection(sel1); bpReader.Get(var_i32, I32.data()); var_i32.SetSelection(sel2); bpReader.Get(var_i32, I32.data() + Ny * Nx / 2); + var_i64.SetStepSelection({CurrentStep, 1}); var_i64.SetSelection(sel1); bpReader.Get(var_i64, I64.data()); var_i64.SetSelection(sel2); bpReader.Get(var_i64, I64.data() + Ny * Nx / 2); + var_u8.SetStepSelection({CurrentStep, 1}); var_u8.SetSelection(sel1); bpReader.Get(var_u8, U8.data()); var_u8.SetSelection(sel2); bpReader.Get(var_u8, U8.data() + Ny * Nx / 2); + var_u16.SetStepSelection({CurrentStep, 1}); var_u16.SetSelection(sel1); bpReader.Get(var_u16, U16.data()); var_u16.SetSelection(sel2); bpReader.Get(var_u16, U16.data() + Ny * Nx / 2); + var_u32.SetStepSelection({CurrentStep, 1}); var_u32.SetSelection(sel1); bpReader.Get(var_u32, U32.data()); var_u32.SetSelection(sel2); bpReader.Get(var_u32, U32.data() + Ny * Nx / 2); + var_u64.SetStepSelection({CurrentStep, 1}); var_u64.SetSelection(sel1); bpReader.Get(var_u64, U64.data()); var_u64.SetSelection(sel2); bpReader.Get(var_u64, U64.data() + Ny * Nx / 2); + var_r32.SetStepSelection({CurrentStep, 1}); var_r32.SetSelection(sel1); bpReader.Get(var_r32, R32.data()); var_r32.SetSelection(sel2); bpReader.Get(var_r32, R32.data() + Ny * Nx / 2); + var_r64.SetStepSelection({CurrentStep, 1}); var_r64.SetSelection(sel1); bpReader.Get(var_r64, R64.data()); var_r64.SetSelection(sel2); bpReader.Get(var_r64, R64.data() + Ny * Nx / 2); + var_cr32.SetStepSelection({CurrentStep, 1}); var_cr32.SetSelection(sel1); bpReader.Get(var_cr32, CR32.data()); var_cr32.SetSelection(sel2); bpReader.Get(var_cr32, CR32.data() + Ny * Nx / 2); + var_cr64.SetStepSelection({CurrentStep, 1}); var_cr64.SetSelection(sel1); bpReader.Get(var_cr64, CR64.data()); var_cr64.SetSelection(sel2); bpReader.Get(var_cr64, CR64.data() + Ny * Nx / 2); - bpReader.EndStep(); + bpReader.PerformGets(); // Generate test data for each rank uniquely SmallTestData currentTestData = generateNewSmallTestData( @@ -1532,35 +1552,33 @@ TEST_F(BPWriteReadMultiblockTest, ADIOS2BPWriteReadMultiblock2D4x2) size_t t = 0; - while (bpReader.BeginStep() == adios2::StepStatus::OK) + for (size_t CurrentStep = 0; CurrentStep < NSteps; CurrentStep++) { const std::vector::Info> i8Info = - bpReader.BlocksInfo(var_i8, bpReader.CurrentStep()); + bpReader.BlocksInfo(var_i8, CurrentStep); const std::vector::Info> i16Info = - bpReader.BlocksInfo(var_i16, bpReader.CurrentStep()); + bpReader.BlocksInfo(var_i16, CurrentStep); const std::vector::Info> i32Info = - bpReader.BlocksInfo(var_i32, bpReader.CurrentStep()); + bpReader.BlocksInfo(var_i32, CurrentStep); const std::vector::Info> i64Info = - bpReader.BlocksInfo(var_i64, bpReader.CurrentStep()); + bpReader.BlocksInfo(var_i64, CurrentStep); const std::vector::Info> u8Info = - bpReader.BlocksInfo(var_u8, bpReader.CurrentStep()); + bpReader.BlocksInfo(var_u8, CurrentStep); const std::vector::Info> u16Info = - bpReader.BlocksInfo(var_u16, bpReader.CurrentStep()); + bpReader.BlocksInfo(var_u16, CurrentStep); const std::vector::Info> u32Info = - bpReader.BlocksInfo(var_u32, bpReader.CurrentStep()); + bpReader.BlocksInfo(var_u32, CurrentStep); const std::vector::Info> u64Info = - bpReader.BlocksInfo(var_u64, bpReader.CurrentStep()); + bpReader.BlocksInfo(var_u64, CurrentStep); const std::vector::Info> r32Info = - bpReader.BlocksInfo(var_r32, bpReader.CurrentStep()); + bpReader.BlocksInfo(var_r32, CurrentStep); const std::vector::Info> r64Info = - bpReader.BlocksInfo(var_r64, bpReader.CurrentStep()); + bpReader.BlocksInfo(var_r64, CurrentStep); const std::vector>::Info> - cr32Info = - bpReader.BlocksInfo(var_cr32, bpReader.CurrentStep()); + cr32Info = bpReader.BlocksInfo(var_cr32, CurrentStep); const std::vector>::Info> - cr64Info = - bpReader.BlocksInfo(var_cr64, bpReader.CurrentStep()); + cr64Info = bpReader.BlocksInfo(var_cr64, CurrentStep); EXPECT_EQ(i8Info.size(), 2 * mpiSize); EXPECT_EQ(i16Info.size(), 2 * mpiSize); @@ -1961,79 +1979,86 @@ TEST_F(BPWriteReadMultiblockTest, ADIOS2BPWriteReadMultiblock2D4x2) EXPECT_EQ(r32Info[i].Max, r32Max); EXPECT_EQ(r64Info[i].Min, r64Min); EXPECT_EQ(r64Info[i].Max, r64Max); - - EXPECT_EQ(cr32Info[i].Min, cr32Min); - EXPECT_EQ(cr32Info[i].Max, cr32Max); - EXPECT_EQ(cr64Info[i].Min, cr64Min); - EXPECT_EQ(cr64Info[i].Max, cr64Max); } + var_i8.SetStepSelection({CurrentStep, 1}); var_i8.SetSelection(sel1); bpReader.Get(var_i8, I8.data()); var_i8.SetSelection(sel2); bpReader.Get(var_i8, I8.data() + Ny * Nx / 2); + var_i16.SetStepSelection({CurrentStep, 1}); var_i16.SetSelection(sel1); bpReader.Get(var_i16, I16.data()); var_i16.SetSelection(sel2); bpReader.Get(var_i16, I16.data() + Ny * Nx / 2); + var_i32.SetStepSelection({CurrentStep, 1}); var_i32.SetSelection(sel1); bpReader.Get(var_i32, I32.data()); var_i32.SetSelection(sel2); bpReader.Get(var_i32, I32.data() + Ny * Nx / 2); + var_i64.SetStepSelection({CurrentStep, 1}); var_i64.SetSelection(sel1); bpReader.Get(var_i64, I64.data()); var_i64.SetSelection(sel2); bpReader.Get(var_i64, I64.data() + Ny * Nx / 2); + var_u8.SetStepSelection({CurrentStep, 1}); var_u8.SetSelection(sel1); bpReader.Get(var_u8, U8.data()); var_u8.SetSelection(sel2); bpReader.Get(var_u8, U8.data() + Ny * Nx / 2); + var_u16.SetStepSelection({CurrentStep, 1}); var_u16.SetSelection(sel1); bpReader.Get(var_u16, U16.data()); var_u16.SetSelection(sel2); bpReader.Get(var_u16, U16.data() + Ny * Nx / 2); + var_u32.SetStepSelection({CurrentStep, 1}); var_u32.SetSelection(sel1); bpReader.Get(var_u32, U32.data()); var_u32.SetSelection(sel2); bpReader.Get(var_u32, U32.data() + Ny * Nx / 2); + var_u64.SetStepSelection({CurrentStep, 1}); var_u64.SetSelection(sel1); bpReader.Get(var_u64, U64.data()); var_u64.SetSelection(sel2); bpReader.Get(var_u64, U64.data() + Ny * Nx / 2); + var_r32.SetStepSelection({CurrentStep, 1}); var_r32.SetSelection(sel1); bpReader.Get(var_r32, R32.data()); var_r32.SetSelection(sel2); bpReader.Get(var_r32, R32.data() + Ny * Nx / 2); + var_r64.SetStepSelection({CurrentStep, 1}); var_r64.SetSelection(sel1); bpReader.Get(var_r64, R64.data()); var_r64.SetSelection(sel2); bpReader.Get(var_r64, R64.data() + Ny * Nx / 2); + var_cr32.SetStepSelection({CurrentStep, 1}); var_cr32.SetSelection(sel1); bpReader.Get(var_cr32, CR32.data()); var_cr32.SetSelection(sel2); bpReader.Get(var_cr32, CR32.data() + Ny * Nx / 2); + var_cr64.SetStepSelection({CurrentStep, 1}); var_cr64.SetSelection(sel1); bpReader.Get(var_cr64, CR64.data()); var_cr64.SetSelection(sel2); bpReader.Get(var_cr64, CR64.data() + Ny * Nx / 2); - bpReader.EndStep(); - // Generate test data for each rank uniquely SmallTestData currentTestData = generateNewSmallTestData( m_TestData, static_cast(t), mpiRank, mpiSize); + bpReader.PerformGets(); + for (size_t i = 0; i < Nx * Ny; ++i) { std::stringstream ss;