Skip to content

Commit 04edeca

Browse files
authored
rework (#4583)
1 parent d69968b commit 04edeca

File tree

6 files changed

+49
-19
lines changed

6 files changed

+49
-19
lines changed

source/adios2/core/Engine.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,10 @@ class Engine
529529
void RegisterCreatedVariable(const VariableBase *var);
530530
void RemoveCreatedVars();
531531

532+
/** true: We only need the name of an operator used in Get, not actual operation
533+
*/
534+
bool m_OperatorNameQuery = false;
535+
532536
protected:
533537
/** from ADIOS class passed to Engine created with Open
534538
* if no communicator is passed */

source/adios2/core/VariableBase.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,9 @@ size_t VariableBase::AddOperation(const std::string &type, const Params &paramet
346346
if (!m_Operations.empty() && (m_Operations[0]->m_TypeString == "null"))
347347
{
348348
// if there's a dummy operation in place, replace it
349-
m_Operations[0] = op;
350-
}
351-
else
352-
{
353-
m_Operations.push_back(op);
349+
m_Operations.clear();
354350
}
351+
m_Operations.push_back(op);
355352
}
356353
else
357354
{

source/adios2/operator/plugin/PluginOperator.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ void PluginOperator::PluginInit(const std::string &pluginName, const std::string
9494
// add for external visibility
9595
m_PluginName = pluginName;
9696
m_PluginLibrary = pluginLibrary;
97+
if (m_OperatorNameQuery)
98+
{
99+
auto m = MakeMessage("Plugins", "PluginOperator", "PluginInit",
100+
"Succeeding in load library " + m_PluginLibrary +
101+
" looking for plugin " + m_PluginName,
102+
-1, helper::LogMode::EXCEPTION);
103+
throw PluginLoadFailure(m, pluginLibrary, pluginName);
104+
}
97105
}
98106

99107
size_t PluginOperator::GetEstimatedSize(const size_t ElemCount, const size_t ElemSize,

source/adios2/operator/plugin/PluginOperator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class PluginOperator : public core::Operator
5050

5151
std::string m_PluginLibrary;
5252
std::string m_PluginName;
53+
bool m_OperatorNameQuery = false;
5354

5455
protected:
5556
void PluginInit(const std::string &pluginName, const std::string &pluginLibrary);

source/adios2/toolkit/format/bp5/BP5Deserializer.cpp

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#endif
3232

3333
#include "adios2/operator/OperatorFactory.h"
34+
#include "adios2/operator/plugin/PluginOperator.h"
3435

3536
#include <array>
3637
#include <float.h>
@@ -1993,22 +1994,39 @@ void BP5Deserializer::FinalizeGet(const ReadRequest &Read, const bool freeAddr)
19931994
std::shared_ptr<Operator> op = nullptr;
19941995
VariableBase *VB =
19951996
static_cast<VariableBase *>(((struct BP5VarRec *)Req.VarRec)->Variable);
1996-
if (!VB->m_Operations.empty() && (VB->m_Operations[0]->m_TypeString != "null"))
1997-
{
1998-
op = VB->m_Operations[0];
1999-
}
2000-
else
2001-
{
2002-
Operator::OperatorType compressorType =
2003-
static_cast<Operator::OperatorType>(IncomingData[0]);
2004-
op = MakeOperator(OperatorTypeToString(compressorType), {});
2005-
VB->m_Operations.resize(1);
2006-
VB->m_Operations[0] = op;
2007-
}
2008-
op->SetAccuracy(VB->GetAccuracyRequested());
2009-
20101997
{
20111998
std::lock_guard<std::mutex> lockGuard(mutexDecompress);
1999+
// lock_guard protects mods to VB->m_Operations as well as the decompress operator
2000+
if (!VB->m_Operations.empty() && (VB->m_Operations[0]->m_TypeString != "null"))
2001+
{
2002+
op = VB->m_Operations[0];
2003+
}
2004+
else
2005+
{
2006+
Operator::OperatorType compressorType =
2007+
static_cast<Operator::OperatorType>(IncomingData[0]);
2008+
op = MakeOperator(OperatorTypeToString(compressorType), {});
2009+
VB->m_Operations.clear();
2010+
VB->m_Operations.push_back(op);
2011+
if (m_Engine->m_OperatorNameQuery)
2012+
{
2013+
if (compressorType == Operator::PLUGIN_INTERFACE)
2014+
{
2015+
auto pop = dynamic_cast<plugin::PluginOperator *>(op.get());
2016+
pop->m_OperatorNameQuery = true;
2017+
}
2018+
else
2019+
{
2020+
auto m = MakeMessage("Operator", "OperatorFactory", "MakeOperator",
2021+
"ADIOS2 compiled with " +
2022+
OperatorTypeToString(compressorType) +
2023+
" library, operator added",
2024+
-1, helper::LogMode::EXCEPTION);
2025+
throw MissingOperatorFailure(m, OperatorTypeToString(compressorType));
2026+
}
2027+
}
2028+
}
2029+
op->SetAccuracy(VB->GetAccuracyRequested());
20122030
core::Decompress(
20132031
IncomingData,
20142032
((MetaArrayRecOperator *)writer_meta_base)->DataBlockSize[Read.BlockID],

source/utils/bpls/bpls.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,9 @@ int doList_operators(core::Engine *fp, core::IO *io)
10101010
variable->SetBlockSelection(0); \
10111011
std::vector<T> dataV; \
10121012
dataV.resize(variable->SelectionSize()); \
1013+
fp->m_OperatorNameQuery = true; \
10131014
fp->Get(*variable, dataV, adios2::Mode::Sync); \
1015+
fp->m_OperatorNameQuery = false; \
10141016
}
10151017
ADIOS2_FOREACH_STDTYPE_1ARG(declare_template_instantiation)
10161018
#undef declare_template_instantiation

0 commit comments

Comments
 (0)