Skip to content

Commit

Permalink
Merge pull request #2657 from eisenhauer/NewSerializer
Browse files Browse the repository at this point in the history
New serializer
  • Loading branch information
eisenhauer committed May 25, 2021
2 parents 24ab5dc + 03f365a commit edb0eec
Show file tree
Hide file tree
Showing 40 changed files with 7,383 additions and 2,168 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ adios_option(DataSpaces "Enable support for DATASPACES" AUTO)
adios_option(SSC "Enable support for SSC" AUTO)
adios_option(Table "Enable support for Table" AUTO)
adios_option(SST "Enable support for SST" AUTO)
adios_option(BP5 "Enable support for BP5" AUTO)
adios_option(ZeroMQ "Enable support for ZeroMQ" AUTO)
adios_option(HDF5 "Enable support for the HDF5 engine" AUTO)
adios_option(IME "Enable support for DDN IME transport" AUTO)
Expand All @@ -150,7 +151,7 @@ if(ADIOS2_HAVE_MPI)
endif()

set(ADIOS2_CONFIG_OPTS
Blosc BZip2 ZFP SZ MGARD PNG MPI DataMan DAOS Table SSC SST DataSpaces ZeroMQ HDF5 HDF5_VOL IME Python Fortran SysVShMem Profiling Endian_Reverse
Blosc BZip2 ZFP SZ MGARD PNG MPI DataMan DAOS Table SSC SST BP5 DataSpaces ZeroMQ HDF5 HDF5_VOL IME Python Fortran SysVShMem Profiling Endian_Reverse
)
GenerateADIOSHeaderConfig(${ADIOS2_CONFIG_OPTS})
configure_file(
Expand Down
14 changes: 10 additions & 4 deletions cmake/DetectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ if(Python_Interpreter_FOUND)
endif()

# Sst
if(ADIOS2_USE_SST AND NOT MSVC)
if(ADIOS2_USE_SST AND NOT WIN32)
set(ADIOS2_HAVE_SST TRUE)
find_package(LIBFABRIC 1.6)
if(LIBFABRIC_FOUND)
Expand All @@ -329,10 +329,16 @@ if(ADIOS2_USE_SST AND NOT MSVC)
endif()
endif()

# DAOS
find_package(DAOS)
if(DAOS_FOUND)
set(ADIOS2_HAVE_DAOS TRUE)
endif()
if(DAOS_FOUND)
set(ADIOS2_HAVE_DAOS TRUE)
endif()

# BP5
if(ADIOS2_USE_BP5 AND NOT WIN32)
set(ADIOS2_HAVE_BP5 TRUE)
endif()

#SysV IPC
if(UNIX)
Expand Down
19 changes: 19 additions & 0 deletions source/adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ add_library(adios2_core
engine/nullcore/NullCoreWriter.cpp engine/nullcore/NullCoreWriter.tcc
#toolkit
toolkit/format/buffer/Buffer.cpp
toolkit/format/buffer/BufferV.cpp
toolkit/format/buffer/heap/BufferSTL.cpp

toolkit/format/bp/BPBase.cpp toolkit/format/bp/BPBase.tcc
Expand Down Expand Up @@ -128,6 +129,24 @@ if(UNIX)
target_sources(adios2_core PRIVATE toolkit/transport/file/FilePOSIX.cpp)
endif()

if (ADIOS2_HAVE_BP5)
target_sources(adios2_core PRIVATE
engine/bp5/BP5Engine.cpp
engine/bp5/BP5Reader.cpp engine/bp5/BP5Reader.tcc
engine/bp5/BP5Writer.cpp engine/bp5/BP5Writer.tcc
)
endif()

if (ADIOS2_HAVE_BP5 OR ADIOS2_HAVE_SST)
target_sources(adios2_core PRIVATE
toolkit/format/buffer/ffs/BufferFFS.cpp
toolkit/format/bp5/BP5Base.cpp
toolkit/format/bp5/BP5Serializer.cpp
toolkit/format/bp5/BP5Deserializer.cpp toolkit/format/bp5/BP5Deserializer.tcc
)
target_link_libraries(adios2_core PRIVATE ffs::ffs)
endif()

if(ADIOS2_HAVE_DAOS)
target_sources(adios2_core PRIVATE toolkit/transport/file/FileDaos.cpp)
target_link_libraries(adios2_core PRIVATE DAOS::DAOS)
Expand Down
12 changes: 12 additions & 0 deletions source/adios2/core/IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include "adios2/engine/bp3/BP3Writer.h"
#include "adios2/engine/bp4/BP4Reader.h"
#include "adios2/engine/bp4/BP4Writer.h"
#ifdef ADIOS2_HAVE_BP5
#include "adios2/engine/bp5/BP5Reader.h"
#include "adios2/engine/bp5/BP5Writer.h"
#endif
#include "adios2/engine/inline/InlineReader.h"
#include "adios2/engine/inline/InlineWriter.h"
#include "adios2/engine/null/NullEngine.h"
Expand Down Expand Up @@ -65,6 +69,14 @@ std::unordered_map<std::string, IO::EngineFactoryEntry> Factory = {
{IO::MakeEngine<engine::BP3Reader>, IO::MakeEngine<engine::BP3Writer>}},
{"bp4",
{IO::MakeEngine<engine::BP4Reader>, IO::MakeEngine<engine::BP4Writer>}},
{"bp5",
#ifdef ADIOS2_HAVE_BP5
{IO::MakeEngine<engine::BP5Reader>, IO::MakeEngine<engine::BP5Writer>}
#else
IO::NoEngineEntry("ERROR: this version didn't compile with "
"BP5 library, can't use BP5 engine\n")
#endif
},
{"hdfmixer",
#ifdef ADIOS2_HAVE_HDF5
IO_MakeEngine_HDFMixer()
Expand Down
192 changes: 192 additions & 0 deletions source/adios2/engine/bp5/BP5Engine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* BP5Engine.cpp
*
*/

#include "BP5Engine.h"

#include "adios2/common/ADIOSMacros.h"
#include "adios2/common/ADIOSTypes.h" //PathSeparator
#include "adios2/core/IO.h"
#include "adios2/helper/adiosFunctions.h" //CreateDirectory, StringToTimeUnit,

#include <ctime>
#include <iostream>

namespace adios2
{
namespace core
{
namespace engine
{

std::vector<std::string>
BP5Engine::GetBPMetadataFileNames(const std::vector<std::string> &names) const
noexcept
{
std::vector<std::string> metadataFileNames;
metadataFileNames.reserve(names.size());
for (const auto &name : names)
{
metadataFileNames.push_back(GetBPMetadataFileName(name));
}
return metadataFileNames;
}

std::vector<std::string> BP5Engine::GetBPMetaMetadataFileNames(
const std::vector<std::string> &names) const noexcept
{
std::vector<std::string> metaMetadataFileNames;
metaMetadataFileNames.reserve(names.size());
for (const auto &name : names)
{
metaMetadataFileNames.push_back(GetBPMetaMetadataFileName(name));
}
return metaMetadataFileNames;
}

std::string BP5Engine::GetBPMetadataFileName(const std::string &name) const
noexcept
{
const std::string bpName = helper::RemoveTrailingSlash(name);
const size_t index = 0; // global metadata file is generated by rank 0
/* the name of the metadata file is "md.0" */
const std::string bpMetaDataRankName(bpName + PathSeparator + "md." +
std::to_string(index));
return bpMetaDataRankName;
}

std::string BP5Engine::GetBPMetaMetadataFileName(const std::string &name) const
noexcept
{
const std::string bpName = helper::RemoveTrailingSlash(name);
const size_t index = 0; // global metadata file is generated by rank 0
/* the name of the metadata file is "md.0" */
const std::string bpMetaMetaDataRankName(bpName + PathSeparator + "mmd." +
std::to_string(index));
return bpMetaMetaDataRankName;
}

std::vector<std::string> BP5Engine::GetBPMetadataIndexFileNames(
const std::vector<std::string> &names) const noexcept
{
std::vector<std::string> metadataIndexFileNames;
metadataIndexFileNames.reserve(names.size());
for (const auto &name : names)
{
metadataIndexFileNames.push_back(GetBPMetadataIndexFileName(name));
}
return metadataIndexFileNames;
}

std::string BP5Engine::GetBPMetadataIndexFileName(const std::string &name) const
noexcept
{
const std::string bpName = helper::RemoveTrailingSlash(name);
/* the name of the metadata index file is "md.idx" */
const std::string bpMetaDataIndexRankName(bpName + PathSeparator +
"md.idx");
return bpMetaDataIndexRankName;
}

std::string BP5Engine::GetBPSubStreamName(const std::string &name,
const size_t id,
const bool hasSubFiles,
const bool isReader) const noexcept
{
if (!hasSubFiles)
{
return name;
}

const std::string bpName = helper::RemoveTrailingSlash(name);

const size_t index = id;
// isReader ? id
// : m_Aggregator.m_IsActive ? m_Aggregator.m_SubStreamIndex : id;

/* the name of a data file starts with "data." */
const std::string bpRankName(bpName + PathSeparator + "data." +
std::to_string(index));
return bpRankName;
}

std::vector<std::string>
BP5Engine::GetBPSubStreamNames(const std::vector<std::string> &names) const
noexcept
{
std::vector<std::string> bpNames;
bpNames.reserve(names.size());

for (const auto &name : names)
{
bpNames.push_back(
GetBPSubStreamName(name, static_cast<unsigned int>(m_RankMPI)));
}
return bpNames;
}

void BP5Engine::ParseParams(IO &io, struct BP5Params &Params)
{
std::memset(&Params, 0, sizeof(Params));

auto lf_SetBoolParameter = [&](const std::string key, bool &parameter,
bool def) {
auto itKey = io.m_Parameters.find(key);
parameter = def;
if (itKey != io.m_Parameters.end())
{
std::string value = itKey->second;
std::transform(value.begin(), value.end(), value.begin(),
::tolower);
if (value == "yes" || value == "true" || value == "on")
{
parameter = true;
}
else if (value == "no" || value == "false" || value == "off")
{
parameter = false;
}
else
{
throw std::invalid_argument(
"ERROR: Unknown BP5 Boolean parameter \"" + value + "\"");
}
}
};
auto lf_SetIntParameter = [&](const std::string key, int &parameter,
int def) {
auto itKey = io.m_Parameters.find(key);
parameter = def;
if (itKey != io.m_Parameters.end())
{
parameter = std::stoi(itKey->second);
return true;
}
return false;
};

// auto lf_SetStringParameter = [&](const std::string key,
// std::string &parameter, char *def) {
// std::cout << "Set String Param , key = " << key << std::endl;
// auto itKey = io.m_Parameters.find(key);
// if (itKey != io.m_Parameters.end())
// {
// parameter = (itKey->second).c_str();
// return true;
// }
// return false;
// };

#define get_params(Param, Type, Typedecl, Default) \
lf_Set##Type##Parameter(#Param, Params.Param, Default);
BP5_FOREACH_PARAMETER_TYPE_4ARGS(get_params);
#undef get_params
};

} // namespace engine
} // namespace core
} // namespace adios2
Loading

0 comments on commit edb0eec

Please sign in to comment.