Skip to content
Snippets Groups Projects
Commit c211ab90 authored by William F Godoy's avatar William F Godoy
Browse files

Reading bp files using stepping mode BeginStep EndStep

Modifying file names
parent b1962d80
No related branches found
No related tags found
1 merge request!319Reading bp files using stepping mode BeginStep EndStep
...@@ -25,6 +25,43 @@ BPFileReader::BPFileReader(IO &io, const std::string &name, const Mode mode, ...@@ -25,6 +25,43 @@ BPFileReader::BPFileReader(IO &io, const std::string &name, const Mode mode,
Init(); Init();
} }
StepStatus BPFileReader::BeginStep(StepMode mode, const float timeoutSeconds)
{
if (m_DebugMode && mode != StepMode::NextAvailable)
{
throw std::invalid_argument("ERROR: mode is not supported yet for "
"engine BPFileReader, in call to "
"BeginStep\n");
}
const auto &variablesData = m_IO.GetVariablesDataMap();
for (const auto &variableData : variablesData)
{
const std::string name = variableData.first;
const std::string type = m_IO.InquireVariableType(name);
if (type == "compound")
{
}
#define declare_type(T) \
else if (type == GetType<T>()) \
{ \
auto variable = m_IO.InquireVariable<T>(name); \
if (mode == StepMode::NextAvailable) \
{ \
variable->SetStepSelection({m_CurrentStep + 1, 1}); \
} \
}
ADIOS2_FOREACH_TYPE_1ARG(declare_type)
#undef declare_type
}
return StepStatus::OK;
}
void BPFileReader::EndStep() { ++m_CurrentStep; }
void BPFileReader::PerformGets() void BPFileReader::PerformGets()
{ {
const std::map<std::string, SubFileInfoMap> variablesSubfileInfo = const std::map<std::string, SubFileInfoMap> variablesSubfileInfo =
......
...@@ -42,6 +42,11 @@ public: ...@@ -42,6 +42,11 @@ public:
virtual ~BPFileReader() = default; virtual ~BPFileReader() = default;
StepStatus BeginStep(StepMode mode = StepMode::NextAvailable,
const float timeoutSeconds = 0.f) final;
void EndStep() final;
void PerformGets() final; void PerformGets() final;
void Close(const int transportIndex = -1); void Close(const int transportIndex = -1);
...@@ -51,6 +56,9 @@ private: ...@@ -51,6 +56,9 @@ private:
transportman::TransportMan m_FileManager; transportman::TransportMan m_FileManager;
transportman::TransportMan m_SubFileManager; transportman::TransportMan m_SubFileManager;
/** updates if step=1 in EndStep function, used for per-step reads */
size_t m_CurrentStep = 0;
void Init(); void Init();
void InitTransports(); void InitTransports();
void InitBuffer(); void InitBuffer();
......
...@@ -64,4 +64,19 @@ SmallTestData generateNewSmallTestData(SmallTestData in, int step, int rank, ...@@ -64,4 +64,19 @@ SmallTestData generateNewSmallTestData(SmallTestData in, int step, int rank,
return in; return in;
} }
void UpdateSmallTestData(SmallTestData &in, int step, int rank, int size)
{
int j = rank + 1 + step * size;
std::for_each(in.I8.begin(), in.I8.end(), [&](int8_t &v) { v += j; });
std::for_each(in.I16.begin(), in.I16.end(), [&](int16_t &v) { v += j; });
std::for_each(in.I32.begin(), in.I32.end(), [&](int32_t &v) { v += j; });
std::for_each(in.I64.begin(), in.I64.end(), [&](int64_t &v) { v += j; });
std::for_each(in.U8.begin(), in.U8.end(), [&](uint8_t &v) { v += j; });
std::for_each(in.U16.begin(), in.U16.end(), [&](uint16_t &v) { v += j; });
std::for_each(in.U32.begin(), in.U32.end(), [&](uint32_t &v) { v += j; });
std::for_each(in.U64.begin(), in.U64.end(), [&](uint64_t &v) { v += j; });
std::for_each(in.R32.begin(), in.R32.end(), [&](float &v) { v += j; });
std::for_each(in.R64.begin(), in.R64.end(), [&](double &v) { v += j; });
}
#endif // TESTING_ADIOS2_ENGINE_SMALLTESTDATA_H_ #endif // TESTING_ADIOS2_ENGINE_SMALLTESTDATA_H_
...@@ -6,18 +6,23 @@ ...@@ -6,18 +6,23 @@
add_executable(TestBPWriteReadADIOS2 TestBPWriteReadADIOS2.cpp) add_executable(TestBPWriteReadADIOS2 TestBPWriteReadADIOS2.cpp)
target_link_libraries(TestBPWriteReadADIOS2 adios2 gtest gtest_main) target_link_libraries(TestBPWriteReadADIOS2 adios2 gtest gtest_main)
add_executable(TestBPWriteReadAsStreamADIOS2 TestBPWriteReadAsStreamADIOS2.cpp)
target_link_libraries(TestBPWriteReadAsStreamADIOS2 adios2 gtest gtest_main)
add_executable(TestBPWriteReadAttributesADIOS2 TestBPWriteReadAttributesADIOS2.cpp) add_executable(TestBPWriteReadAttributesADIOS2 TestBPWriteReadAttributesADIOS2.cpp)
target_link_libraries(TestBPWriteReadAttributesADIOS2 adios2 gtest gtest_main) target_link_libraries(TestBPWriteReadAttributesADIOS2 adios2 gtest gtest_main)
if(ADIOS2_HAVE_MPI) if(ADIOS2_HAVE_MPI)
target_link_libraries(TestBPWriteReadADIOS2 MPI::MPI_C) target_link_libraries(TestBPWriteReadADIOS2 MPI::MPI_C)
target_link_libraries(TestBPWriteReadAsStreamADIOS2 MPI::MPI_C)
target_link_libraries(TestBPWriteReadAttributesADIOS2 MPI::MPI_C) target_link_libraries(TestBPWriteReadAttributesADIOS2 MPI::MPI_C)
set(extra_test_args EXEC_WRAPPER ${MPIEXEC_COMMAND}) set(extra_test_args EXEC_WRAPPER ${MPIEXEC_COMMAND})
endif() endif()
gtest_add_tests(TARGET TestBPWriteReadADIOS2 ${extra_test_args}) gtest_add_tests(TARGET TestBPWriteReadADIOS2 ${extra_test_args})
gtest_add_tests(TARGET TestBPWriteReadAsStreamADIOS2 ${extra_test_args})
gtest_add_tests(TARGET TestBPWriteReadAttributesADIOS2 ${extra_test_args}) gtest_add_tests(TARGET TestBPWriteReadAttributesADIOS2 ${extra_test_args})
if (ADIOS2_HAVE_ADIOS1) if (ADIOS2_HAVE_ADIOS1)
......
This diff is collapsed.
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