diff --git a/docs/user_guide/source/engines/ssc.rst b/docs/user_guide/source/engines/ssc.rst index 24578e6ccf..68ae308be0 100644 --- a/docs/user_guide/source/engines/ssc.rst +++ b/docs/user_guide/source/engines/ssc.rst @@ -8,15 +8,12 @@ The SSC engine takes the following parameters: 1. ``OpenTimeoutSecs``: Default **10**. Timeout in seconds for opening a stream. The SSC engine's open function will block until the RendezvousAppCount is reached, or timeout, whichever comes first. If it reaches the timeout, SSC will throw an exception. -2. ``MpiMode``: Default **TwoSided**. MPI communication modes to use. Besides the default TwoSided mode using two sided MPI communications, MPI_Isend and MPI_Irecv, for data transport, there are four one sided MPI modes: OneSidedFencePush, OneSidedPostPush, OneSidedFencePull, and OneSidedPostPull. Modes with **Push** are based on the push model and use MPI_Put for data transport, while modes with **Pull** are based on the pull model and use MPI_Get. Modes with **Fence** use MPI_Win_fence for synchronization, while modes with **Post** use MPI_Win_start, MPI_Win_complete, MPI_Win_post and MPI_Win_wait. - -3. ``Threading``: Default **False**. SSC will use threads to hide the time cost for metadata manipulation and data transfer when this parameter is set to **true**. SSC will check if MPI is initialized with multi-thread enabled, and if not, then SSC will force this parameter to be **false**. Please do NOT enable threading when multiple I/O streams are opened in an application, as it will cause unpredictable errors. +2. ``Threading``: Default **False**. SSC will use threads to hide the time cost for metadata manipulation and data transfer when this parameter is set to **true**. SSC will check if MPI is initialized with multi-thread enabled, and if not, then SSC will force this parameter to be **false**. Please do NOT enable threading when multiple I/O streams are opened in an application, as it will cause unpredictable errors. =============================== ================== ================================================ **Key** **Value Format** **Default** and Examples =============================== ================== ================================================ OpenTimeoutSecs integer **10**, 2, 20, 200 - MpiMode string **TwoSided**, OneSidedFencePush, OneSidedPostPush, OneSidedFencePull, OneSidedPostPull Threading bool **false**, true =============================== ================== ================================================ diff --git a/source/adios2/engine/ssc/SscReader.cpp b/source/adios2/engine/ssc/SscReader.cpp index 0e4f0794d3..3ff29fa189 100644 --- a/source/adios2/engine/ssc/SscReader.cpp +++ b/source/adios2/engine/ssc/SscReader.cpp @@ -27,7 +27,6 @@ SscReader::SscReader(IO &io, const std::string &name, const Mode mode, { TAU_SCOPED_TIMER_FUNC(); - helper::GetParameter(m_IO.m_Parameters, "MpiMode", m_MpiMode); helper::GetParameter(m_IO.m_Parameters, "Verbose", m_Verbosity); helper::GetParameter(m_IO.m_Parameters, "Threading", m_Threading); helper::GetParameter(m_IO.m_Parameters, "OpenTimeoutSecs", @@ -40,28 +39,9 @@ SscReader::~SscReader() { TAU_SCOPED_TIMER_FUNC(); } void SscReader::BeginStepConsequentFixed() { - if (m_MpiMode == "twosided") - { - MPI_Waitall(static_cast(m_MpiRequests.size()), - m_MpiRequests.data(), MPI_STATUS_IGNORE); - m_MpiRequests.clear(); - } - else if (m_MpiMode == "onesidedfencepush") - { - MPI_Win_fence(0, m_MpiWin); - } - else if (m_MpiMode == "onesidedpostpush") - { - MPI_Win_wait(m_MpiWin); - } - else if (m_MpiMode == "onesidedfencepull") - { - MPI_Win_fence(0, m_MpiWin); - } - else if (m_MpiMode == "onesidedpostpull") - { - MPI_Win_complete(m_MpiWin); - } + MPI_Waitall(static_cast(m_MpiRequests.size()), m_MpiRequests.data(), + MPI_STATUS_IGNORE); + m_MpiRequests.clear(); } void SscReader::BeginStepFlexible(StepStatus &status) @@ -278,46 +258,13 @@ void SscReader::EndStepFixed() { MPI_Win_free(&m_MpiWin); SyncReadPattern(); - MPI_Win_create(m_Buffer.data(), m_Buffer.size(), 1, MPI_INFO_NULL, - m_StreamComm, &m_MpiWin); } - if (m_MpiMode == "twosided") + for (const auto &i : m_AllReceivingWriterRanks) { - for (const auto &i : m_AllReceivingWriterRanks) - { - m_MpiRequests.emplace_back(); - MPI_Irecv(m_Buffer.data() + i.second.first, - static_cast(i.second.second), MPI_CHAR, i.first, 0, - m_StreamComm, &m_MpiRequests.back()); - } - } - else if (m_MpiMode == "onesidedfencepush") - { - MPI_Win_fence(0, m_MpiWin); - } - else if (m_MpiMode == "onesidedpostpush") - { - MPI_Win_post(m_WriterGroup, 0, m_MpiWin); - } - else if (m_MpiMode == "onesidedfencepull") - { - MPI_Win_fence(0, m_MpiWin); - for (const auto &i : m_AllReceivingWriterRanks) - { - MPI_Get(m_Buffer.data() + i.second.first, - static_cast(i.second.second), MPI_CHAR, i.first, 0, - static_cast(i.second.second), MPI_CHAR, m_MpiWin); - } - } - else if (m_MpiMode == "onesidedpostpull") - { - MPI_Win_start(m_WriterGroup, 0, m_MpiWin); - for (const auto &i : m_AllReceivingWriterRanks) - { - MPI_Get(m_Buffer.data() + i.second.first, - static_cast(i.second.second), MPI_CHAR, i.first, 0, - static_cast(i.second.second), MPI_CHAR, m_MpiWin); - } + m_MpiRequests.emplace_back(); + MPI_Irecv(m_Buffer.data() + i.second.first, + static_cast(i.second.second), MPI_CHAR, i.first, 0, + m_StreamComm, &m_MpiRequests.back()); } } @@ -567,11 +514,6 @@ void SscReader::DoClose(const int transportIndex) { BeginStep(); } - - if (m_WriterDefinitionsLocked && m_ReaderSelectionsLocked) - { - MPI_Win_free(&m_MpiWin); - } } } // end namespace engine diff --git a/source/adios2/engine/ssc/SscReader.h b/source/adios2/engine/ssc/SscReader.h index 4bd50b3109..71c198dee4 100644 --- a/source/adios2/engine/ssc/SscReader.h +++ b/source/adios2/engine/ssc/SscReader.h @@ -101,7 +101,6 @@ class SscReader : public Engine int m_Verbosity = 0; int m_OpenTimeoutSecs = 10; bool m_Threading = false; - std::string m_MpiMode = "twosided"; }; } // end namespace engine diff --git a/source/adios2/engine/ssc/SscWriter.cpp b/source/adios2/engine/ssc/SscWriter.cpp index 01514293d9..f9089103e6 100644 --- a/source/adios2/engine/ssc/SscWriter.cpp +++ b/source/adios2/engine/ssc/SscWriter.cpp @@ -26,7 +26,6 @@ SscWriter::SscWriter(IO &io, const std::string &name, const Mode mode, { TAU_SCOPED_TIMER_FUNC(); - helper::GetParameter(m_IO.m_Parameters, "MpiMode", m_MpiMode); helper::GetParameter(m_IO.m_Parameters, "Verbose", m_Verbosity); helper::GetParameter(m_IO.m_Parameters, "Threading", m_Threading); helper::GetParameter(m_IO.m_Parameters, "OpenTimeoutSecs", @@ -108,53 +107,16 @@ void SscWriter::EndStepFirst() m_StreamComm, &m_MpiWin); MPI_Win_free(&m_MpiWin); SyncReadPattern(); - if (m_WriterDefinitionsLocked && m_ReaderSelectionsLocked) - { - MPI_Win_create(m_Buffer.data(), m_Buffer.size(), 1, MPI_INFO_NULL, - m_StreamComm, &m_MpiWin); - } } void SscWriter::EndStepConsequentFixed() { TAU_SCOPED_TIMER_FUNC(); - if (m_MpiMode == "twosided") - { - for (const auto &i : m_AllSendingReaderRanks) - { - m_MpiRequests.emplace_back(); - MPI_Isend(m_Buffer.data(), static_cast(m_Buffer.size()), - MPI_CHAR, i.first, 0, m_StreamComm, - &m_MpiRequests.back()); - } - } - else if (m_MpiMode == "onesidedfencepush") - { - MPI_Win_fence(0, m_MpiWin); - for (const auto &i : m_AllSendingReaderRanks) - { - MPI_Put(m_Buffer.data(), static_cast(m_Buffer.size()), - MPI_CHAR, i.first, i.second.first, - static_cast(m_Buffer.size()), MPI_CHAR, m_MpiWin); - } - } - else if (m_MpiMode == "onesidedpostpush") - { - MPI_Win_start(m_ReaderGroup, 0, m_MpiWin); - for (const auto &i : m_AllSendingReaderRanks) - { - MPI_Put(m_Buffer.data(), static_cast(m_Buffer.size()), - MPI_CHAR, i.first, i.second.first, - static_cast(m_Buffer.size()), MPI_CHAR, m_MpiWin); - } - } - else if (m_MpiMode == "onesidedfencepull") + for (const auto &i : m_AllSendingReaderRanks) { - MPI_Win_fence(0, m_MpiWin); - } - else if (m_MpiMode == "onesidedpostpull") - { - MPI_Win_post(m_ReaderGroup, 0, m_MpiWin); + m_MpiRequests.emplace_back(); + MPI_Isend(m_Buffer.data(), static_cast(m_Buffer.size()), MPI_CHAR, + i.first, 0, m_StreamComm, &m_MpiRequests.back()); } } @@ -213,28 +175,9 @@ void SscWriter::Flush(const int transportIndex) { TAU_SCOPED_TIMER_FUNC(); } void SscWriter::MpiWait() { - if (m_MpiMode == "twosided") - { - MPI_Waitall(static_cast(m_MpiRequests.size()), - m_MpiRequests.data(), MPI_STATUSES_IGNORE); - m_MpiRequests.clear(); - } - else if (m_MpiMode == "onesidedfencepush") - { - MPI_Win_fence(0, m_MpiWin); - } - else if (m_MpiMode == "onesidedpostpush") - { - MPI_Win_complete(m_MpiWin); - } - else if (m_MpiMode == "onesidedfencepull") - { - MPI_Win_fence(0, m_MpiWin); - } - else if (m_MpiMode == "onesidedpostpull") - { - MPI_Win_wait(m_MpiWin); - } + MPI_Waitall(static_cast(m_MpiRequests.size()), m_MpiRequests.data(), + MPI_STATUSES_IGNORE); + m_MpiRequests.clear(); } void SscWriter::SyncMpiPattern() @@ -418,50 +361,15 @@ void SscWriter::DoClose(const int transportIndex) m_Buffer[0] = 1; - if (m_MpiMode == "twosided") - { - std::vector requests; - for (const auto &i : m_AllSendingReaderRanks) - { - requests.emplace_back(); - MPI_Isend(m_Buffer.data(), 1, MPI_CHAR, i.first, 0, - m_StreamComm, &requests.back()); - } - MPI_Waitall(static_cast(requests.size()), requests.data(), - MPI_STATUS_IGNORE); - } - else if (m_MpiMode == "onesidedfencepush") - { - MPI_Win_fence(0, m_MpiWin); - for (const auto &i : m_AllSendingReaderRanks) - { - MPI_Put(m_Buffer.data(), 1, MPI_CHAR, i.first, 0, 1, MPI_CHAR, - m_MpiWin); - } - MPI_Win_fence(0, m_MpiWin); - } - else if (m_MpiMode == "onesidedpostpush") - { - MPI_Win_start(m_ReaderGroup, 0, m_MpiWin); - for (const auto &i : m_AllSendingReaderRanks) - { - MPI_Put(m_Buffer.data(), 1, MPI_CHAR, i.first, 0, 1, MPI_CHAR, - m_MpiWin); - } - MPI_Win_complete(m_MpiWin); - } - else if (m_MpiMode == "onesidedfencepull") - { - MPI_Win_fence(0, m_MpiWin); - MPI_Win_fence(0, m_MpiWin); - } - else if (m_MpiMode == "onesidedpostpull") + std::vector requests; + for (const auto &i : m_AllSendingReaderRanks) { - MPI_Win_post(m_ReaderGroup, 0, m_MpiWin); - MPI_Win_wait(m_MpiWin); + requests.emplace_back(); + MPI_Isend(m_Buffer.data(), 1, MPI_CHAR, i.first, 0, m_StreamComm, + &requests.back()); } - - MPI_Win_free(&m_MpiWin); + MPI_Waitall(static_cast(requests.size()), requests.data(), + MPI_STATUS_IGNORE); } else { diff --git a/source/adios2/engine/ssc/SscWriter.h b/source/adios2/engine/ssc/SscWriter.h index 2065443382..82a0148912 100644 --- a/source/adios2/engine/ssc/SscWriter.h +++ b/source/adios2/engine/ssc/SscWriter.h @@ -89,7 +89,6 @@ class SscWriter : public Engine int m_Verbosity = 0; int m_OpenTimeoutSecs = 10; bool m_Threading = false; - std::string m_MpiMode = "twosided"; }; } // end namespace engine diff --git a/testing/adios2/engine/ssc/CMakeLists.txt b/testing/adios2/engine/ssc/CMakeLists.txt index 8b28391547..486e5b5350 100644 --- a/testing/adios2/engine/ssc/CMakeLists.txt +++ b/testing/adios2/engine/ssc/CMakeLists.txt @@ -27,18 +27,6 @@ if(ADIOS2_HAVE_MPI) gtest_add_tests_helper(OnlyTwoSteps MPI_ONLY Ssc Engine.SSC. "") SetupTestPipeline(Engine.SSC.SscEngineTest.TestSscOnlyTwoSteps.MPI "" TRUE) - gtest_add_tests_helper(OneSidedFencePush MPI_ONLY Ssc Engine.SSC. "") - SetupTestPipeline(Engine.SSC.SscEngineTest.TestSscOneSidedFencePush.MPI "" TRUE) - - gtest_add_tests_helper(OneSidedPostPush MPI_ONLY Ssc Engine.SSC. "") - SetupTestPipeline(Engine.SSC.SscEngineTest.TestSscOneSidedPostPush.MPI "" TRUE) - - gtest_add_tests_helper(OneSidedFencePull MPI_ONLY Ssc Engine.SSC. "") - SetupTestPipeline(Engine.SSC.SscEngineTest.TestSscOneSidedFencePull.MPI "" TRUE) - - gtest_add_tests_helper(OneSidedPostPull MPI_ONLY Ssc Engine.SSC. "") - SetupTestPipeline(Engine.SSC.SscEngineTest.TestSscOneSidedPostPull.MPI "" TRUE) - gtest_add_tests_helper(Unbalanced MPI_ONLY Ssc Engine.SSC. "") SetupTestPipeline(Engine.SSC.SscEngineTest.TestSscUnbalanced.MPI "" TRUE) diff --git a/testing/adios2/engine/ssc/TestSscOneSidedFencePull.cpp b/testing/adios2/engine/ssc/TestSscOneSidedFencePull.cpp deleted file mode 100644 index 7396d6df92..0000000000 --- a/testing/adios2/engine/ssc/TestSscOneSidedFencePull.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - */ - -#include "TestSscCommon.h" -#include -#include -#include -#include -#include - -using namespace adios2; -int mpiRank = 0; -int mpiSize = 1; -MPI_Comm mpiComm; - -class SscEngineTest : public ::testing::Test -{ -public: - SscEngineTest() = default; -}; - -void Writer(const Dims &shape, const Dims &start, const Dims &count, - const size_t steps, const adios2::Params &engineParams, - const std::string &name) -{ - size_t datasize = - std::accumulate(count.begin(), count.end(), static_cast(1), - std::multiplies()); - adios2::ADIOS adios(mpiComm); - adios2::IO dataManIO = adios.DeclareIO("WAN"); - dataManIO.SetEngine("ssc"); - dataManIO.SetParameters(engineParams); - std::vector myChars(datasize); - std::vector myUChars(datasize); - std::vector myShorts(datasize); - std::vector myUShorts(datasize); - std::vector myInts(datasize); - std::vector myUInts(datasize); - std::vector myFloats(datasize); - std::vector myDoubles(datasize); - std::vector> myComplexes(datasize); - std::vector> myDComplexes(datasize); - auto bpChars = - dataManIO.DefineVariable("bpChars", shape, start, count); - auto bpUChars = dataManIO.DefineVariable("bpUChars", shape, - start, count); - auto bpShorts = - dataManIO.DefineVariable("bpShorts", shape, start, count); - auto bpUShorts = dataManIO.DefineVariable( - "bpUShorts", shape, start, count); - auto bpInts = dataManIO.DefineVariable("bpInts", shape, start, count); - auto bpUInts = - dataManIO.DefineVariable("bpUInts", shape, start, count); - auto bpFloats = - dataManIO.DefineVariable("bpFloats", shape, start, count); - auto bpDoubles = - dataManIO.DefineVariable("bpDoubles", shape, start, count); - auto bpComplexes = dataManIO.DefineVariable>( - "bpComplexes", shape, start, count); - auto bpDComplexes = dataManIO.DefineVariable>( - "bpDComplexes", shape, start, count); - auto scalarInt = dataManIO.DefineVariable("scalarInt"); - dataManIO.DefineAttribute("AttInt", 110); - adios2::Engine engine = dataManIO.Open(name, adios2::Mode::Write); - engine.LockWriterDefinitions(); - for (size_t i = 0; i < steps; ++i) - { - engine.BeginStep(); - GenData(myChars, i, start, count, shape); - GenData(myUChars, i, start, count, shape); - GenData(myShorts, i, start, count, shape); - GenData(myUShorts, i, start, count, shape); - GenData(myInts, i, start, count, shape); - GenData(myUInts, i, start, count, shape); - GenData(myFloats, i, start, count, shape); - GenData(myDoubles, i, start, count, shape); - GenData(myComplexes, i, start, count, shape); - GenData(myDComplexes, i, start, count, shape); - engine.Put(bpChars, myChars.data(), adios2::Mode::Sync); - engine.Put(bpUChars, myUChars.data(), adios2::Mode::Sync); - engine.Put(bpShorts, myShorts.data(), adios2::Mode::Sync); - engine.Put(bpUShorts, myUShorts.data(), adios2::Mode::Sync); - engine.Put(bpInts, myInts.data(), adios2::Mode::Sync); - engine.Put(bpUInts, myUInts.data(), adios2::Mode::Sync); - engine.Put(bpFloats, myFloats.data(), adios2::Mode::Sync); - engine.Put(bpDoubles, myDoubles.data(), adios2::Mode::Sync); - engine.Put(bpComplexes, myComplexes.data(), adios2::Mode::Sync); - engine.Put(bpDComplexes, myDComplexes.data(), adios2::Mode::Sync); - engine.Put(scalarInt, static_cast(i)); - engine.EndStep(); - } - engine.Close(); -} - -void Reader(const Dims &shape, const Dims &start, const Dims &count, - const size_t steps, const adios2::Params &engineParams, - const std::string &name) -{ - adios2::ADIOS adios(mpiComm); - adios2::IO dataManIO = adios.DeclareIO("Test"); - dataManIO.SetEngine("ssc"); - dataManIO.SetParameters(engineParams); - adios2::Engine engine = dataManIO.Open(name, adios2::Mode::Read); - engine.LockReaderSelections(); - - size_t datasize = - std::accumulate(count.begin(), count.end(), static_cast(1), - std::multiplies()); - std::vector myChars(datasize); - std::vector myUChars(datasize); - std::vector myShorts(datasize); - std::vector myUShorts(datasize); - std::vector myInts(datasize); - std::vector myUInts(datasize); - std::vector myFloats(datasize); - std::vector myDoubles(datasize); - std::vector> myComplexes(datasize); - std::vector> myDComplexes(datasize); - - while (true) - { - adios2::StepStatus status = engine.BeginStep(StepMode::Read, 5); - if (status == adios2::StepStatus::OK) - { - const auto &vars = dataManIO.AvailableVariables(); - ASSERT_EQ(vars.size(), 11); - size_t currentStep = engine.CurrentStep(); - adios2::Variable bpChars = - dataManIO.InquireVariable("bpChars"); - adios2::Variable bpUChars = - dataManIO.InquireVariable("bpUChars"); - adios2::Variable bpShorts = - dataManIO.InquireVariable("bpShorts"); - adios2::Variable bpUShorts = - dataManIO.InquireVariable("bpUShorts"); - adios2::Variable bpInts = - dataManIO.InquireVariable("bpInts"); - adios2::Variable bpUInts = - dataManIO.InquireVariable("bpUInts"); - adios2::Variable bpFloats = - dataManIO.InquireVariable("bpFloats"); - adios2::Variable bpDoubles = - dataManIO.InquireVariable("bpDoubles"); - adios2::Variable> bpComplexes = - dataManIO.InquireVariable>("bpComplexes"); - adios2::Variable> bpDComplexes = - dataManIO.InquireVariable>("bpDComplexes"); - auto scalarInt = dataManIO.InquireVariable("scalarInt"); - - bpChars.SetSelection({start, count}); - bpUChars.SetSelection({start, count}); - bpShorts.SetSelection({start, count}); - bpUShorts.SetSelection({start, count}); - bpInts.SetSelection({start, count}); - bpUInts.SetSelection({start, count}); - bpFloats.SetSelection({start, count}); - bpDoubles.SetSelection({start, count}); - bpComplexes.SetSelection({start, count}); - bpDComplexes.SetSelection({start, count}); - - engine.Get(bpChars, myChars.data(), adios2::Mode::Sync); - engine.Get(bpUChars, myUChars.data(), adios2::Mode::Sync); - engine.Get(bpShorts, myShorts.data(), adios2::Mode::Sync); - engine.Get(bpUShorts, myUShorts.data(), adios2::Mode::Sync); - engine.Get(bpInts, myInts.data(), adios2::Mode::Sync); - engine.Get(bpUInts, myUInts.data(), adios2::Mode::Sync); - engine.Get(bpFloats, myFloats.data(), adios2::Mode::Sync); - engine.Get(bpDoubles, myDoubles.data(), adios2::Mode::Sync); - engine.Get(bpComplexes, myComplexes.data(), adios2::Mode::Sync); - engine.Get(bpDComplexes, myDComplexes.data(), adios2::Mode::Sync); - int i; - engine.Get(scalarInt, &i, adios2::Mode::Sync); - - ASSERT_EQ(i, currentStep); - - VerifyData(myChars.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUChars.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myShorts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUShorts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myInts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUInts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myFloats.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myDoubles.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myComplexes.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myDComplexes.data(), currentStep, start, count, shape, - mpiRank); - engine.EndStep(); - } - else if (status == adios2::StepStatus::EndOfStream) - { - std::cout << "[Rank " + std::to_string(mpiRank) + - "] SscTest reader end of stream!" - << std::endl; - break; - } - } - auto attInt = dataManIO.InquireAttribute("AttInt"); - std::cout << "[Rank " + std::to_string(mpiRank) + "] Attribute received " - << attInt.Data()[0] << ", expected 110" << std::endl; - ASSERT_EQ(110, attInt.Data()[0]); - ASSERT_NE(111, attInt.Data()[0]); - engine.Close(); -} - -TEST_F(SscEngineTest, TestSscOneSidedFencePull) -{ - std::string filename = "TestSscOneSidedFencePull"; - adios2::Params engineParams = {{"MpiMode", "OneSidedFencePull"}}; - - int worldRank, worldSize; - MPI_Comm_rank(MPI_COMM_WORLD, &worldRank); - MPI_Comm_size(MPI_COMM_WORLD, &worldSize); - int mpiGroup = worldRank / (worldSize / 2); - MPI_Comm_split(MPI_COMM_WORLD, mpiGroup, worldRank, &mpiComm); - - MPI_Comm_rank(mpiComm, &mpiRank); - MPI_Comm_size(mpiComm, &mpiSize); - - Dims shape = {10, (size_t)mpiSize * 2}; - Dims start = {2, (size_t)mpiRank * 2}; - Dims count = {5, 2}; - size_t steps = 100; - - if (mpiGroup == 0) - { - Writer(shape, start, count, steps, engineParams, filename); - } - - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - - if (mpiGroup == 1) - { - Reader(shape, start, count, steps, engineParams, filename); - } - - MPI_Barrier(MPI_COMM_WORLD); -} - -int main(int argc, char **argv) -{ - MPI_Init(&argc, &argv); - int worldRank, worldSize; - MPI_Comm_rank(MPI_COMM_WORLD, &worldRank); - MPI_Comm_size(MPI_COMM_WORLD, &worldSize); - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); - - MPI_Finalize(); - return result; -} diff --git a/testing/adios2/engine/ssc/TestSscOneSidedFencePush.cpp b/testing/adios2/engine/ssc/TestSscOneSidedFencePush.cpp deleted file mode 100644 index b496d5f1b3..0000000000 --- a/testing/adios2/engine/ssc/TestSscOneSidedFencePush.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - */ - -#include "TestSscCommon.h" -#include -#include -#include -#include -#include - -using namespace adios2; -int mpiRank = 0; -int mpiSize = 1; -MPI_Comm mpiComm; - -class SscEngineTest : public ::testing::Test -{ -public: - SscEngineTest() = default; -}; - -void Writer(const Dims &shape, const Dims &start, const Dims &count, - const size_t steps, const adios2::Params &engineParams, - const std::string &name) -{ - size_t datasize = - std::accumulate(count.begin(), count.end(), static_cast(1), - std::multiplies()); - adios2::ADIOS adios(mpiComm); - adios2::IO dataManIO = adios.DeclareIO("WAN"); - dataManIO.SetEngine("ssc"); - dataManIO.SetParameters(engineParams); - std::vector myChars(datasize); - std::vector myUChars(datasize); - std::vector myShorts(datasize); - std::vector myUShorts(datasize); - std::vector myInts(datasize); - std::vector myUInts(datasize); - std::vector myFloats(datasize); - std::vector myDoubles(datasize); - std::vector> myComplexes(datasize); - std::vector> myDComplexes(datasize); - auto bpChars = - dataManIO.DefineVariable("bpChars", shape, start, count); - auto bpUChars = dataManIO.DefineVariable("bpUChars", shape, - start, count); - auto bpShorts = - dataManIO.DefineVariable("bpShorts", shape, start, count); - auto bpUShorts = dataManIO.DefineVariable( - "bpUShorts", shape, start, count); - auto bpInts = dataManIO.DefineVariable("bpInts", shape, start, count); - auto bpUInts = - dataManIO.DefineVariable("bpUInts", shape, start, count); - auto bpFloats = - dataManIO.DefineVariable("bpFloats", shape, start, count); - auto bpDoubles = - dataManIO.DefineVariable("bpDoubles", shape, start, count); - auto bpComplexes = dataManIO.DefineVariable>( - "bpComplexes", shape, start, count); - auto bpDComplexes = dataManIO.DefineVariable>( - "bpDComplexes", shape, start, count); - auto scalarInt = dataManIO.DefineVariable("scalarInt"); - dataManIO.DefineAttribute("AttInt", 110); - adios2::Engine engine = dataManIO.Open(name, adios2::Mode::Write); - engine.LockWriterDefinitions(); - for (size_t i = 0; i < steps; ++i) - { - engine.BeginStep(); - GenData(myChars, i, start, count, shape); - GenData(myUChars, i, start, count, shape); - GenData(myShorts, i, start, count, shape); - GenData(myUShorts, i, start, count, shape); - GenData(myInts, i, start, count, shape); - GenData(myUInts, i, start, count, shape); - GenData(myFloats, i, start, count, shape); - GenData(myDoubles, i, start, count, shape); - GenData(myComplexes, i, start, count, shape); - GenData(myDComplexes, i, start, count, shape); - engine.Put(bpChars, myChars.data(), adios2::Mode::Sync); - engine.Put(bpUChars, myUChars.data(), adios2::Mode::Sync); - engine.Put(bpShorts, myShorts.data(), adios2::Mode::Sync); - engine.Put(bpUShorts, myUShorts.data(), adios2::Mode::Sync); - engine.Put(bpInts, myInts.data(), adios2::Mode::Sync); - engine.Put(bpUInts, myUInts.data(), adios2::Mode::Sync); - engine.Put(bpFloats, myFloats.data(), adios2::Mode::Sync); - engine.Put(bpDoubles, myDoubles.data(), adios2::Mode::Sync); - engine.Put(bpComplexes, myComplexes.data(), adios2::Mode::Sync); - engine.Put(bpDComplexes, myDComplexes.data(), adios2::Mode::Sync); - engine.Put(scalarInt, static_cast(i)); - engine.EndStep(); - } - engine.Close(); -} - -void Reader(const Dims &shape, const Dims &start, const Dims &count, - const size_t steps, const adios2::Params &engineParams, - const std::string &name) -{ - adios2::ADIOS adios(mpiComm); - adios2::IO dataManIO = adios.DeclareIO("Test"); - dataManIO.SetEngine("ssc"); - dataManIO.SetParameters(engineParams); - adios2::Engine engine = dataManIO.Open(name, adios2::Mode::Read); - engine.LockReaderSelections(); - - size_t datasize = - std::accumulate(count.begin(), count.end(), static_cast(1), - std::multiplies()); - std::vector myChars(datasize); - std::vector myUChars(datasize); - std::vector myShorts(datasize); - std::vector myUShorts(datasize); - std::vector myInts(datasize); - std::vector myUInts(datasize); - std::vector myFloats(datasize); - std::vector myDoubles(datasize); - std::vector> myComplexes(datasize); - std::vector> myDComplexes(datasize); - - while (true) - { - adios2::StepStatus status = engine.BeginStep(StepMode::Read, 5); - if (status == adios2::StepStatus::OK) - { - const auto &vars = dataManIO.AvailableVariables(); - ASSERT_EQ(vars.size(), 11); - size_t currentStep = engine.CurrentStep(); - adios2::Variable bpChars = - dataManIO.InquireVariable("bpChars"); - adios2::Variable bpUChars = - dataManIO.InquireVariable("bpUChars"); - adios2::Variable bpShorts = - dataManIO.InquireVariable("bpShorts"); - adios2::Variable bpUShorts = - dataManIO.InquireVariable("bpUShorts"); - adios2::Variable bpInts = - dataManIO.InquireVariable("bpInts"); - adios2::Variable bpUInts = - dataManIO.InquireVariable("bpUInts"); - adios2::Variable bpFloats = - dataManIO.InquireVariable("bpFloats"); - adios2::Variable bpDoubles = - dataManIO.InquireVariable("bpDoubles"); - adios2::Variable> bpComplexes = - dataManIO.InquireVariable>("bpComplexes"); - adios2::Variable> bpDComplexes = - dataManIO.InquireVariable>("bpDComplexes"); - auto scalarInt = dataManIO.InquireVariable("scalarInt"); - - bpChars.SetSelection({start, count}); - bpUChars.SetSelection({start, count}); - bpShorts.SetSelection({start, count}); - bpUShorts.SetSelection({start, count}); - bpInts.SetSelection({start, count}); - bpUInts.SetSelection({start, count}); - bpFloats.SetSelection({start, count}); - bpDoubles.SetSelection({start, count}); - bpComplexes.SetSelection({start, count}); - bpDComplexes.SetSelection({start, count}); - - engine.Get(bpChars, myChars.data(), adios2::Mode::Sync); - engine.Get(bpUChars, myUChars.data(), adios2::Mode::Sync); - engine.Get(bpShorts, myShorts.data(), adios2::Mode::Sync); - engine.Get(bpUShorts, myUShorts.data(), adios2::Mode::Sync); - engine.Get(bpInts, myInts.data(), adios2::Mode::Sync); - engine.Get(bpUInts, myUInts.data(), adios2::Mode::Sync); - engine.Get(bpFloats, myFloats.data(), adios2::Mode::Sync); - engine.Get(bpDoubles, myDoubles.data(), adios2::Mode::Sync); - engine.Get(bpComplexes, myComplexes.data(), adios2::Mode::Sync); - engine.Get(bpDComplexes, myDComplexes.data(), adios2::Mode::Sync); - int i; - engine.Get(scalarInt, &i, adios2::Mode::Sync); - - ASSERT_EQ(i, currentStep); - - VerifyData(myChars.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUChars.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myShorts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUShorts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myInts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUInts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myFloats.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myDoubles.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myComplexes.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myDComplexes.data(), currentStep, start, count, shape, - mpiRank); - engine.EndStep(); - } - else if (status == adios2::StepStatus::EndOfStream) - { - std::cout << "[Rank " + std::to_string(mpiRank) + - "] SscTest reader end of stream!" - << std::endl; - break; - } - } - auto attInt = dataManIO.InquireAttribute("AttInt"); - std::cout << "[Rank " + std::to_string(mpiRank) + "] Attribute received " - << attInt.Data()[0] << ", expected 110" << std::endl; - ASSERT_EQ(110, attInt.Data()[0]); - ASSERT_NE(111, attInt.Data()[0]); - engine.Close(); -} - -TEST_F(SscEngineTest, TestSscOneSidedFencePush) -{ - std::string filename = "TestSscOneSidedFencePush"; - adios2::Params engineParams = {{"MpiMode", "OneSidedFencePush"}}; - - int worldRank, worldSize; - MPI_Comm_rank(MPI_COMM_WORLD, &worldRank); - MPI_Comm_size(MPI_COMM_WORLD, &worldSize); - int mpiGroup = worldRank / (worldSize / 2); - MPI_Comm_split(MPI_COMM_WORLD, mpiGroup, worldRank, &mpiComm); - - MPI_Comm_rank(mpiComm, &mpiRank); - MPI_Comm_size(mpiComm, &mpiSize); - - Dims shape = {10, (size_t)mpiSize * 2}; - Dims start = {2, (size_t)mpiRank * 2}; - Dims count = {5, 2}; - size_t steps = 100; - - if (mpiGroup == 0) - { - Writer(shape, start, count, steps, engineParams, filename); - } - - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - - if (mpiGroup == 1) - { - Reader(shape, start, count, steps, engineParams, filename); - } - - MPI_Barrier(MPI_COMM_WORLD); -} - -int main(int argc, char **argv) -{ - MPI_Init(&argc, &argv); - int worldRank, worldSize; - MPI_Comm_rank(MPI_COMM_WORLD, &worldRank); - MPI_Comm_size(MPI_COMM_WORLD, &worldSize); - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); - - MPI_Finalize(); - return result; -} diff --git a/testing/adios2/engine/ssc/TestSscOneSidedPostPull.cpp b/testing/adios2/engine/ssc/TestSscOneSidedPostPull.cpp deleted file mode 100644 index b338470049..0000000000 --- a/testing/adios2/engine/ssc/TestSscOneSidedPostPull.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - */ - -#include "TestSscCommon.h" -#include -#include -#include -#include -#include - -using namespace adios2; -int mpiRank = 0; -int mpiSize = 1; -MPI_Comm mpiComm; - -class SscEngineTest : public ::testing::Test -{ -public: - SscEngineTest() = default; -}; - -void Writer(const Dims &shape, const Dims &start, const Dims &count, - const size_t steps, const adios2::Params &engineParams, - const std::string &name) -{ - size_t datasize = - std::accumulate(count.begin(), count.end(), static_cast(1), - std::multiplies()); - adios2::ADIOS adios(mpiComm); - adios2::IO dataManIO = adios.DeclareIO("WAN"); - dataManIO.SetEngine("ssc"); - dataManIO.SetParameters(engineParams); - std::vector myChars(datasize); - std::vector myUChars(datasize); - std::vector myShorts(datasize); - std::vector myUShorts(datasize); - std::vector myInts(datasize); - std::vector myUInts(datasize); - std::vector myFloats(datasize); - std::vector myDoubles(datasize); - std::vector> myComplexes(datasize); - std::vector> myDComplexes(datasize); - auto bpChars = - dataManIO.DefineVariable("bpChars", shape, start, count); - auto bpUChars = dataManIO.DefineVariable("bpUChars", shape, - start, count); - auto bpShorts = - dataManIO.DefineVariable("bpShorts", shape, start, count); - auto bpUShorts = dataManIO.DefineVariable( - "bpUShorts", shape, start, count); - auto bpInts = dataManIO.DefineVariable("bpInts", shape, start, count); - auto bpUInts = - dataManIO.DefineVariable("bpUInts", shape, start, count); - auto bpFloats = - dataManIO.DefineVariable("bpFloats", shape, start, count); - auto bpDoubles = - dataManIO.DefineVariable("bpDoubles", shape, start, count); - auto bpComplexes = dataManIO.DefineVariable>( - "bpComplexes", shape, start, count); - auto bpDComplexes = dataManIO.DefineVariable>( - "bpDComplexes", shape, start, count); - auto scalarInt = dataManIO.DefineVariable("scalarInt"); - dataManIO.DefineAttribute("AttInt", 110); - adios2::Engine engine = dataManIO.Open(name, adios2::Mode::Write); - engine.LockWriterDefinitions(); - for (size_t i = 0; i < steps; ++i) - { - engine.BeginStep(); - GenData(myChars, i, start, count, shape); - GenData(myUChars, i, start, count, shape); - GenData(myShorts, i, start, count, shape); - GenData(myUShorts, i, start, count, shape); - GenData(myInts, i, start, count, shape); - GenData(myUInts, i, start, count, shape); - GenData(myFloats, i, start, count, shape); - GenData(myDoubles, i, start, count, shape); - GenData(myComplexes, i, start, count, shape); - GenData(myDComplexes, i, start, count, shape); - engine.Put(bpChars, myChars.data(), adios2::Mode::Sync); - engine.Put(bpUChars, myUChars.data(), adios2::Mode::Sync); - engine.Put(bpShorts, myShorts.data(), adios2::Mode::Sync); - engine.Put(bpUShorts, myUShorts.data(), adios2::Mode::Sync); - engine.Put(bpInts, myInts.data(), adios2::Mode::Sync); - engine.Put(bpUInts, myUInts.data(), adios2::Mode::Sync); - engine.Put(bpFloats, myFloats.data(), adios2::Mode::Sync); - engine.Put(bpDoubles, myDoubles.data(), adios2::Mode::Sync); - engine.Put(bpComplexes, myComplexes.data(), adios2::Mode::Sync); - engine.Put(bpDComplexes, myDComplexes.data(), adios2::Mode::Sync); - engine.Put(scalarInt, static_cast(i)); - engine.EndStep(); - } - engine.Close(); -} - -void Reader(const Dims &shape, const Dims &start, const Dims &count, - const size_t steps, const adios2::Params &engineParams, - const std::string &name) -{ - adios2::ADIOS adios(mpiComm); - adios2::IO dataManIO = adios.DeclareIO("Test"); - dataManIO.SetEngine("ssc"); - dataManIO.SetParameters(engineParams); - adios2::Engine engine = dataManIO.Open(name, adios2::Mode::Read); - engine.LockReaderSelections(); - - size_t datasize = - std::accumulate(count.begin(), count.end(), static_cast(1), - std::multiplies()); - std::vector myChars(datasize); - std::vector myUChars(datasize); - std::vector myShorts(datasize); - std::vector myUShorts(datasize); - std::vector myInts(datasize); - std::vector myUInts(datasize); - std::vector myFloats(datasize); - std::vector myDoubles(datasize); - std::vector> myComplexes(datasize); - std::vector> myDComplexes(datasize); - - while (true) - { - adios2::StepStatus status = engine.BeginStep(StepMode::Read, 5); - if (status == adios2::StepStatus::OK) - { - const auto &vars = dataManIO.AvailableVariables(); - ASSERT_EQ(vars.size(), 11); - size_t currentStep = engine.CurrentStep(); - adios2::Variable bpChars = - dataManIO.InquireVariable("bpChars"); - adios2::Variable bpUChars = - dataManIO.InquireVariable("bpUChars"); - adios2::Variable bpShorts = - dataManIO.InquireVariable("bpShorts"); - adios2::Variable bpUShorts = - dataManIO.InquireVariable("bpUShorts"); - adios2::Variable bpInts = - dataManIO.InquireVariable("bpInts"); - adios2::Variable bpUInts = - dataManIO.InquireVariable("bpUInts"); - adios2::Variable bpFloats = - dataManIO.InquireVariable("bpFloats"); - adios2::Variable bpDoubles = - dataManIO.InquireVariable("bpDoubles"); - adios2::Variable> bpComplexes = - dataManIO.InquireVariable>("bpComplexes"); - adios2::Variable> bpDComplexes = - dataManIO.InquireVariable>("bpDComplexes"); - auto scalarInt = dataManIO.InquireVariable("scalarInt"); - - bpChars.SetSelection({start, count}); - bpUChars.SetSelection({start, count}); - bpShorts.SetSelection({start, count}); - bpUShorts.SetSelection({start, count}); - bpInts.SetSelection({start, count}); - bpUInts.SetSelection({start, count}); - bpFloats.SetSelection({start, count}); - bpDoubles.SetSelection({start, count}); - bpComplexes.SetSelection({start, count}); - bpDComplexes.SetSelection({start, count}); - - engine.Get(bpChars, myChars.data(), adios2::Mode::Sync); - engine.Get(bpUChars, myUChars.data(), adios2::Mode::Sync); - engine.Get(bpShorts, myShorts.data(), adios2::Mode::Sync); - engine.Get(bpUShorts, myUShorts.data(), adios2::Mode::Sync); - engine.Get(bpInts, myInts.data(), adios2::Mode::Sync); - engine.Get(bpUInts, myUInts.data(), adios2::Mode::Sync); - engine.Get(bpFloats, myFloats.data(), adios2::Mode::Sync); - engine.Get(bpDoubles, myDoubles.data(), adios2::Mode::Sync); - engine.Get(bpComplexes, myComplexes.data(), adios2::Mode::Sync); - engine.Get(bpDComplexes, myDComplexes.data(), adios2::Mode::Sync); - int i; - engine.Get(scalarInt, &i, adios2::Mode::Sync); - - ASSERT_EQ(i, currentStep); - - VerifyData(myChars.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUChars.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myShorts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUShorts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myInts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUInts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myFloats.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myDoubles.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myComplexes.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myDComplexes.data(), currentStep, start, count, shape, - mpiRank); - engine.EndStep(); - } - else if (status == adios2::StepStatus::EndOfStream) - { - std::cout << "[Rank " + std::to_string(mpiRank) + - "] SscTest reader end of stream!" - << std::endl; - break; - } - } - auto attInt = dataManIO.InquireAttribute("AttInt"); - std::cout << "[Rank " + std::to_string(mpiRank) + "] Attribute received " - << attInt.Data()[0] << ", expected 110" << std::endl; - ASSERT_EQ(110, attInt.Data()[0]); - ASSERT_NE(111, attInt.Data()[0]); - engine.Close(); -} - -TEST_F(SscEngineTest, TestSscOneSidedPostPull) -{ - std::string filename = "TestSscOneSidedPostPull"; - adios2::Params engineParams = {{"MpiMode", "OneSidedPostPull"}}; - - int worldRank, worldSize; - MPI_Comm_rank(MPI_COMM_WORLD, &worldRank); - MPI_Comm_size(MPI_COMM_WORLD, &worldSize); - int mpiGroup = worldRank / (worldSize / 2); - MPI_Comm_split(MPI_COMM_WORLD, mpiGroup, worldRank, &mpiComm); - - MPI_Comm_rank(mpiComm, &mpiRank); - MPI_Comm_size(mpiComm, &mpiSize); - - Dims shape = {10, (size_t)mpiSize * 2}; - Dims start = {2, (size_t)mpiRank * 2}; - Dims count = {5, 2}; - size_t steps = 100; - - if (mpiGroup == 0) - { - Writer(shape, start, count, steps, engineParams, filename); - } - - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - - if (mpiGroup == 1) - { - Reader(shape, start, count, steps, engineParams, filename); - } - - MPI_Barrier(MPI_COMM_WORLD); -} - -int main(int argc, char **argv) -{ - MPI_Init(&argc, &argv); - int worldRank, worldSize; - MPI_Comm_rank(MPI_COMM_WORLD, &worldRank); - MPI_Comm_size(MPI_COMM_WORLD, &worldSize); - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); - - MPI_Finalize(); - return result; -} diff --git a/testing/adios2/engine/ssc/TestSscOneSidedPostPush.cpp b/testing/adios2/engine/ssc/TestSscOneSidedPostPush.cpp deleted file mode 100644 index 453bbaf9c3..0000000000 --- a/testing/adios2/engine/ssc/TestSscOneSidedPostPush.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - */ - -#include "TestSscCommon.h" -#include -#include -#include -#include -#include - -using namespace adios2; -int mpiRank = 0; -int mpiSize = 1; -MPI_Comm mpiComm; - -class SscEngineTest : public ::testing::Test -{ -public: - SscEngineTest() = default; -}; - -void Writer(const Dims &shape, const Dims &start, const Dims &count, - const size_t steps, const adios2::Params &engineParams, - const std::string &name) -{ - size_t datasize = - std::accumulate(count.begin(), count.end(), static_cast(1), - std::multiplies()); - adios2::ADIOS adios(mpiComm); - adios2::IO dataManIO = adios.DeclareIO("WAN"); - dataManIO.SetEngine("ssc"); - dataManIO.SetParameters(engineParams); - std::vector myChars(datasize); - std::vector myUChars(datasize); - std::vector myShorts(datasize); - std::vector myUShorts(datasize); - std::vector myInts(datasize); - std::vector myUInts(datasize); - std::vector myFloats(datasize); - std::vector myDoubles(datasize); - std::vector> myComplexes(datasize); - std::vector> myDComplexes(datasize); - auto bpChars = - dataManIO.DefineVariable("bpChars", shape, start, count); - auto bpUChars = dataManIO.DefineVariable("bpUChars", shape, - start, count); - auto bpShorts = - dataManIO.DefineVariable("bpShorts", shape, start, count); - auto bpUShorts = dataManIO.DefineVariable( - "bpUShorts", shape, start, count); - auto bpInts = dataManIO.DefineVariable("bpInts", shape, start, count); - auto bpUInts = - dataManIO.DefineVariable("bpUInts", shape, start, count); - auto bpFloats = - dataManIO.DefineVariable("bpFloats", shape, start, count); - auto bpDoubles = - dataManIO.DefineVariable("bpDoubles", shape, start, count); - auto bpComplexes = dataManIO.DefineVariable>( - "bpComplexes", shape, start, count); - auto bpDComplexes = dataManIO.DefineVariable>( - "bpDComplexes", shape, start, count); - auto scalarInt = dataManIO.DefineVariable("scalarInt"); - dataManIO.DefineAttribute("AttInt", 110); - adios2::Engine engine = dataManIO.Open(name, adios2::Mode::Write); - engine.LockWriterDefinitions(); - for (size_t i = 0; i < steps; ++i) - { - engine.BeginStep(); - GenData(myChars, i, start, count, shape); - GenData(myUChars, i, start, count, shape); - GenData(myShorts, i, start, count, shape); - GenData(myUShorts, i, start, count, shape); - GenData(myInts, i, start, count, shape); - GenData(myUInts, i, start, count, shape); - GenData(myFloats, i, start, count, shape); - GenData(myDoubles, i, start, count, shape); - GenData(myComplexes, i, start, count, shape); - GenData(myDComplexes, i, start, count, shape); - engine.Put(bpChars, myChars.data(), adios2::Mode::Sync); - engine.Put(bpUChars, myUChars.data(), adios2::Mode::Sync); - engine.Put(bpShorts, myShorts.data(), adios2::Mode::Sync); - engine.Put(bpUShorts, myUShorts.data(), adios2::Mode::Sync); - engine.Put(bpInts, myInts.data(), adios2::Mode::Sync); - engine.Put(bpUInts, myUInts.data(), adios2::Mode::Sync); - engine.Put(bpFloats, myFloats.data(), adios2::Mode::Sync); - engine.Put(bpDoubles, myDoubles.data(), adios2::Mode::Sync); - engine.Put(bpComplexes, myComplexes.data(), adios2::Mode::Sync); - engine.Put(bpDComplexes, myDComplexes.data(), adios2::Mode::Sync); - engine.Put(scalarInt, static_cast(i)); - engine.EndStep(); - } - engine.Close(); -} - -void Reader(const Dims &shape, const Dims &start, const Dims &count, - const size_t steps, const adios2::Params &engineParams, - const std::string &name) -{ - adios2::ADIOS adios(mpiComm); - adios2::IO dataManIO = adios.DeclareIO("Test"); - dataManIO.SetEngine("ssc"); - dataManIO.SetParameters(engineParams); - adios2::Engine engine = dataManIO.Open(name, adios2::Mode::Read); - engine.LockReaderSelections(); - - size_t datasize = - std::accumulate(count.begin(), count.end(), static_cast(1), - std::multiplies()); - std::vector myChars(datasize); - std::vector myUChars(datasize); - std::vector myShorts(datasize); - std::vector myUShorts(datasize); - std::vector myInts(datasize); - std::vector myUInts(datasize); - std::vector myFloats(datasize); - std::vector myDoubles(datasize); - std::vector> myComplexes(datasize); - std::vector> myDComplexes(datasize); - - while (true) - { - adios2::StepStatus status = engine.BeginStep(StepMode::Read, 5); - if (status == adios2::StepStatus::OK) - { - const auto &vars = dataManIO.AvailableVariables(); - ASSERT_EQ(vars.size(), 11); - size_t currentStep = engine.CurrentStep(); - adios2::Variable bpChars = - dataManIO.InquireVariable("bpChars"); - adios2::Variable bpUChars = - dataManIO.InquireVariable("bpUChars"); - adios2::Variable bpShorts = - dataManIO.InquireVariable("bpShorts"); - adios2::Variable bpUShorts = - dataManIO.InquireVariable("bpUShorts"); - adios2::Variable bpInts = - dataManIO.InquireVariable("bpInts"); - adios2::Variable bpUInts = - dataManIO.InquireVariable("bpUInts"); - adios2::Variable bpFloats = - dataManIO.InquireVariable("bpFloats"); - adios2::Variable bpDoubles = - dataManIO.InquireVariable("bpDoubles"); - adios2::Variable> bpComplexes = - dataManIO.InquireVariable>("bpComplexes"); - adios2::Variable> bpDComplexes = - dataManIO.InquireVariable>("bpDComplexes"); - auto scalarInt = dataManIO.InquireVariable("scalarInt"); - - bpChars.SetSelection({start, count}); - bpUChars.SetSelection({start, count}); - bpShorts.SetSelection({start, count}); - bpUShorts.SetSelection({start, count}); - bpInts.SetSelection({start, count}); - bpUInts.SetSelection({start, count}); - bpFloats.SetSelection({start, count}); - bpDoubles.SetSelection({start, count}); - bpComplexes.SetSelection({start, count}); - bpDComplexes.SetSelection({start, count}); - - engine.Get(bpChars, myChars.data(), adios2::Mode::Sync); - engine.Get(bpUChars, myUChars.data(), adios2::Mode::Sync); - engine.Get(bpShorts, myShorts.data(), adios2::Mode::Sync); - engine.Get(bpUShorts, myUShorts.data(), adios2::Mode::Sync); - engine.Get(bpInts, myInts.data(), adios2::Mode::Sync); - engine.Get(bpUInts, myUInts.data(), adios2::Mode::Sync); - engine.Get(bpFloats, myFloats.data(), adios2::Mode::Sync); - engine.Get(bpDoubles, myDoubles.data(), adios2::Mode::Sync); - engine.Get(bpComplexes, myComplexes.data(), adios2::Mode::Sync); - engine.Get(bpDComplexes, myDComplexes.data(), adios2::Mode::Sync); - int i; - engine.Get(scalarInt, &i, adios2::Mode::Sync); - - ASSERT_EQ(i, currentStep); - - VerifyData(myChars.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUChars.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myShorts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUShorts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myInts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myUInts.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myFloats.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myDoubles.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myComplexes.data(), currentStep, start, count, shape, - mpiRank); - VerifyData(myDComplexes.data(), currentStep, start, count, shape, - mpiRank); - engine.EndStep(); - } - else if (status == adios2::StepStatus::EndOfStream) - { - std::cout << "[Rank " + std::to_string(mpiRank) + - "] SscTest reader end of stream!" - << std::endl; - break; - } - } - auto attInt = dataManIO.InquireAttribute("AttInt"); - std::cout << "[Rank " + std::to_string(mpiRank) + "] Attribute received " - << attInt.Data()[0] << ", expected 110" << std::endl; - ASSERT_EQ(110, attInt.Data()[0]); - ASSERT_NE(111, attInt.Data()[0]); - engine.Close(); -} - -TEST_F(SscEngineTest, TestSscOneSidedPostPush) -{ - std::string filename = "TestSscOneSidedPostPush"; - adios2::Params engineParams = {{"MpiMode", "OneSidedPostPush"}}; - - int worldRank, worldSize; - MPI_Comm_rank(MPI_COMM_WORLD, &worldRank); - MPI_Comm_size(MPI_COMM_WORLD, &worldSize); - int mpiGroup = worldRank / (worldSize / 2); - MPI_Comm_split(MPI_COMM_WORLD, mpiGroup, worldRank, &mpiComm); - - MPI_Comm_rank(mpiComm, &mpiRank); - MPI_Comm_size(mpiComm, &mpiSize); - - Dims shape = {10, (size_t)mpiSize * 2}; - Dims start = {2, (size_t)mpiRank * 2}; - Dims count = {5, 2}; - size_t steps = 100; - - if (mpiGroup == 0) - { - Writer(shape, start, count, steps, engineParams, filename); - } - - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - - if (mpiGroup == 1) - { - Reader(shape, start, count, steps, engineParams, filename); - } - - MPI_Barrier(MPI_COMM_WORLD); -} - -int main(int argc, char **argv) -{ - MPI_Init(&argc, &argv); - int worldRank, worldSize; - MPI_Comm_rank(MPI_COMM_WORLD, &worldRank); - MPI_Comm_size(MPI_COMM_WORLD, &worldSize); - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); - - MPI_Finalize(); - return result; -}