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

Find and accept parameters CASE INSENSITIVE #3102

Merged
merged 1 commit into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 55 additions & 18 deletions source/adios2/engine/bp5/BP5Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,20 @@ BP5Engine::GetBPSubStreamNames(const std::vector<std::string> &names,

void BP5Engine::ParseParams(IO &io, struct BP5Params &Params)
{
adios2::Params params_lowercase;
for (auto &p : io.m_Parameters)
{
const std::string key = helper::LowerCase(p.first);
const std::string value = helper::LowerCase(p.second);
params_lowercase[key] = value;
}

auto lf_SetBoolParameter = [&](const std::string key, bool &parameter,
bool def) {
auto itKey = io.m_Parameters.find(key);
const std::string lkey = helper::LowerCase(std::string(key));
auto itKey = params_lowercase.find(lkey);
parameter = def;
if (itKey != io.m_Parameters.end())
if (itKey != params_lowercase.end())
{
std::string value = itKey->second;
std::transform(value.begin(), value.end(), value.begin(),
Expand All @@ -174,9 +183,10 @@ void BP5Engine::ParseParams(IO &io, struct BP5Params &Params)

auto lf_SetFloatParameter = [&](const std::string key, float &parameter,
float def) {
auto itKey = io.m_Parameters.find(key);
const std::string lkey = helper::LowerCase(std::string(key));
auto itKey = params_lowercase.find(lkey);
parameter = def;
if (itKey != io.m_Parameters.end())
if (itKey != params_lowercase.end())
{
std::string value = itKey->second;
parameter =
Expand All @@ -186,9 +196,10 @@ void BP5Engine::ParseParams(IO &io, struct BP5Params &Params)

auto lf_SetSizeBytesParameter = [&](const std::string key,
size_t &parameter, size_t def) {
auto itKey = io.m_Parameters.find(key);
const std::string lkey = helper::LowerCase(std::string(key));
auto itKey = params_lowercase.find(lkey);
parameter = def;
if (itKey != io.m_Parameters.end())
if (itKey != params_lowercase.end())
{
std::string value = itKey->second;
parameter = helper::StringToByteUnits(
Expand All @@ -198,9 +209,10 @@ void BP5Engine::ParseParams(IO &io, struct BP5Params &Params)

auto lf_SetIntParameter = [&](const std::string key, int &parameter,
int def) {
auto itKey = io.m_Parameters.find(key);
const std::string lkey = helper::LowerCase(std::string(key));
auto itKey = params_lowercase.find(lkey);
parameter = def;
if (itKey != io.m_Parameters.end())
if (itKey != params_lowercase.end())
{
parameter = std::stoi(itKey->second);
return true;
Expand All @@ -210,9 +222,10 @@ void BP5Engine::ParseParams(IO &io, struct BP5Params &Params)

auto lf_SetUIntParameter = [&](const std::string key,
unsigned int &parameter, unsigned int def) {
auto itKey = io.m_Parameters.find(key);
const std::string lkey = helper::LowerCase(std::string(key));
auto itKey = params_lowercase.find(lkey);
parameter = def;
if (itKey != io.m_Parameters.end())
if (itKey != params_lowercase.end())
{
unsigned long result = std::stoul(itKey->second);
if (result > std::numeric_limits<unsigned>::max())
Expand All @@ -227,8 +240,10 @@ void BP5Engine::ParseParams(IO &io, struct BP5Params &Params)

auto lf_SetStringParameter = [&](const std::string key,
std::string &parameter, const char *def) {
auto itKey = io.m_Parameters.find(key);
if (itKey != io.m_Parameters.end())
const std::string lkey = helper::LowerCase(std::string(key));
auto itKey = params_lowercase.find(lkey);
parameter = def;
if (itKey != params_lowercase.end())
{
parameter = itKey->second;
return true;
Expand All @@ -238,9 +253,10 @@ void BP5Engine::ParseParams(IO &io, struct BP5Params &Params)

auto lf_SetBufferVTypeParameter = [&](const std::string key, int &parameter,
int def) {
auto itKey = io.m_Parameters.find(key);
const std::string lkey = helper::LowerCase(std::string(key));
auto itKey = params_lowercase.find(lkey);
parameter = def;
if (itKey != io.m_Parameters.end())
if (itKey != params_lowercase.end())
{
std::string value = itKey->second;
std::transform(value.begin(), value.end(), value.begin(),
Expand All @@ -265,9 +281,10 @@ void BP5Engine::ParseParams(IO &io, struct BP5Params &Params)

auto lf_SetAggregationTypeParameter = [&](const std::string key,
int &parameter, int def) {
auto itKey = io.m_Parameters.find(key);
const std::string lkey = helper::LowerCase(std::string(key));
auto itKey = params_lowercase.find(lkey);
parameter = def;
if (itKey != io.m_Parameters.end())
if (itKey != params_lowercase.end())
{
std::string value = itKey->second;
std::transform(value.begin(), value.end(), value.begin(),
Expand Down Expand Up @@ -297,9 +314,10 @@ void BP5Engine::ParseParams(IO &io, struct BP5Params &Params)

auto lf_SetAsyncWriteParameter = [&](const std::string key, int &parameter,
int def) {
auto itKey = io.m_Parameters.find(key);
const std::string lkey = helper::LowerCase(std::string(key));
auto itKey = params_lowercase.find(lkey);
parameter = def;
if (itKey != io.m_Parameters.end())
if (itKey != params_lowercase.end())
{
std::string value = itKey->second;
std::transform(value.begin(), value.end(), value.begin(),
Expand Down Expand Up @@ -331,8 +349,27 @@ void BP5Engine::ParseParams(IO &io, struct BP5Params &Params)

#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

if (Params.verbose > 0 && !m_RankMPI)
{
std::cout << "---------------- " << io.m_EngineType
<< " engine parameters --------------\n";
#define print_params(Param, Type, Typedecl, Default) \
lf_Set##Type##Parameter(#Param, Params.Param, Default); \
if (!m_RankMPI) \
{ \
std::cout << " " << std::string(#Param) << " = " << Params.Param \
<< " default = " << Default << std::endl; \
}

BP5_FOREACH_PARAMETER_TYPE_4ARGS(print_params);
#undef print_params
std::cout << "-----------------------------------------------------"
<< std::endl;
}
};

} // namespace engine
Expand Down
6 changes: 3 additions & 3 deletions source/adios2/engine/bp5/BP5Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ class BP5Engine
MACRO(BeginStepPollingFrequencySecs, Float, float, 1.0f) \
MACRO(StreamReader, Bool, bool, false) \
MACRO(BurstBufferDrain, Bool, bool, true) \
MACRO(BurstBufferPath, String, std::string, (char *)(intptr_t)0) \
MACRO(BurstBufferPath, String, std::string, "") \
MACRO(NodeLocal, Bool, bool, false) \
MACRO(verbose, Int, int, 0) \
MACRO(CollectiveMetadata, Bool, bool, true) \
MACRO(NumAggregators, UInt, unsigned int, 0) \
MACRO(AggregatorRatio, UInt, unsigned int, 0) \
MACRO(NumSubFiles, UInt, unsigned int, 999999) \
MACRO(NumSubFiles, UInt, unsigned int, 0) \
MACRO(StripeSize, UInt, unsigned int, 4096) \
MACRO(DirectIO, Bool, bool, false) \
MACRO(DirectIOAlignOffset, UInt, unsigned int, 512) \
Expand All @@ -148,7 +148,7 @@ class BP5Engine
MACRO(MaxShmSize, SizeBytes, size_t, DefaultMaxShmSize) \
MACRO(BufferVType, BufferVType, int, (int)BufferVType::ChunkVType) \
MACRO(AppendAfterSteps, Int, int, INT_MAX) \
MACRO(SelectSteps, String, std::string, (char *)(intptr_t)0) \
MACRO(SelectSteps, String, std::string, "") \
MACRO(ReaderShortCircuitReads, Bool, bool, false)

struct BP5Params
Expand Down