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

Rework BP5 Attribute handling #3304

Merged
merged 17 commits into from
Aug 15, 2022
Prev Previous commit
Next Next commit
Use engine params to control attribute marshalling
  • Loading branch information
eisenhauer committed Aug 15, 2022
commit 4662ef2545ba44a5a063d4c5efb32fc2aaa416e3
1 change: 1 addition & 0 deletions source/adios2/engine/bp5/BP5Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class BP5Engine
MACRO(StatsLevel, UInt, unsigned int, 1) \
MACRO(StatsBlockSize, SizeBytes, size_t, DefaultStatsBlockSize) \
MACRO(Threads, UInt, unsigned int, 0) \
MACRO(UseOneTimeAttributes, Bool, bool, true) \
MACRO(MaxOpenFilesAtOnce, UInt, unsigned int, UINT_MAX)

struct BP5Params
Expand Down
4 changes: 2 additions & 2 deletions source/adios2/engine/bp5/BP5Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ StepStatus BP5Writer::BeginStep(StepMode mode, const float timeoutSeconds)
}
}

if ((m_WriterStep == 0) && !getenv("OldAttr"))
if ((m_WriterStep == 0) && m_Parameters.UseOneTimeAttributes)
{
const auto &attributes = m_IO.GetAttributes();

Expand Down Expand Up @@ -440,7 +440,7 @@ void BP5Writer::NotifyEngineAttribute(std::string name, DataType type) noexcept
void BP5Writer::NotifyEngineAttribute(std::string name, AttributeBase *Attr,
void *data) noexcept
{
if (getenv("OldAttr"))
if (!m_Parameters.UseOneTimeAttributes)
{
m_MarshalAttributesNecessary = true;
return;
Expand Down
27 changes: 23 additions & 4 deletions source/adios2/engine/sst/SstWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* Sst.cpp
* SstWriter.cpp
*
* Created on: Aug 17, 2017
* Author: Greg Eisenhauer
Expand Down Expand Up @@ -187,10 +187,16 @@ void SstWriter::MarshalAttributes()
PERFSTUBS_SCOPED_TIMER_FUNC();
const auto &attributes = m_IO.GetAttributes();

const uint32_t attributesCount = static_cast<uint32_t>(attributes.size());
if ((m_WriterStep == 0) && Params.UseOneTimeAttributes)
{
for (const auto &attributePair : attributes)
{
m_BP5Serializer->OnetimeMarshalAttribute(*(attributePair.second));
}
}

// if there are no new attributes, nothing to do
if (attributesCount == m_MarshaledAttributesCount)
if (!m_MarshalAttributesNecessary)
return;

for (const auto &attributePair : attributes)
Expand Down Expand Up @@ -245,7 +251,20 @@ void SstWriter::MarshalAttributes()
ADIOS2_FOREACH_ATTRIBUTE_PRIMITIVE_STDTYPE_1ARG(declare_type)
#undef declare_type
}
m_MarshaledAttributesCount = attributesCount;
m_MarshalAttributesNecessary = false;
}

void SstWriter::NotifyEngineAttribute(std::string name, AttributeBase *Attr,
void *data) noexcept
{
if (!Params.UseOneTimeAttributes)
{
m_MarshalAttributesNecessary = true;
return;
}

m_BP5Serializer->OnetimeMarshalAttribute(*Attr);
m_MarshalAttributesNecessary = false;
}

void SstWriter::EndStep()
Expand Down
4 changes: 3 additions & 1 deletion source/adios2/engine/sst/SstWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class SstWriter : public Engine
void PerformPuts() final;
void EndStep() final;
void Flush(const int transportIndex = -1) final;
void NotifyEngineAttribute(std::string name, AttributeBase *Attr,
void *data) noexcept;

/**
* Called if destructor is called on an open engine. Should warn or take
Expand Down Expand Up @@ -85,7 +87,7 @@ class SstWriter : public Engine
SstStream m_Output;
long m_WriterStep = -1;
bool m_DefinitionsNotified = false;
size_t m_MarshaledAttributesCount = 0;
bool m_MarshalAttributesNecessary = true; // first time through, marshal
struct _SstParams Params;

void MarshalAttributes();
Expand Down
1 change: 1 addition & 0 deletions source/adios2/toolkit/sst/sst_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ typedef struct _SstStats
MACRO(SpeculativePreloadMode, SpecPreloadMode, int, SpecPreloadAuto) \
MACRO(SpecAutoNodeThreshold, Int, int, 1) \
MACRO(ReaderShortCircuitReads, Bool, int, 0) \
MACRO(UseOneTimeAttributes, Bool, int, 0) \
MACRO(ControlModule, String, char *, NULL)

typedef enum
Expand Down