Skip to content

Commit

Permalink
enabled complex types
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonRuonanWang committed Jan 19, 2022
1 parent 8d5ac2d commit 2b5b392
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
41 changes: 28 additions & 13 deletions source/adios2/operator/compress/CompressMGARD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,19 @@ size_t CompressMGARD::Operate(const char *dataIn, const Dims &blockStart,

MakeCommonHeader(bufferOut, bufferOutOffset, bufferVersion);

const size_t ndims = blockCount.size();
Dims convertedDims = ConvertDims(blockCount, type, 3);

const size_t ndims = convertedDims.size();
if (ndims > 5)
{
throw std::invalid_argument("ERROR: ADIOS2 MGARD compression: MGARG "
"only supports up to 5 dimensions");
helper::Log("Operator", "CompressMGARD", "Operate",
"MGARG only supports up to 5 dimensions",
helper::LogMode::EXCEPTION);
}

// mgard V1 metadata
PutParameter(bufferOut, bufferOutOffset, ndims);
for (const auto &d : blockCount)
for (const auto &d : convertedDims)
{
PutParameter(bufferOut, bufferOutOffset, d);
}
Expand All @@ -67,17 +70,26 @@ size_t CompressMGARD::Operate(const char *dataIn, const Dims &blockStart,
{
mgardType = mgard_x::data_type::Double;
}
else if (type == helper::GetDataType<std::complex<float>>())
{
mgardType = mgard_x::data_type::Float;
}
else if (type == helper::GetDataType<std::complex<double>>())
{
mgardType = mgard_x::data_type::Double;
}
else
{
throw std::invalid_argument("ERROR: ADIOS2 operator MGARD only "
"supports float and double types");
helper::Log("Operator", "CompressMGARD", "Operate",
"MGARD only supports float and double types",
helper::LogMode::EXCEPTION);
}
// set type end

// set mgard style dim info
mgard_x::DIM mgardDim = ndims;
std::vector<mgard_x::SIZE> mgardCount;
for (const auto &c : blockCount)
for (const auto &c : convertedDims)
{
mgardCount.push_back(c);
}
Expand All @@ -103,9 +115,9 @@ size_t CompressMGARD::Operate(const char *dataIn, const Dims &blockStart,
}
if (!hasTolerance)
{
throw std::invalid_argument("ERROR: missing mandatory parameter "
"tolerance for MGARD compression "
"operator\n");
helper::Log("Operator", "CompressMGARD", "Operate",
"missing mandatory parameter tolerance / accuracy",
helper::LogMode::EXCEPTION);
}
auto itSParameter = m_Parameters.find("s");
if (itSParameter != m_Parameters.end())
Expand Down Expand Up @@ -180,7 +192,8 @@ size_t CompressMGARD::DecompressV1(const char *bufferIn, const size_t sizeIn,
}
catch (...)
{
throw(m_VersionInfo);
helper::Log("Operator", "CompressMGARD", "DecompressV1", m_VersionInfo,
helper::LogMode::EXCEPTION);
}

return sizeOut;
Expand All @@ -206,15 +219,17 @@ size_t CompressMGARD::InverseOperate(const char *bufferIn, const size_t sizeIn,
}
else
{
throw("unknown mgard buffer version");
helper::Log("Operator", "CompressMGARD", "DecompressV1",
"unknown mgard buffer version", helper::LogMode::EXCEPTION);
}

return 0;
}

bool CompressMGARD::IsDataTypeValid(const DataType type) const
{
if (type == DataType::Double || type == DataType::Float)
if (type == DataType::Double || type == DataType::Float ||
type == DataType::DoubleComplex || type == DataType::FloatComplex)
{
return true;
}
Expand Down
1 change: 0 additions & 1 deletion source/adios2/operator/compress/CompressZFP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ size_t CompressZFP::Operate(const char *dataIn, const Dims &blockStart,
const Dims &blockCount, const DataType type,
char *bufferOut)
{

const uint8_t bufferVersion = 1;
size_t bufferOutOffset = 0;

Expand Down

0 comments on commit 2b5b392

Please sign in to comment.