Skip to content

Commit

Permalink
Move the SCR initialize and finalize inside the BP4 engine
Browse files Browse the repository at this point in the history
  • Loading branch information
anagainaru committed Nov 30, 2022
1 parent 73bf631 commit 786c40a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 28 deletions.
1 change: 1 addition & 0 deletions examples/hello/bpWriter/helloBPWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ int main(int argc, char *argv[])
/*** IO class object: settings and factory of Settings: Variables,
* Parameters, Transports, and Execution: Engines */
adios2::IO bpIO = adios.DeclareIO("BPFile_N2N");
bpIO.SetParameters({{"UseSCR", "1"}});

/** global array : name, { shape (total) }, { start (local) }, {
* count
Expand Down
68 changes: 45 additions & 23 deletions source/adios2/engine/bp4/BP4Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,42 @@ void BP4Writer::Flush(const int transportIndex)
}

// PRIVATE
#ifdef ADIOS2_HAVE_SCR
void InitSCR(const std::string fname)
{
SCR_Start_output(fname.c_str(), SCR_FLAG_CHECKPOINT);
}

void CloseSCR(const std::string fname)
{
int scr_valid = 1;
SCR_Complete_output(scr_valid);
}
#endif

std::string SCRRouteFile(std::string name)
{
#ifdef ADIOS2_HAVE_SCR
char scr_name[SCR_MAX_FILENAME];
SCR_Route_file(name.c_str(), scr_name);

std::string s(scr_name);
return s;
#else
return name;
#endif
}

std::vector<std::string> AddSCRRouteInfo(const std::vector<std::string> files)
{
std::vector<std::string> newFiles;
for (const auto &name : files)
{
newFiles.push_back(SCRRouteFile(name));
}
return newFiles;
}

void BP4Writer::Init()
{
InitParameters();
Expand All @@ -160,6 +196,10 @@ void BP4Writer::Init()
}
InitTransports();
InitBPBuffer();
#ifdef ADIOS2_HAVE_SCR
if (m_SCR)
InitSCR(m_Name);
#endif
}

#define declare_type(T) \
Expand Down Expand Up @@ -203,29 +243,7 @@ void BP4Writer::InitParameters()
"in call to BP4::Open to write");
m_WriteToBB = !(m_BP4Serializer.m_Parameters.BurstBufferPath.empty());
m_DrainBB = m_WriteToBB && m_BP4Serializer.m_Parameters.BurstBufferDrain;
}

std::string SCRRouteFile(std::string name)
{
#ifdef ADIOS2_HAVE_SCR
char scr_name[SCR_MAX_FILENAME];
SCR_Route_file(name.c_str(), scr_name);

std::string s(scr_name);
return s;
#else
return name;
#endif
}

std::vector<std::string> AddSCRRouteInfo(const std::vector<std::string> files)
{
std::vector<std::string> newFiles;
for (const auto &name : files)
{
newFiles.push_back(SCRRouteFile(name));
}
return newFiles;
m_SCR = helper::GetParameter(m_IO.m_Parameters, "UseSCR", m_Verbosity);
}

void BP4Writer::InitTransports()
Expand Down Expand Up @@ -584,6 +602,10 @@ void BP4Writer::DoClose(const int transportIndex)
m_FileDrainer.Finish();
}
// m_BP4Serializer.DeleteBuffers();
#ifdef ADIOS2_HAVE_SCR
if (m_SCR)
CloseSCR(m_Name);
#endif
}

void BP4Writer::WriteProfilingJSONFile()
Expand Down
6 changes: 1 addition & 5 deletions source/adios2/engine/bp4/BP4Writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ class BP4Writer : public core::Engine
/* transport manager for managing the metadata index file */
transportman::TransportMan m_FileMetadataIndexManager;

#ifdef ADIOS2_HAVE_SCR
static constexpr bool m_SCR = true;
#else
static constexpr bool m_SCR = false;
#endif
bool m_SCR;

/*
* Burst buffer variables
Expand Down

0 comments on commit 786c40a

Please sign in to comment.