Skip to content
Snippets Groups Projects
Commit 78c57400 authored by Atkins, Charles Vernon's avatar Atkins, Charles Vernon
Browse files

Auto clang-tidy fixes

parent 2ef64313
No related branches found
No related tags found
1 merge request!22Fix clang tidy issues round2
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "ADIOS_CPP.h" #include "ADIOS_CPP.h"
int main(int argc, char *argv[]) int main(int /*argc*/, char ** /*argv*/)
{ {
const bool adiosDebug = true; const bool adiosDebug = true;
adios::ADIOS adios(adios::Verbose::WARN, adiosDebug); adios::ADIOS adios(adios::Verbose::WARN, adiosDebug);
...@@ -55,7 +55,9 @@ int main(int argc, char *argv[]) ...@@ -55,7 +55,9 @@ int main(int argc, char *argv[])
adios::IOMode::COLLECTIVE); adios::IOMode::COLLECTIVE);
if (bpFileWriter == nullptr) if (bpFileWriter == nullptr)
{
throw std::ios_base::failure("ERROR: couldn't create bpWriter at Open\n"); throw std::ios_base::failure("ERROR: couldn't create bpWriter at Open\n");
}
bpFileWriter->Write<double>( bpFileWriter->Write<double>(
ioMyDoubles, myDoubles.data()); // Base class Engine own the Write<T> ioMyDoubles, myDoubles.data()); // Base class Engine own the Write<T>
......
...@@ -21,8 +21,8 @@ namespace adios ...@@ -21,8 +21,8 @@ namespace adios
BPFileWriter::BPFileWriter(ADIOS &adios, const std::string name, BPFileWriter::BPFileWriter(ADIOS &adios, const std::string name,
const std::string accessMode, MPI_Comm mpiComm, const std::string accessMode, MPI_Comm mpiComm,
const Method &method, const IOMode iomode, const Method &method, const IOMode /*iomode*/,
const float timeout_sec, const bool debugMode, const float /*timeout_sec*/, const bool debugMode,
const unsigned int nthreads) const unsigned int nthreads)
: Engine(adios, "BPFileWriter", name, accessMode, mpiComm, method, debugMode, : Engine(adios, "BPFileWriter", name, accessMode, mpiComm, method, debugMode,
nthreads, " BPFileWriter constructor (or call to ADIOS Open).\n"), nthreads, " BPFileWriter constructor (or call to ADIOS Open).\n"),
...@@ -34,7 +34,7 @@ BPFileWriter::BPFileWriter(ADIOS &adios, const std::string name, ...@@ -34,7 +34,7 @@ BPFileWriter::BPFileWriter(ADIOS &adios, const std::string name,
Init(); Init();
} }
BPFileWriter::~BPFileWriter() {} BPFileWriter::~BPFileWriter() = default;
void BPFileWriter::Init() void BPFileWriter::Init()
{ {
...@@ -133,7 +133,10 @@ void BPFileWriter::Write(Variable<std::complex<long double>> &variable, ...@@ -133,7 +133,10 @@ void BPFileWriter::Write(Variable<std::complex<long double>> &variable,
WriteVariableCommon(variable, values); WriteVariableCommon(variable, values);
} }
void BPFileWriter::Write(VariableCompound &variable, const void *values) {} void BPFileWriter::Write(VariableCompound & /*variable*/,
const void * /*values*/)
{
}
// String version // String version
void BPFileWriter::Write(const std::string variableName, const char *values) void BPFileWriter::Write(const std::string variableName, const char *values)
...@@ -232,12 +235,12 @@ void BPFileWriter::Write(const std::string variableName, ...@@ -232,12 +235,12 @@ void BPFileWriter::Write(const std::string variableName,
m_ADIOS.GetVariable<std::complex<long double>>(variableName), values); m_ADIOS.GetVariable<std::complex<long double>>(variableName), values);
} }
void BPFileWriter::Write(const std::string variableName, void BPFileWriter::Write(const std::string /*variableName*/,
const void *values) // Compound type const void * /*values*/) // Compound type
{ {
} }
void BPFileWriter::Advance(float timeout_sec) void BPFileWriter::Advance(float /*timeout_sec*/)
{ {
m_BP1Writer.Advance(m_MetadataSet, m_Buffer); m_BP1Writer.Advance(m_MetadataSet, m_Buffer);
} }
...@@ -247,10 +250,11 @@ void BPFileWriter::Close(const int transportIndex) ...@@ -247,10 +250,11 @@ void BPFileWriter::Close(const int transportIndex)
CheckTransportIndex(transportIndex); CheckTransportIndex(transportIndex);
if (transportIndex == -1) if (transportIndex == -1)
{ {
for (auto &transport : for (auto &transport : m_Transports)
m_Transports) // by reference or value or it doesn't matter? { // by reference or value or it doesn't matter?
m_BP1Writer.Close(m_MetadataSet, m_Buffer, *transport, m_IsFirstClose, m_BP1Writer.Close(m_MetadataSet, m_Buffer, *transport, m_IsFirstClose,
false); // false: not using aggregation for now false); // false: not using aggregation for now
}
} }
else else
{ {
...@@ -292,9 +296,11 @@ void BPFileWriter::InitParameters() ...@@ -292,9 +296,11 @@ void BPFileWriter::InitParameters()
if (m_DebugMode == true) if (m_DebugMode == true)
{ {
if (growthFactor == 1.f) if (growthFactor == 1.f)
{
throw std::invalid_argument( throw std::invalid_argument(
"ERROR: buffer_growth argument can't be less of equal than 1, in " + "ERROR: buffer_growth argument can't be less of equal than 1, in " +
m_EndMessage + "\n"); m_EndMessage + "\n");
}
} }
m_BP1Writer.m_GrowthFactor = growthFactor; m_BP1Writer.m_GrowthFactor = growthFactor;
...@@ -307,9 +313,11 @@ void BPFileWriter::InitParameters() ...@@ -307,9 +313,11 @@ void BPFileWriter::InitParameters()
if (m_DebugMode == true) if (m_DebugMode == true)
{ {
if (m_GrowthFactor <= 1.f) if (m_GrowthFactor <= 1.f)
{
throw std::invalid_argument("ERROR: Method buffer_growth argument " throw std::invalid_argument("ERROR: Method buffer_growth argument "
"can't be less of equal than 1, in " + "can't be less of equal than 1, in " +
m_EndMessage + "\n"); m_EndMessage + "\n");
}
} }
m_MaxBufferSize = std::stoul(itMaxBufferSize->second) * m_MaxBufferSize = std::stoul(itMaxBufferSize->second) *
...@@ -323,9 +331,11 @@ void BPFileWriter::InitParameters() ...@@ -323,9 +331,11 @@ void BPFileWriter::InitParameters()
if (m_DebugMode == true) if (m_DebugMode == true)
{ {
if (verbosity < 0 || verbosity > 5) if (verbosity < 0 || verbosity > 5)
{
throw std::invalid_argument("ERROR: Method verbose argument must be an " throw std::invalid_argument("ERROR: Method verbose argument must be an "
"integer in the range [0,5], in call to " "integer in the range [0,5], in call to "
"Open or Engine constructor\n"); "Open or Engine constructor\n");
}
} }
m_BP1Writer.m_Verbosity = verbosity; m_BP1Writer.m_Verbosity = verbosity;
} }
...@@ -336,25 +346,33 @@ void BPFileWriter::InitParameters() ...@@ -336,25 +346,33 @@ void BPFileWriter::InitParameters()
auto &profiler = m_MetadataSet.Log; auto &profiler = m_MetadataSet.Log;
if (itProfile->second == "mus" || itProfile->second == "microseconds") if (itProfile->second == "mus" || itProfile->second == "microseconds")
{
profiler.m_Timers.emplace_back("buffering", Support::Resolutions::mus); profiler.m_Timers.emplace_back("buffering", Support::Resolutions::mus);
}
else if (itProfile->second == "ms" || itProfile->second == "milliseconds") else if (itProfile->second == "ms" || itProfile->second == "milliseconds")
{
profiler.m_Timers.emplace_back("buffering", Support::Resolutions::ms); profiler.m_Timers.emplace_back("buffering", Support::Resolutions::ms);
}
else if (itProfile->second == "s" || itProfile->second == "seconds") else if (itProfile->second == "s" || itProfile->second == "seconds")
{
profiler.m_Timers.emplace_back("buffering", Support::Resolutions::s); profiler.m_Timers.emplace_back("buffering", Support::Resolutions::s);
}
else if (itProfile->second == "min" || itProfile->second == "minutes") else if (itProfile->second == "min" || itProfile->second == "minutes")
{
profiler.m_Timers.emplace_back("buffering", Support::Resolutions::m); profiler.m_Timers.emplace_back("buffering", Support::Resolutions::m);
}
else if (itProfile->second == "h" || itProfile->second == "hours") else if (itProfile->second == "h" || itProfile->second == "hours")
{
profiler.m_Timers.emplace_back("buffering", Support::Resolutions::h); profiler.m_Timers.emplace_back("buffering", Support::Resolutions::h);
}
else else
{ {
if (m_DebugMode == true) if (m_DebugMode == true)
{
throw std::invalid_argument("ERROR: Method profile_buffering_units " throw std::invalid_argument("ERROR: Method profile_buffering_units "
"argument must be mus, ms, s, min or h, in " "argument must be mus, ms, s, min or h, in "
"call to Open or Engine constructor\n"); "call to Open or Engine constructor\n");
}
} }
profiler.m_IsActive = true; profiler.m_IsActive = true;
...@@ -383,26 +401,33 @@ void BPFileWriter::InitTransports() ...@@ -383,26 +401,33 @@ void BPFileWriter::InitTransports()
if (itProfile != parameters.end()) if (itProfile != parameters.end())
{ {
if (itProfile->second == "mus" || itProfile->second == "microseconds") if (itProfile->second == "mus" || itProfile->second == "microseconds")
{
resolution = Support::Resolutions::mus; resolution = Support::Resolutions::mus;
}
else if (itProfile->second == "ms" || itProfile->second == "milliseconds") else if (itProfile->second == "ms" || itProfile->second == "milliseconds")
{
resolution = Support::Resolutions::ms; resolution = Support::Resolutions::ms;
}
else if (itProfile->second == "s" || itProfile->second == "seconds") else if (itProfile->second == "s" || itProfile->second == "seconds")
{
resolution = Support::Resolutions::s; resolution = Support::Resolutions::s;
}
else if (itProfile->second == "min" || itProfile->second == "minutes") else if (itProfile->second == "min" || itProfile->second == "minutes")
{
resolution = Support::Resolutions::m; resolution = Support::Resolutions::m;
}
else if (itProfile->second == "h" || itProfile->second == "hours") else if (itProfile->second == "h" || itProfile->second == "hours")
{
resolution = Support::Resolutions::h; resolution = Support::Resolutions::h;
}
else else
{ {
if (m_DebugMode == true) if (m_DebugMode == true)
{
throw std::invalid_argument("ERROR: Transport profile_units argument " throw std::invalid_argument("ERROR: Transport profile_units argument "
"must be mus, ms, s, min or h " + "must be mus, ms, s, min or h " +
m_EndMessage); m_EndMessage);
}
} }
doProfiling = true; doProfiling = true;
} }
...@@ -418,7 +443,9 @@ void BPFileWriter::InitTransports() ...@@ -418,7 +443,9 @@ void BPFileWriter::InitTransports()
auto file = auto file =
std::make_shared<transport::FileDescriptor>(m_MPIComm, m_DebugMode); std::make_shared<transport::FileDescriptor>(m_MPIComm, m_DebugMode);
if (doProfiling == true) if (doProfiling == true)
{
file->InitProfiler(m_AccessMode, resolution); file->InitProfiler(m_AccessMode, resolution);
}
m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file); m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file);
m_Transports.push_back(std::move(file)); m_Transports.push_back(std::move(file));
...@@ -428,7 +455,9 @@ void BPFileWriter::InitTransports() ...@@ -428,7 +455,9 @@ void BPFileWriter::InitTransports()
auto file = auto file =
std::make_shared<transport::FilePointer>(m_MPIComm, m_DebugMode); std::make_shared<transport::FilePointer>(m_MPIComm, m_DebugMode);
if (doProfiling == true) if (doProfiling == true)
{
file->InitProfiler(m_AccessMode, resolution); file->InitProfiler(m_AccessMode, resolution);
}
m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file); m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file);
m_Transports.push_back(std::move(file)); m_Transports.push_back(std::move(file));
...@@ -440,7 +469,9 @@ void BPFileWriter::InitTransports() ...@@ -440,7 +469,9 @@ void BPFileWriter::InitTransports()
std::make_shared<transport::FStream>(m_MPIComm, m_DebugMode); std::make_shared<transport::FStream>(m_MPIComm, m_DebugMode);
if (doProfiling == true) if (doProfiling == true)
{
file->InitProfiler(m_AccessMode, resolution); file->InitProfiler(m_AccessMode, resolution);
}
m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file); m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file);
m_Transports.push_back(std::move(file)); m_Transports.push_back(std::move(file));
...@@ -451,17 +482,21 @@ void BPFileWriter::InitTransports() ...@@ -451,17 +482,21 @@ void BPFileWriter::InitTransports()
else else
{ {
if (m_DebugMode == true) if (m_DebugMode == true)
{
throw std::invalid_argument( throw std::invalid_argument(
"ERROR: file transport library " + itLibrary->second + "ERROR: file transport library " + itLibrary->second +
" not supported, in " + m_Name + m_EndMessage); " not supported, in " + m_Name + m_EndMessage);
}
} }
} }
else else
{ {
if (m_DebugMode == true) if (m_DebugMode == true)
{
throw std::invalid_argument("ERROR: transport " + itTransport->second + throw std::invalid_argument("ERROR: transport " + itTransport->second +
" (you mean File?) not supported, in " + " (you mean File?) not supported, in " +
m_Name + m_EndMessage); m_Name + m_EndMessage);
}
} }
} }
} }
...@@ -469,7 +504,9 @@ void BPFileWriter::InitTransports() ...@@ -469,7 +504,9 @@ void BPFileWriter::InitTransports()
void BPFileWriter::InitProcessGroup() void BPFileWriter::InitProcessGroup()
{ {
if (m_MetadataSet.Log.m_IsActive == true) if (m_MetadataSet.Log.m_IsActive == true)
{
m_MetadataSet.Log.m_Timers[0].SetInitialTime(); m_MetadataSet.Log.m_Timers[0].SetInitialTime();
}
if (m_AccessMode == "a") if (m_AccessMode == "a")
{ {
...@@ -480,7 +517,9 @@ void BPFileWriter::InitProcessGroup() ...@@ -480,7 +517,9 @@ void BPFileWriter::InitProcessGroup()
WriteProcessGroupIndex(); WriteProcessGroupIndex();
if (m_MetadataSet.Log.m_IsActive == true) if (m_MetadataSet.Log.m_IsActive == true)
{
m_MetadataSet.Log.m_Timers[0].SetTime(); m_MetadataSet.Log.m_Timers[0].SetTime();
}
} }
void BPFileWriter::WriteProcessGroupIndex() void BPFileWriter::WriteProcessGroupIndex()
......
...@@ -21,10 +21,13 @@ std::string BP1::GetDirectoryName(const std::string name) const noexcept ...@@ -21,10 +21,13 @@ std::string BP1::GetDirectoryName(const std::string name) const noexcept
std::string directory; std::string directory;
if (name.find(".bp") == name.size() - 3) if (name.find(".bp") == name.size() - 3)
{
directory = name; directory = name;
}
else else
{
directory = name + ".bp"; directory = name + ".bp";
}
return directory; return directory;
} }
...@@ -48,15 +51,25 @@ std::vector<std::uint8_t> BP1::GetMethodIDs( ...@@ -48,15 +51,25 @@ std::vector<std::uint8_t> BP1::GetMethodIDs(
auto lf_GetMethodID = [](const std::string method) -> std::uint8_t { auto lf_GetMethodID = [](const std::string method) -> std::uint8_t {
int id = METHOD_UNKNOWN; int id = METHOD_UNKNOWN;
if (method == "NULL") if (method == "NULL")
{
id = METHOD_NULL; id = METHOD_NULL;
}
else if (method == "POSIX") else if (method == "POSIX")
{
id = METHOD_POSIX; id = METHOD_POSIX;
}
else if (method == "FStream") else if (method == "FStream")
{
id = METHOD_FSTREAM; id = METHOD_FSTREAM;
}
else if (method == "File") else if (method == "File")
{
id = METHOD_FILE; id = METHOD_FILE;
}
else if (method == "MPI") else if (method == "MPI")
{
id = METHOD_MPI; id = METHOD_MPI;
}
return id; return id;
}; };
...@@ -65,7 +78,9 @@ std::vector<std::uint8_t> BP1::GetMethodIDs( ...@@ -65,7 +78,9 @@ std::vector<std::uint8_t> BP1::GetMethodIDs(
methodIDs.reserve(transports.size()); methodIDs.reserve(transports.size());
for (const auto &transport : transports) for (const auto &transport : transports)
{
methodIDs.push_back(lf_GetMethodID(transport->m_Type)); methodIDs.push_back(lf_GetMethodID(transport->m_Type));
}
return methodIDs; return methodIDs;
} }
......
...@@ -28,7 +28,7 @@ BP1Aggregator::BP1Aggregator(MPI_Comm mpiComm, const bool debugMode) ...@@ -28,7 +28,7 @@ BP1Aggregator::BP1Aggregator(MPI_Comm mpiComm, const bool debugMode)
MPI_Comm_size(m_MPIComm, &m_SizeMPI); MPI_Comm_size(m_MPIComm, &m_SizeMPI);
} }
BP1Aggregator::~BP1Aggregator() {} BP1Aggregator::~BP1Aggregator() = default;
void BP1Aggregator::WriteProfilingLog(const std::string fileName, void BP1Aggregator::WriteProfilingLog(const std::string fileName,
const std::string &rankLog) const std::string &rankLog)
...@@ -44,8 +44,10 @@ void BP1Aggregator::WriteProfilingLog(const std::string fileName, ...@@ -44,8 +44,10 @@ void BP1Aggregator::WriteProfilingLog(const std::string fileName,
// first receive sizes // first receive sizes
for (unsigned int i = 1; i < sizeMPI; ++i) for (unsigned int i = 1; i < sizeMPI; ++i)
{
MPI_Irecv(&rankLogsSizes[i - 1], 1, MPI_INT, i, 0, m_MPIComm, MPI_Irecv(&rankLogsSizes[i - 1], 1, MPI_INT, i, 0, m_MPIComm,
&requests[i]); &requests[i]);
}
for (unsigned int i = 1; i < sizeMPI; ++i) for (unsigned int i = 1; i < sizeMPI; ++i)
{ {
...@@ -53,20 +55,26 @@ void BP1Aggregator::WriteProfilingLog(const std::string fileName, ...@@ -53,20 +55,26 @@ void BP1Aggregator::WriteProfilingLog(const std::string fileName,
if (m_DebugMode == true) if (m_DebugMode == true)
{ {
if (rankLogsSizes[i - 1] == -1) if (rankLogsSizes[i - 1] == -1)
{
throw std::runtime_error("ERROR: couldn't get size from rank " + throw std::runtime_error("ERROR: couldn't get size from rank " +
std::to_string(i) + std::to_string(i) +
", in ADIOS aggregator for Profiling.log\n"); ", in ADIOS aggregator for Profiling.log\n");
}
} }
rankLogs[i - 1].resize(rankLogsSizes[i - 1]); // allocate with zeros rankLogs[i - 1].resize(rankLogsSizes[i - 1]); // allocate with zeros
} }
// receive rankLog from other ranks // receive rankLog from other ranks
for (unsigned int i = 1; i < sizeMPI; ++i) for (unsigned int i = 1; i < sizeMPI; ++i)
{
MPI_Irecv(rankLogs[i - 1].data(), rankLogsSizes[i - 1], MPI_CHAR, i, 1, MPI_Irecv(rankLogs[i - 1].data(), rankLogsSizes[i - 1], MPI_CHAR, i, 1,
m_MPIComm, &requests[i]); m_MPIComm, &requests[i]);
}
for (unsigned int i = 1; i < sizeMPI; ++i) for (unsigned int i = 1; i < sizeMPI; ++i)
{
MPI_Wait(&requests[i], &statuses[i]); MPI_Wait(&requests[i], &statuses[i]);
}
// write file // write file
std::string logFile("log = { \n"); std::string logFile("log = { \n");
......
...@@ -121,17 +121,23 @@ void BP1Writer::Close(BP1MetadataSet &metadataSet, capsule::STLVector &heap, ...@@ -121,17 +121,23 @@ void BP1Writer::Close(BP1MetadataSet &metadataSet, capsule::STLVector &heap,
const bool doAggregation) const noexcept const bool doAggregation) const noexcept
{ {
if (metadataSet.Log.m_IsActive == true) if (metadataSet.Log.m_IsActive == true)
{
metadataSet.Log.m_Timers[0].SetInitialTime(); metadataSet.Log.m_Timers[0].SetInitialTime();
}
if (isFirstClose == true) if (isFirstClose == true)
{ {
if (metadataSet.DataPGIsOpen == true) if (metadataSet.DataPGIsOpen == true)
{
FlattenData(metadataSet, heap); FlattenData(metadataSet, heap);
}
FlattenMetadata(metadataSet, heap); FlattenMetadata(metadataSet, heap);
if (metadataSet.Log.m_IsActive == true) if (metadataSet.Log.m_IsActive == true)
{
metadataSet.Log.m_Timers[0].SetInitialTime(); metadataSet.Log.m_Timers[0].SetInitialTime();
}
if (doAggregation == true) // N-to-M where 1 <= M <= N-1, might need a new if (doAggregation == true) // N-to-M where 1 <= M <= N-1, might need a new
// Log metadataSet.Log.m_Timers just for // Log metadataSet.Log.m_Timers just for
...@@ -177,7 +183,9 @@ std::string BP1Writer::GetRankProfilingLog( ...@@ -177,7 +183,9 @@ std::string BP1Writer::GetRankProfilingLog(
rankLog += "'lib': " + transports[t]->m_Type + ", "; rankLog += "'lib': " + transports[t]->m_Type + ", ";
for (unsigned int i = 0; i < 3; ++i) for (unsigned int i = 0; i < 3; ++i)
{
lf_WriterTimer(rankLog, timers[i]); lf_WriterTimer(rankLog, timers[i]);
}
rankLog += "}, "; rankLog += "}, ";
} }
...@@ -391,7 +399,9 @@ void BP1Writer::FlattenMetadata(BP1MetadataSet &metadataSet, ...@@ -391,7 +399,9 @@ void BP1Writer::FlattenMetadata(BP1MetadataSet &metadataSet,
heap.m_DataAbsolutePosition += footerSize; heap.m_DataAbsolutePosition += footerSize;
if (metadataSet.Log.m_IsActive == true) if (metadataSet.Log.m_IsActive == true)
{
metadataSet.Log.m_TotalBytes.push_back(heap.m_DataAbsolutePosition); metadataSet.Log.m_TotalBytes.push_back(heap.m_DataAbsolutePosition);
}
} }
} // end namespace format } // end namespace format
......
...@@ -37,10 +37,12 @@ void DumpFileToString(const std::string fileName, std::string &fileContent) ...@@ -37,10 +37,12 @@ void DumpFileToString(const std::string fileName, std::string &fileContent)
{ {
std::ifstream fileStream(fileName); std::ifstream fileStream(fileName);
if (fileStream.good() == false) // check file if (fileStream.good() == false)
{ // check file
throw std::ios_base::failure( throw std::ios_base::failure(
"ERROR: file " + fileName + "ERROR: file " + fileName +
" could not be opened. Check permissions or file existence\n"); " could not be opened. Check permissions or file existence\n");
}
std::ostringstream fileSS; std::ostringstream fileSS;
fileSS << fileStream.rdbuf(); fileSS << fileStream.rdbuf();
...@@ -48,7 +50,9 @@ void DumpFileToString(const std::string fileName, std::string &fileContent) ...@@ -48,7 +50,9 @@ void DumpFileToString(const std::string fileName, std::string &fileContent)
fileContent = fileSS.str(); // convert to string and check fileContent = fileSS.str(); // convert to string and check
if (fileContent.empty()) if (fileContent.empty())
{
throw std::invalid_argument("ERROR: file " + fileName + " is empty\n"); throw std::invalid_argument("ERROR: file " + fileName + " is empty\n");
}
} }
void GetSubString(const std::string initialTag, const std::string finalTag, void GetSubString(const std::string initialTag, const std::string finalTag,
...@@ -101,25 +105,35 @@ void GetSubString(const std::string initialTag, const std::string finalTag, ...@@ -101,25 +105,35 @@ void GetSubString(const std::string initialTag, const std::string finalTag,
(singleQuotePosition == content.npos && end < doubleQuotePosition) || (singleQuotePosition == content.npos && end < doubleQuotePosition) ||
(doubleQuotePosition == content.npos && end < singleQuotePosition) || (doubleQuotePosition == content.npos && end < singleQuotePosition) ||
(end < singleQuotePosition && end < doubleQuotePosition)) (end < singleQuotePosition && end < doubleQuotePosition))
{
break; break;
}
// find the closing corresponding quote // find the closing corresponding quote
std::string::size_type closingQuotePosition; std::string::size_type closingQuotePosition;
if (singleQuotePosition == content.npos) // no ' anywhere if (singleQuotePosition == content.npos)
{ // no ' anywhere
lf_SetPositions('\"', doubleQuotePosition, content, currentPosition, lf_SetPositions('\"', doubleQuotePosition, content, currentPosition,
closingQuotePosition); closingQuotePosition);
else if (doubleQuotePosition == content.npos) // no " anywhere }
else if (doubleQuotePosition == content.npos)
{ // no " anywhere
lf_SetPositions('\'', singleQuotePosition, content, currentPosition, lf_SetPositions('\'', singleQuotePosition, content, currentPosition,
closingQuotePosition); closingQuotePosition);
}
else else
{ {
if (singleQuotePosition < doubleQuotePosition) if (singleQuotePosition < doubleQuotePosition)
{
lf_SetPositions('\'', singleQuotePosition, content, currentPosition, lf_SetPositions('\'', singleQuotePosition, content, currentPosition,
closingQuotePosition); closingQuotePosition);
else // find the closing " }
else
{ // find the closing "
lf_SetPositions('\"', doubleQuotePosition, content, currentPosition, lf_SetPositions('\"', doubleQuotePosition, content, currentPosition,
closingQuotePosition); closingQuotePosition);
}
} }
if (closingQuotePosition == if (closingQuotePosition ==
...@@ -132,7 +146,9 @@ void GetSubString(const std::string initialTag, const std::string finalTag, ...@@ -132,7 +146,9 @@ void GetSubString(const std::string initialTag, const std::string finalTag,
currentPosition = closingQuotePosition + 1; currentPosition = closingQuotePosition + 1;
if (closingQuotePosition < end) if (closingQuotePosition < end)
{
continue; continue;
}
// if this point is reached it means it's a value inside " " or ' ', move to // if this point is reached it means it's a value inside " " or ' ', move to
// the next end // the next end
...@@ -151,8 +167,10 @@ void GetQuotedValue(const char quote, ...@@ -151,8 +167,10 @@ void GetQuotedValue(const char quote,
auto nextQuotePosition = currentTag.find(quote); auto nextQuotePosition = currentTag.find(quote);
if (nextQuotePosition == currentTag.npos) if (nextQuotePosition == currentTag.npos)
{
throw std::invalid_argument("ERROR: Invalid attribute in..." + currentTag + throw std::invalid_argument("ERROR: Invalid attribute in..." + currentTag +
"...check XML file\n"); "...check XML file\n");
}
value = currentTag.substr(0, nextQuotePosition); value = currentTag.substr(0, nextQuotePosition);
currentTag = currentTag.substr(nextQuotePosition + 1); currentTag = currentTag.substr(nextQuotePosition + 1);
...@@ -201,8 +219,10 @@ void GetPairsFromTag( ...@@ -201,8 +219,10 @@ void GetPairsFromTag(
">"); // check for closing tagName ">"); // check for closing tagName
if (fileContent.find(closingTagName) == fileContent.npos) if (fileContent.find(closingTagName) == fileContent.npos)
{
throw std::invalid_argument("ERROR: closing tag " + closingTagName + throw std::invalid_argument("ERROR: closing tag " + closingTagName +
" missing, check XML file\n"); " missing, check XML file\n");
}
GetPairs(tag, pairs); GetPairs(tag, pairs);
} }
...@@ -411,7 +431,9 @@ std::size_t GetTotalSize(const std::vector<std::size_t> &dimensions) ...@@ -411,7 +431,9 @@ std::size_t GetTotalSize(const std::vector<std::size_t> &dimensions)
std::size_t product = 1; std::size_t product = 1;
for (const auto dimension : dimensions) for (const auto dimension : dimensions)
{
product *= dimension; product *= dimension;
}
return product; return product;
} }
...@@ -420,13 +442,17 @@ void CreateDirectory(const std::string fullPath) noexcept ...@@ -420,13 +442,17 @@ void CreateDirectory(const std::string fullPath) noexcept
{ {
auto lf_Mkdir = [](const std::string directory, struct stat &st) { auto lf_Mkdir = [](const std::string directory, struct stat &st) {
if (stat(directory.c_str(), &st) == -1) if (stat(directory.c_str(), &st) == -1)
{
mkdir(directory.c_str(), 0777); mkdir(directory.c_str(), 0777);
}
}; };
auto directoryPosition = fullPath.find("/"); auto directoryPosition = fullPath.find("/");
if (fullPath[0] == '/' || fullPath[0] == '.') // find the second '/' if (fullPath[0] == '/' || fullPath[0] == '.')
{ // find the second '/'
directoryPosition = fullPath.find("/", directoryPosition + 1); directoryPosition = fullPath.find("/", directoryPosition + 1);
}
struct stat st = {0}; struct stat st = {0};
if (directoryPosition == fullPath.npos) // no subdirectories if (directoryPosition == fullPath.npos) // no subdirectories
...@@ -464,9 +490,11 @@ void SetTransformsHelper(const std::vector<std::string> &transformNames, ...@@ -464,9 +490,11 @@ void SetTransformsHelper(const std::vector<std::string> &transformNames,
if (debugMode == true) if (debugMode == true)
{ {
if (colonPosition == transformName.size() - 1) if (colonPosition == transformName.size() - 1)
{
throw std::invalid_argument("ERROR: wrong format for transform " + throw std::invalid_argument("ERROR: wrong format for transform " +
transformName + transformName +
", in call to SetTransform\n"); ", in call to SetTransform\n");
}
} }
transformMethod = transformName.substr(0, colonPosition); transformMethod = transformName.substr(0, colonPosition);
...@@ -528,14 +556,18 @@ BuildParametersMap(const std::vector<std::string> &parameters, ...@@ -528,14 +556,18 @@ BuildParametersMap(const std::vector<std::string> &parameters,
if (debugMode == true) if (debugMode == true)
{ {
if (equalPosition == parameter.npos) if (equalPosition == parameter.npos)
{
throw std::invalid_argument("ERROR: wrong format for parameter " + throw std::invalid_argument("ERROR: wrong format for parameter " +
parameter + parameter +
", format must be field=value \n"); ", format must be field=value \n");
}
if (equalPosition == parameter.size() - 1) if (equalPosition == parameter.size() - 1)
{
throw std::invalid_argument("ERROR: empty value in parameter " + throw std::invalid_argument("ERROR: empty value in parameter " +
parameter + parameter +
", format must be field=value \n"); ", format must be field=value \n");
}
} }
field = parameter.substr(0, equalPosition); field = parameter.substr(0, equalPosition);
...@@ -553,8 +585,10 @@ BuildParametersMap(const std::vector<std::string> &parameters, ...@@ -553,8 +585,10 @@ BuildParametersMap(const std::vector<std::string> &parameters,
if (debugMode == true) if (debugMode == true)
{ {
if (parametersOutput.count(field) == 1) if (parametersOutput.count(field) == 1)
{
throw std::invalid_argument("ERROR: parameter " + field + throw std::invalid_argument("ERROR: parameter " + field +
" already exists, must be unique\n"); " already exists, must be unique\n");
}
} }
parametersOutput[field] = value; parametersOutput[field] = value;
...@@ -567,7 +601,9 @@ std::vector<int> CSVToVectorInt(const std::string csv) ...@@ -567,7 +601,9 @@ std::vector<int> CSVToVectorInt(const std::string csv)
{ {
std::vector<int> numbers; std::vector<int> numbers;
if (csv.empty()) if (csv.empty())
{
return numbers; return numbers;
}
if (csv.find(",") == csv.npos) // check if no commas, one int if (csv.find(",") == csv.npos) // check if no commas, one int
{ {
...@@ -600,7 +636,9 @@ bool CheckBufferAllocation(const std::size_t newSize, const float growthFactor, ...@@ -600,7 +636,9 @@ bool CheckBufferAllocation(const std::size_t newSize, const float growthFactor,
bool doTransportsFlush = (requiredDataSize > maxBufferSize) ? true : false; bool doTransportsFlush = (requiredDataSize > maxBufferSize) ? true : false;
if (GrowBuffer(requiredDataSize, growthFactor, buffer) == -1) if (GrowBuffer(requiredDataSize, growthFactor, buffer) == -1)
{
doTransportsFlush = true; doTransportsFlush = true;
}
return doTransportsFlush; return doTransportsFlush;
} }
...@@ -643,4 +681,4 @@ bool IsLittleEndian() noexcept ...@@ -643,4 +681,4 @@ bool IsLittleEndian() noexcept
return *reinterpret_cast<std::uint8_t *>(&hexa) != 0x12; return *reinterpret_cast<std::uint8_t *>(&hexa) != 0x12;
} }
} // end namespace } // namespace adios
...@@ -17,15 +17,15 @@ namespace transform ...@@ -17,15 +17,15 @@ namespace transform
BZIP2::BZIP2() : Transform("bzip2") {} BZIP2::BZIP2() : Transform("bzip2") {}
BZIP2::~BZIP2() {} BZIP2::~BZIP2() = default;
void BZIP2::Compress(const std::vector<char> &bufferIn, void BZIP2::Compress(const std::vector<char> & /*bufferIn*/,
std::vector<char> &bufferOut) std::vector<char> & /*bufferOut*/)
{ {
} }
void BZIP2::Decompress(const std::vector<char> &bufferIn, void BZIP2::Decompress(const std::vector<char> & /*bufferIn*/,
std::vector<char> &bufferOut) std::vector<char> & /*bufferOut*/)
{ {
} }
......
...@@ -45,87 +45,115 @@ void FileDescriptor::Open(const std::string name, const std::string accessMode) ...@@ -45,87 +45,115 @@ void FileDescriptor::Open(const std::string name, const std::string accessMode)
if (accessMode == "w" || accessMode == "write") if (accessMode == "w" || accessMode == "write")
{ {
if (m_Profiler.m_IsActive == true) if (m_Profiler.m_IsActive == true)
{
m_Profiler.m_Timers[0].SetInitialTime(); m_Profiler.m_Timers[0].SetInitialTime();
}
m_FileDescriptor = open(m_Name.c_str(), O_WRONLY | O_CREAT, 0777); m_FileDescriptor = open(m_Name.c_str(), O_WRONLY | O_CREAT, 0777);
if (m_Profiler.m_IsActive == true) if (m_Profiler.m_IsActive == true)
{
m_Profiler.m_Timers[0].SetTime(); m_Profiler.m_Timers[0].SetTime();
}
} }
else if (accessMode == "a" || accessMode == "append") else if (accessMode == "a" || accessMode == "append")
{ {
if (m_Profiler.m_IsActive == true) if (m_Profiler.m_IsActive == true)
{
m_Profiler.m_Timers[0].SetInitialTime(); m_Profiler.m_Timers[0].SetInitialTime();
}
m_FileDescriptor = m_FileDescriptor =
open(m_Name.c_str(), O_WRONLY | O_APPEND); // we need to change this open(m_Name.c_str(), O_WRONLY | O_APPEND); // we need to change this
if (m_Profiler.m_IsActive == true) if (m_Profiler.m_IsActive == true)
{
m_Profiler.m_Timers[0].SetTime(); m_Profiler.m_Timers[0].SetTime();
}
} }
else if (accessMode == "r" || accessMode == "read") else if (accessMode == "r" || accessMode == "read")
{ {
if (m_Profiler.m_IsActive == true) if (m_Profiler.m_IsActive == true)
{
m_Profiler.m_Timers[0].SetInitialTime(); m_Profiler.m_Timers[0].SetInitialTime();
}
m_FileDescriptor = open(m_Name.c_str(), O_RDONLY); m_FileDescriptor = open(m_Name.c_str(), O_RDONLY);
if (m_Profiler.m_IsActive == true) if (m_Profiler.m_IsActive == true)
{
m_Profiler.m_Timers[0].SetTime(); m_Profiler.m_Timers[0].SetTime();
}
} }
if (m_DebugMode == true) if (m_DebugMode == true)
{ {
if (m_FileDescriptor == -1) if (m_FileDescriptor == -1)
{
throw std::ios_base::failure("ERROR: couldn't open file " + m_Name + throw std::ios_base::failure("ERROR: couldn't open file " + m_Name +
", from call to Open in FD transport using " ", from call to Open in FD transport using "
"POSIX open. Does file exists?\n"); "POSIX open. Does file exists?\n");
}
} }
} }
void FileDescriptor::Write(const char *buffer, std::size_t size) void FileDescriptor::Write(const char *buffer, std::size_t size)
{ {
if (m_Profiler.m_IsActive == true) if (m_Profiler.m_IsActive == true)
{
m_Profiler.m_Timers[1].SetInitialTime(); m_Profiler.m_Timers[1].SetInitialTime();
}
auto writtenSize = write(m_FileDescriptor, buffer, size); auto writtenSize = write(m_FileDescriptor, buffer, size);
if (m_Profiler.m_IsActive == true) if (m_Profiler.m_IsActive == true)
{
m_Profiler.m_Timers[1].SetTime(); m_Profiler.m_Timers[1].SetTime();
}
if (m_DebugMode == true) if (m_DebugMode == true)
{ {
if (writtenSize == -1) if (writtenSize == -1)
{
throw std::ios_base::failure("ERROR: couldn't write to file " + m_Name + throw std::ios_base::failure("ERROR: couldn't write to file " + m_Name +
", in call to POSIX write\n"); ", in call to POSIX write\n");
}
if (static_cast<std::size_t>(writtenSize) != size) if (static_cast<std::size_t>(writtenSize) != size)
{
throw std::ios_base::failure( throw std::ios_base::failure(
"ERROR: written size + " + std::to_string(writtenSize) + "ERROR: written size + " + std::to_string(writtenSize) +
" is not equal to intended size " + std::to_string(size) + " is not equal to intended size " + std::to_string(size) +
" in file " + m_Name + ", in call to POSIX write\n"); " in file " + m_Name + ", in call to POSIX write\n");
}
} }
} }
void FileDescriptor::Close() void FileDescriptor::Close()
{ {
if (m_Profiler.m_IsActive == true) if (m_Profiler.m_IsActive == true)
{
m_Profiler.m_Timers[2].SetInitialTime(); m_Profiler.m_Timers[2].SetInitialTime();
}
int status = close(m_FileDescriptor); int status = close(m_FileDescriptor);
if (m_Profiler.m_IsActive == true) if (m_Profiler.m_IsActive == true)
{
m_Profiler.m_Timers[2].SetTime(); m_Profiler.m_Timers[2].SetTime();
}
if (m_DebugMode == true) if (m_DebugMode == true)
{ {
if (status == -1) if (status == -1)
{
throw std::ios_base::failure("ERROR: couldn't close file " + m_Name + throw std::ios_base::failure("ERROR: couldn't close file " + m_Name +
", in call to POSIX write\n"); ", in call to POSIX write\n");
}
} }
m_IsOpen = false; m_IsOpen = false;
} }
} // end namespace transport } // end namespace transport
} // end namespace } // namespace adios
...@@ -26,8 +26,10 @@ FilePointer::FilePointer(MPI_Comm mpiComm, const bool debugMode) ...@@ -26,8 +26,10 @@ FilePointer::FilePointer(MPI_Comm mpiComm, const bool debugMode)
FilePointer::~FilePointer() FilePointer::~FilePointer()
{ {
if (m_File != NULL) if (m_File != nullptr)
{
fclose(m_File); fclose(m_File);
}
} }
void FilePointer::Open(const std::string name, const std::string accessMode) void FilePointer::Open(const std::string name, const std::string accessMode)
...@@ -36,20 +38,26 @@ void FilePointer::Open(const std::string name, const std::string accessMode) ...@@ -36,20 +38,26 @@ void FilePointer::Open(const std::string name, const std::string accessMode)
m_AccessMode = accessMode; m_AccessMode = accessMode;
if (accessMode == "w" || accessMode == "write") if (accessMode == "w" || accessMode == "write")
{
m_File = fopen(name.c_str(), "w"); m_File = fopen(name.c_str(), "w");
}
else if (accessMode == "a" || accessMode == "append") else if (accessMode == "a" || accessMode == "append")
{
m_File = fopen(name.c_str(), "a"); m_File = fopen(name.c_str(), "a");
}
else if (accessMode == "r" || accessMode == "read") else if (accessMode == "r" || accessMode == "read")
{
m_File = fopen(name.c_str(), "r"); m_File = fopen(name.c_str(), "r");
}
if (m_DebugMode == true) if (m_DebugMode == true)
{ {
if (m_File == NULL) if (m_File == nullptr)
{
throw std::ios_base::failure("ERROR: couldn't open file " + name + throw std::ios_base::failure("ERROR: couldn't open file " + name +
", " ", "
"in call to Open from File* transport\n"); "in call to Open from File* transport\n");
}
} }
} }
...@@ -60,8 +68,10 @@ void FilePointer::SetBuffer(char *buffer, std::size_t size) ...@@ -60,8 +68,10 @@ void FilePointer::SetBuffer(char *buffer, std::size_t size)
if (m_DebugMode == true) if (m_DebugMode == true)
{ {
if (status == 1) if (status == 1)
{
throw std::ios_base::failure("ERROR: could not set buffer in rank " + throw std::ios_base::failure("ERROR: could not set buffer in rank " +
std::to_string(m_RankMPI) + "\n"); std::to_string(m_RankMPI) + "\n");
}
} }
} }
...@@ -72,8 +82,10 @@ void FilePointer::Write(const char *buffer, std::size_t size) ...@@ -72,8 +82,10 @@ void FilePointer::Write(const char *buffer, std::size_t size)
if (m_DebugMode == true) if (m_DebugMode == true)
{ {
if (ferror(m_File)) if (ferror(m_File))
{
throw std::ios_base::failure("ERROR: couldn't write to file " + m_Name + throw std::ios_base::failure("ERROR: couldn't write to file " + m_Name +
", in call to File* write\n"); ", in call to File* write\n");
}
} }
} }
...@@ -87,4 +99,4 @@ void FilePointer::Close() ...@@ -87,4 +99,4 @@ void FilePointer::Close()
} }
} // end namespace transport } // end namespace transport
} // end namespace } // namespace adios
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment