Skip to content

Commit

Permalink
mpiwrap: provide serial ADIOS constructors even when compiled with mpi
Browse files Browse the repository at this point in the history
and add a simple test
  • Loading branch information
germasch committed Jun 3, 2019
1 parent 3991b32 commit 04b7b17
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
3 changes: 1 addition & 2 deletions bindings/CXX11/cxx11/ADIOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ ADIOS::ADIOS(MPI_Comm comm, const bool debugMode) : ADIOS("", comm, debugMode)
{
}

#else
#endif
ADIOS::ADIOS(const std::string &configFile, const bool debugMode)
: m_ADIOS(std::make_shared<core::ADIOS>(configFile, debugMode, "C++"))
{
}

ADIOS::ADIOS(const bool debugMode) : ADIOS("", debugMode) {}
#endif

ADIOS::operator bool() const noexcept { return m_ADIOS ? true : false; }

Expand Down
5 changes: 2 additions & 3 deletions bindings/CXX11/cxx11/ADIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class ADIOS
* @exception std::invalid_argument in debugMode = true if user input is
* incorrect
*/
ADIOS(const std::string &configFile = "", MPI_Comm comm = MPI_COMM_SELF,
ADIOS(const std::string &configFile, MPI_Comm comm,
const bool debugMode = true);
#else
#endif

/**
* Starting point for non-MPI serial apps. Creates an ADIOS object allowing
Expand All @@ -87,7 +87,6 @@ class ADIOS
* incorrect
*/
ADIOS(const bool debugMode = true);
#endif

/** object inspection true: valid object, false: invalid object */
explicit operator bool() const noexcept;
Expand Down
4 changes: 4 additions & 0 deletions testing/adios2/interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ target_link_libraries(TestADIOSDefineVariable adios2 gtest)
add_executable(TestADIOSDefineAttribute TestADIOSDefineAttribute.cpp)
target_link_libraries(TestADIOSDefineAttribute adios2 gtest)

add_executable(TestADIOSNoMpi TestADIOSNoMpi.cpp)
target_link_libraries(TestADIOSNoMpi adios2 gtest)

if(ADIOS2_HAVE_MPI)
target_link_libraries(TestADIOSInterface MPI::MPI_C)
target_link_libraries(TestADIOSInterfaceWrite MPI::MPI_C)
Expand All @@ -28,3 +31,4 @@ gtest_add_tests(TARGET TestADIOSInterface ${extra_test_args})
gtest_add_tests(TARGET TestADIOSInterfaceWrite ${extra_test_args})
gtest_add_tests(TARGET TestADIOSDefineVariable ${extra_test_args})
gtest_add_tests(TARGET TestADIOSDefineAttribute ${extra_test_args})
gtest_add_tests(TARGET TestADIOSNoMpi ${extra_test_args})
29 changes: 29 additions & 0 deletions testing/adios2/interface/TestADIOSNoMpi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

#include <adios2.h>

#include <gtest/gtest.h>

/**
* Basic test to see that writing and reading a simple BP3 file works without
* initializing MPI
*/
TEST(ADIOSInterface, ADIOSNoMpi)
{
adios2::ADIOS adios(adios2::DebugON);
{
adios2::IO io = adios.DeclareIO("TestIOWrite");
adios2::Engine engine = io.Open("test.bp", adios2::Mode::Write);
engine.Close();
}
{
adios2::IO io = adios.DeclareIO("TestIORead");
adios2::Engine engine = io.Open("test.bp", adios2::Mode::Read);
engine.Close();
}
}

int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit 04b7b17

Please sign in to comment.