Skip to content

Commit

Permalink
Merge pull request #2975 from eisenhauer/BP5MM
Browse files Browse the repository at this point in the history
BP5 MinMax
  • Loading branch information
eisenhauer authored Jan 3, 2022
2 parents c2836de + be0625a commit 9c3f0da
Show file tree
Hide file tree
Showing 18 changed files with 554 additions and 295 deletions.
4 changes: 2 additions & 2 deletions bindings/CXX11/adios2/cxx11/Engine.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ ToBlocksInfo(const core::Engine::MinVarInfo *coreVarInfo)
}
else
{
blockInfo.Min = *((T *)&coreBlockInfo.MinUnion);
blockInfo.Max = *((T *)&coreBlockInfo.MaxUnion);
blockInfo.Min = *(T *)&coreBlockInfo.MinMax.MinUnion;
blockInfo.Max = *(T *)&coreBlockInfo.MinMax.MaxUnion;
}
blockInfo.BlockID = coreBlockInfo.BlockID;
blocksInfo.push_back(blockInfo);
Expand Down
1 change: 0 additions & 1 deletion source/adios2/common/ADIOSMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@

#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) \
Expand Down
143 changes: 127 additions & 16 deletions source/adios2/core/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
#define ADIOS2_CORE_ENGINE_H_

/// \cond EXCLUDE_FROM_DOXYGEN
#include <float.h>
#include <functional> //std::function
#include <limits> //std::numeric_limits
#include <memory> //std::shared_ptr
#include <limits.h>
#include <limits> //std::numeric_limits
#include <memory> //std::shared_ptr
#include <set>
#include <string>
#include <vector>
Expand Down Expand Up @@ -455,30 +457,139 @@ class Engine
#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 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;
union PrimitiveStdtypeUnion MinUnion;
union PrimitiveStdtypeUnion MaxUnion;
MinMaxStruct MinMax;
void *BufferP = NULL;
};
struct MinMaxStruct
{
union PrimitiveStdtypeUnion MinUnion;
union PrimitiveStdtypeUnion MaxUnion;
};
struct MinVarInfo
{
int Dims;
Expand Down
4 changes: 2 additions & 2 deletions source/adios2/core/Variable.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ std::pair<T, T> Variable<T>::DoMinMax(const size_t step) const
Engine::MinMaxStruct MM;
if (m_Engine->VariableMinMax(*this, step, MM))
{
minMax.first = MM.MinUnion.Get(minMax.first);
minMax.second = MM.MaxUnion.Get(minMax.second);
minMax.first = *(T *)&MM.MinUnion;
minMax.second = *(T *)&MM.MaxUnion;
return minMax;
}
}
Expand Down
Loading

0 comments on commit 9c3f0da

Please sign in to comment.