From f2c159300b87b16f4d6f75dac6295d0b05ed2d9b Mon Sep 17 00:00:00 2001 From: William F Godoy Date: Tue, 25 Jun 2019 10:27:51 -0400 Subject: [PATCH] Adding dynamic shape to adios_reorganize --- source/adios2/core/VariableBase.cpp | 19 +++++++++++++++++++ source/adios2/core/VariableBase.h | 2 ++ source/utils/adios_reorganize/Reorganize.cpp | 14 +++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/source/adios2/core/VariableBase.cpp b/source/adios2/core/VariableBase.cpp index b5d1f24934..04155b2979 100644 --- a/source/adios2/core/VariableBase.cpp +++ b/source/adios2/core/VariableBase.cpp @@ -17,6 +17,7 @@ /// \endcond #include "adios2/core/Engine.h" +#include "adios2/core/Variable.h" #include "adios2/helper/adiosFunctions.h" //helper::GetTotalSize namespace adios2 @@ -478,5 +479,23 @@ void VariableBase::CheckDimensionsCommon(const std::string hint) const } } +Dims VariableBase::GetShape(const size_t step) +{ + if (m_Type == "compound") + { + // not supported + } +#define declare_template_instantiation(T) \ + else if (m_Type == helper::GetType()) \ + { \ + Variable *variable = dynamic_cast *>(this); \ + m_Shape = variable->Shape(step); \ + } + ADIOS2_FOREACH_STDTYPE_1ARG(declare_template_instantiation) +#undef declare_template_instantiation + + return m_Shape; +} + } // end namespace core } // end namespace adios2 diff --git a/source/adios2/core/VariableBase.h b/source/adios2/core/VariableBase.h index 65656a9537..b59d81c4a6 100644 --- a/source/adios2/core/VariableBase.h +++ b/source/adios2/core/VariableBase.h @@ -195,6 +195,8 @@ class VariableBase */ void CheckRandomAccessConflict(const std::string hint) const; + Dims GetShape(const size_t step = adios2::EngineCurrentStep); + protected: const bool m_DebugMode = false; bool m_ConstantDims = false; ///< true: fix m_Shape, m_Start, m_Count diff --git a/source/utils/adios_reorganize/Reorganize.cpp b/source/utils/adios_reorganize/Reorganize.cpp index 913137d266..be1f897b75 100644 --- a/source/utils/adios_reorganize/Reorganize.cpp +++ b/source/utils/adios_reorganize/Reorganize.cpp @@ -310,7 +310,7 @@ Reorganize::Decompose(int numproc, int rank, VarInfo &vi, return writesize; } - size_t ndim = vi.v->m_Shape.size(); + size_t ndim = vi.v->GetShape().size(); if (ndim == 0) { // scalars -> rank 0 writes them @@ -381,12 +381,12 @@ Reorganize::Decompose(int numproc, int rank, VarInfo &vi, } else { - count = vi.v->m_Shape[i] / np[i]; + count = vi.v->GetShape()[i] / np[i]; start = count * pos[i]; if (pos[i] == np[i] - 1) { // last one in the dimension may need to read more than the rest - count = vi.v->m_Shape[i] - count * (np[i] - 1); + count = vi.v->GetShape()[i] - count * (np[i] - 1); } } vi.start.push_back(start); @@ -446,11 +446,11 @@ int Reorganize::ProcessMetadata(core::Engine &rStream, core::IO &io, if (!rank) { std::cout << " " << type << " " << name; - if (variable->m_Shape.size() > 0) + if (variable->GetShape().size() > 0) { - std::cout << "[" << variable->m_Shape[0]; - for (int j = 1; j < variable->m_Shape.size(); j++) - std::cout << ", " << variable->m_Shape[j]; + std::cout << "[" << variable->GetShape()[0]; + for (int j = 1; j < variable->GetShape().size(); j++) + std::cout << ", " << variable->GetShape()[j]; std::cout << "]" << std::endl; } else