Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BP5 Local var tests #2896

Merged
merged 4 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions source/adios2/common/ADIOSMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,20 @@
MACRO(std::complex<float>, cfloat) \
MACRO(std::complex<double>, cdouble)

#define ADIOS2_FOREACH_MINMAX_STDTYPE_2ARGS(MACRO) \
MACRO(int8_t, int8) \
MACRO(char, char) \
MACRO(uint8_t, uint8) \
MACRO(int16_t, int16) \
MACRO(uint16_t, uint16) \
MACRO(int32_t, int32) \
MACRO(uint32_t, uint32) \
MACRO(int64_t, int64) \
MACRO(uint64_t, uint64) \
MACRO(float, float) \
MACRO(double, double) \
MACRO(long double, ldouble)

#define ADIOS2_FOREACH_STDTYPE_2ARGS(MACRO) \
ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_2ARGS(MACRO)

Expand Down
2 changes: 1 addition & 1 deletion source/adios2/common/ADIOSTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum class ShapeID
GlobalArray, ///< global (across MPI_Comm) array, common case
JoinedArray, ///< global array with a common (joinable) dimension
LocalValue, ///< special case, local independent value
LocalArray ///< special case, local independent array
LocalArray, ///< special case, local independent array
};

/** Used to set IO class */
Expand Down
33 changes: 22 additions & 11 deletions source/adios2/core/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,17 +452,16 @@ class Engine

union PrimitiveStdtypeUnion
{
int8_t int8;
int16_t int16;
int32_t int32;
int64_t int64;
uint8_t uint8;
uint16_t uint16;
uint32_t uint32;
uint64_t uint64;
float f;
double d;
long double ld;
#define declare_field(T, N) T field_##N;
ADIOS2_FOREACH_MINMAX_STDTYPE_2ARGS(declare_field)
#undef declare_field
#define declare_get(T, N) \
T Get(T def) { return field_##N; }
ADIOS2_FOREACH_MINMAX_STDTYPE_2ARGS(declare_get)
#undef declare_get
std::string Get(std::string def) { return def; }
std::complex<float> Get(std::complex<float> def) { return def; }
std::complex<double> Get(std::complex<double> def) { return def; }
};

struct MinBlockInfo
Expand All @@ -475,6 +474,11 @@ class Engine
union PrimitiveStdtypeUnion MaxUnion;
void *BufferP = NULL;
};
struct MinMaxStruct
{
union PrimitiveStdtypeUnion MinUnion;
union PrimitiveStdtypeUnion MaxUnion;
};
struct MinVarInfo
{
int Dims;
Expand All @@ -489,12 +493,19 @@ class Engine
}
};

// in this call, Step is RELATIVE, not absolute
virtual MinVarInfo *MinBlocksInfo(const VariableBase &,
const size_t Step) const
{
return nullptr;
}

virtual bool VariableMinMax(const VariableBase &, const size_t Step,
MinMaxStruct &MinMax)
{
return false;
}

/** Notify the engine when a new attribute is defined. Called from IO.tcc
*/
virtual void NotifyEngineAttribute(std::string name,
Expand Down
35 changes: 35 additions & 0 deletions source/adios2/core/Variable.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,30 @@ Dims Variable<T>::DoCount() const

if (m_Engine != nullptr && m_SelectionType == SelectionType::WriteBlock)
{
auto MVI = m_Engine->MinBlocksInfo(*this, m_StepsStart);
if (MVI)
{
if (m_BlockID >= MVI->BlocksInfo.size())
{
throw std::invalid_argument(
"ERROR: blockID " + std::to_string(m_BlockID) +
" from SetBlockSelection is out of bounds for available "
"blocks size " +
std::to_string(MVI->BlocksInfo.size()) + " for variable " +
m_Name + " for step " + std::to_string(m_StepsStart) +
", in call to Variable<T>::Count()");
}

size_t *DimsPtr = (MVI->BlocksInfo)[m_BlockID].Count;
Dims D;
D.resize(MVI->Dims);
for (int i = 0; i < MVI->Dims; i++)
{
D[i] = DimsPtr[i];
}
return D;
}

const size_t step =
!m_FirstStreamingStep ? m_Engine->CurrentStep() : lf_Step();

Expand Down Expand Up @@ -101,6 +125,17 @@ std::pair<T, T> Variable<T>::DoMinMax(const size_t step) const
minMax.first = {};
minMax.second = {};

if (m_Engine != nullptr)
{

Engine::MinMaxStruct MM;
if (m_Engine->VariableMinMax(*this, step, MM))
{
minMax.first = MM.MinUnion.Get(minMax.first);
minMax.second = MM.MaxUnion.Get(minMax.second);
return minMax;
}
}
if (m_Engine != nullptr && !m_FirstStreamingStep)
{
const size_t stepInput =
Expand Down
6 changes: 6 additions & 0 deletions source/adios2/engine/bp5/BP5Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,12 @@ Engine::MinVarInfo *BP5Reader::MinBlocksInfo(const VariableBase &Var,
return m_BP5Deserializer->MinBlocksInfo(Var, Step);
}

bool BP5Reader::VariableMinMax(const VariableBase &Var, const size_t Step,
Engine::MinMaxStruct &MinMax)
{
return m_BP5Deserializer->VariableMinMax(Var, Step, MinMax);
}

void BP5Reader::InitTransports()
{
if (m_IO.m_TransportsParameters.empty())
Expand Down
2 changes: 2 additions & 0 deletions source/adios2/engine/bp5/BP5Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class BP5Reader : public BP5Engine, public Engine
void PerformGets() final;

MinVarInfo *MinBlocksInfo(const VariableBase &, const size_t Step) const;
bool VariableMinMax(const VariableBase &, const size_t Step,
MinMaxStruct &MinMax);

private:
format::BP5Deserializer *m_BP5Deserializer = nullptr;
Expand Down
Loading