Skip to content

Commit

Permalink
Merge pull request #1543 from williamfgc/shape_dyn
Browse files Browse the repository at this point in the history
Adding dynamic shape to adios_reorganize
  • Loading branch information
williamfgc authored Jun 25, 2019
2 parents 2f4c21c + f2c1593 commit fc89837
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
19 changes: 19 additions & 0 deletions source/adios2/core/VariableBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/// \endcond

#include "adios2/core/Engine.h"
#include "adios2/core/Variable.h"
#include "adios2/helper/adiosFunctions.h" //helper::GetTotalSize

namespace adios2
Expand Down Expand Up @@ -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<T>()) \
{ \
Variable<T> *variable = dynamic_cast<Variable<T> *>(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
2 changes: 2 additions & 0 deletions source/adios2/core/VariableBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions source/utils/adios_reorganize/Reorganize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fc89837

Please sign in to comment.