Skip to content
Snippets Groups Projects
Commit 7920ce7a authored by Atkins, Charles Vernon's avatar Atkins, Charles Vernon Committed by GitHub
Browse files

Merge pull request #252 from HaochengLIU/Engine-bp-tests-in-parallel

Make all Bp engine tests able to run in parallel
parents 63521144 4de726ce
No related branches found
No related tags found
No related merge requests found
...@@ -4,31 +4,48 @@ ...@@ -4,31 +4,48 @@
#------------------------------------------------------------------------------# #------------------------------------------------------------------------------#
# MPI versions of the test are not properly implemented at the moment # MPI versions of the test are not properly implemented at the moment
if(NOT ADIOS2_HAVE_MPI)
add_executable(TestBPWriteRead TestBPWriteRead.cpp)
if(ADIOS2_HAVE_ADIOS1) target_link_libraries(TestBPWriteRead adios2 gtest adios1::adios)
add_executable(TestBPWriteRead TestBPWriteRead.cpp)
target_link_libraries(TestBPWriteRead adios2 gtest adios1::adios) add_executable(TestBPWriteReadAttributes TestBPWriteReadAttributes.cpp)
target_link_libraries(TestBPWriteReadAttributes adios2 gtest adios1::adios)
add_executable(TestBPWriteReadAttributes TestBPWriteReadAttributes.cpp)
target_link_libraries(TestBPWriteReadAttributes adios2 gtest adios1::adios) add_executable(TestBPWriteReadstdio TestBPWriteReadstdio.cpp)
target_link_libraries(TestBPWriteReadstdio adios2 gtest adios1::adios)
add_executable(TestBPWriteReadstdio TestBPWriteReadstdio.cpp)
target_link_libraries(TestBPWriteReadstdio adios2 gtest adios1::adios) add_executable(TestBPWriteReadfstream TestBPWriteReadfstream.cpp)
target_link_libraries(TestBPWriteReadfstream adios2 gtest adios1::adios)
add_executable(TestBPWriteReadfstream TestBPWriteReadfstream.cpp)
target_link_libraries(TestBPWriteReadfstream adios2 gtest adios1::adios) add_executable(TestBPWriteProfilingJSON TestBPWriteProfilingJSON.cpp)
target_link_libraries(TestBPWriteProfilingJSON
gtest_add_tests(TARGET TestBPWriteRead) adios2 gtest NLohmannJson
gtest_add_tests(TARGET TestBPWriteReadAttributes) )
gtest_add_tests(TARGET TestBPWriteReadstdio)
gtest_add_tests(TARGET TestBPWriteReadfstream) if(ADIOS2_HAVE_MPI)
endif() target_include_directories(TestBPWriteRead PRIVATE ${MPI_C_INCLUDE_PATH})
target_link_libraries(TestBPWriteRead ${MPI_C_LIBRARIES})
add_executable(TestBPWriteProfilingJSON TestBPWriteProfilingJSON.cpp)
target_link_libraries(TestBPWriteProfilingJSON target_include_directories(TestBPWriteReadAttributes PRIVATE ${MPI_C_INCLUDE_PATH})
adios2 gtest gtest_main NLohmannJson target_link_libraries(TestBPWriteReadAttributes ${MPI_C_LIBRARIES})
target_include_directories(TestBPWriteReadstdio PRIVATE ${MPI_C_INCLUDE_PATH})
target_link_libraries(TestBPWriteReadstdio ${MPI_C_LIBRARIES})
target_include_directories(TestBPWriteReadfstream PRIVATE ${MPI_C_INCLUDE_PATH})
target_link_libraries(TestBPWriteReadfstream ${MPI_C_LIBRARIES})
target_include_directories(TestBPWriteProfilingJSON PRIVATE ${MPI_C_INCLUDE_PATH})
target_link_libraries(TestBPWriteProfilingJSON ${MPI_C_LIBRARIES})
set(extra_test_args
EXEC_WRAPPER
${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS}
) )
gtest_add_tests(TARGET TestBPWriteProfilingJSON)
endif() endif()
gtest_add_tests(TARGET TestBPWriteRead ${extra_test_args})
gtest_add_tests(TARGET TestBPWriteReadAttributes ${extra_test_args})
gtest_add_tests(TARGET TestBPWriteReadstdio ${extra_test_args})
gtest_add_tests(TARGET TestBPWriteReadfstream ${extra_test_args})
gtest_add_tests(TARGET TestBPWriteProfilingJSON ${extra_test_args})
...@@ -38,49 +38,75 @@ public: ...@@ -38,49 +38,75 @@ public:
//****************************************************************************** //******************************************************************************
// ADIOS2 write, native ADIOS1 read // ADIOS2 write, native ADIOS1 read
TEST_F(BPWriteProfilingJSONTest, ADIOS2BPWriteProfilingJSON) TEST_F(BPWriteProfilingJSONTest, DISABLED_ADIOS2BPWriteProfilingJSON)
{ {
std::string fname = "ADIOS2BPWriteProfilingJSON.bp"; // Use a relative path + file name to test path in file name capability
std::string fname;
fname = "foo/ADIOS2BPWriteProfilingJSON.bp";
int mpiRank = 0, mpiSize = 1;
// Number of rows
const std::size_t Nx = 8;
// Number of steps
const std::size_t NSteps = 3;
#ifdef ADIOS2_HAVE_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif
// Write test data and profiling.json using ADIOS2 // Write test data and profiling.json using ADIOS2
{ {
#ifdef ADIOS2_HAVE_MPI
adios2::ADIOS adios(MPI_COMM_WORLD, adios2::DebugON);
#else
adios2::ADIOS adios(true); adios2::ADIOS adios(true);
#endif
adios2::IO &io = adios.DeclareIO("TestIO"); adios2::IO &io = adios.DeclareIO("TestIO");
// Declare 1D variables // Declare 1D variables (NumOfProcesses * Nx)
// The local process' part (start, count) can be defined now or later
// before Write().
{ {
auto &var_i8 = adios2::Dims shape{static_cast<unsigned int>(Nx * mpiSize)};
io.DefineVariable<int8_t>("i8", {}, {}, adios2::Dims{8}); adios2::Dims start{static_cast<unsigned int>(Nx * mpiRank)};
adios2::Dims count{static_cast<unsigned int>(Nx)};
auto &var_i8 = io.DefineVariable<int8_t>("i8", shape, start, count);
auto &var_i16 = auto &var_i16 =
io.DefineVariable<int16_t>("i16", {}, {}, adios2::Dims{8}); io.DefineVariable<int16_t>("i16", shape, start, count);
auto &var_i32 = auto &var_i32 =
io.DefineVariable<int32_t>("i32", {}, {}, adios2::Dims{8}); io.DefineVariable<int32_t>("i32", shape, start, count);
auto &var_i64 = auto &var_i64 =
io.DefineVariable<int64_t>("i64", {}, {}, adios2::Dims{8}); io.DefineVariable<int64_t>("i64", shape, start, count);
auto &var_u8 = auto &var_u8 =
io.DefineVariable<uint8_t>("u8", {}, {}, adios2::Dims{8}); io.DefineVariable<uint8_t>("u8", shape, start, count);
auto &var_u16 = auto &var_u16 =
io.DefineVariable<uint16_t>("u16", {}, {}, adios2::Dims{8}); io.DefineVariable<uint16_t>("u16", shape, start, count);
auto &var_u32 = auto &var_u32 =
io.DefineVariable<uint32_t>("u32", {}, {}, adios2::Dims{8}); io.DefineVariable<uint32_t>("u32", shape, start, count);
auto &var_u64 = auto &var_u64 =
io.DefineVariable<uint64_t>("u64", {}, {}, adios2::Dims{8}); io.DefineVariable<uint64_t>("u64", shape, start, count);
auto &var_r32 = auto &var_r32 =
io.DefineVariable<float>("r32", {}, {}, adios2::Dims{8}); io.DefineVariable<float>("r32", shape, start, count);
auto &var_r64 = auto &var_r64 =
io.DefineVariable<double>("r64", {}, {}, adios2::Dims{8}); io.DefineVariable<double>("r64", shape, start, count);
} }
// Create the BP Engine // Create the BP Engine
io.SetEngine("BPFileWriter"); io.SetEngine("BPFileWriter");
io.SetParameters({{"Threads", "2"}}); io.SetParameters({{"Threads", "2"}});
io.AddTransport("File", {{"Library", "POSIX"}}); io.AddTransport("file", {{"Library", "POSIX"}});
auto engine = io.Open(fname, adios2::OpenMode::Write); auto engine = io.Open(fname, adios2::OpenMode::Write);
ASSERT_NE(engine.get(), nullptr); ASSERT_NE(engine.get(), nullptr);
for (size_t step = 0; step < 3; ++step) for (size_t step = 0; step < NSteps; ++step)
{ {
// Generate test data for each process uniquely
SmallTestData currentTestData =
generateNewSmallTestData(m_TestData, step, mpiRank, mpiSize);
// Retrieve the variables that previously went out of scope // Retrieve the variables that previously went out of scope
auto &var_i8 = io.GetVariable<int8_t>("i8"); auto &var_i8 = io.GetVariable<int8_t>("i8");
auto &var_i16 = io.GetVariable<int16_t>("i16"); auto &var_i16 = io.GetVariable<int16_t>("i16");
...@@ -93,22 +119,37 @@ TEST_F(BPWriteProfilingJSONTest, ADIOS2BPWriteProfilingJSON) ...@@ -93,22 +119,37 @@ TEST_F(BPWriteProfilingJSONTest, ADIOS2BPWriteProfilingJSON)
auto &var_r32 = io.GetVariable<float>("r32"); auto &var_r32 = io.GetVariable<float>("r32");
auto &var_r64 = io.GetVariable<double>("r64"); auto &var_r64 = io.GetVariable<double>("r64");
// Make a 1D selection to describe the local dimensions of the
// variable we write and its offsets in the global spaces
adios2::SelectionBoundingBox sel({mpiRank * Nx}, {Nx});
var_i8.SetSelection(sel);
var_i16.SetSelection(sel);
var_i32.SetSelection(sel);
var_i64.SetSelection(sel);
var_u8.SetSelection(sel);
var_u16.SetSelection(sel);
var_u32.SetSelection(sel);
var_u64.SetSelection(sel);
var_r32.SetSelection(sel);
var_r64.SetSelection(sel);
// Write each one // Write each one
engine->Write(var_i8, m_TestData.I8.data() + step); // fill in the variable with values from starting index to
engine->Write(var_i16, m_TestData.I16.data() + step); // starting index + count
engine->Write(var_i32, m_TestData.I32.data() + step); engine->Write(var_i8, currentTestData.I8.data());
engine->Write(var_i64, m_TestData.I64.data() + step); engine->Write(var_i16, currentTestData.I16.data());
engine->Write(var_u8, m_TestData.U8.data() + step); engine->Write(var_i32, currentTestData.I32.data());
engine->Write(var_u16, m_TestData.U16.data() + step); engine->Write(var_i64, currentTestData.I64.data());
engine->Write(var_u32, m_TestData.U32.data() + step); engine->Write(var_u8, currentTestData.U8.data());
engine->Write(var_u64, m_TestData.U64.data() + step); engine->Write(var_u16, currentTestData.U16.data());
engine->Write(var_r32, m_TestData.R32.data() + step); engine->Write(var_u32, currentTestData.U32.data());
engine->Write(var_r64, m_TestData.R64.data() + step); engine->Write(var_u64, currentTestData.U64.data());
engine->Write(var_r32, currentTestData.R32.data());
engine->Write(var_r64, currentTestData.R64.data());
// Advance to the next time step // Advance to the next time step
engine->Advance(); engine->Advance();
} }
// Close the file // Close the file
engine->Close(); engine->Close();
} }
...@@ -116,25 +157,43 @@ TEST_F(BPWriteProfilingJSONTest, ADIOS2BPWriteProfilingJSON) ...@@ -116,25 +157,43 @@ TEST_F(BPWriteProfilingJSONTest, ADIOS2BPWriteProfilingJSON)
// open json file, parse it to a json structure, and verify a few things // open json file, parse it to a json structure, and verify a few things
{ {
std::ifstream profilingJSONFile(fname + ".dir/profiling.json"); std::ifstream profilingJSONFile(fname + ".dir/profiling.json");
std::stringstream buffer; const json profilingJSON = json::parse(profilingJSONFile);
buffer << profilingJSONFile.rdbuf();
const json profilingJSON = json::parse(buffer);
// check rank is zero // check rank is zero
const int rank = profilingJSON[0].value("rank", -1); const int rank = profilingJSON[mpiRank].value("rank", -1);
ASSERT_EQ(rank, 0); ASSERT_EQ(rank, mpiRank);
// check threads // check threads
const int threads = profilingJSON[0].value("threads", 0); const int threads = profilingJSON[mpiRank].value("threads", 0);
ASSERT_EQ(threads, 2); ASSERT_EQ(threads, 2);
// check bytes // check bytes
const unsigned long int bytes = profilingJSON[0].value("bytes", 0UL); const unsigned long int bytes =
profilingJSON[mpiRank].value("bytes", 0UL);
ASSERT_EQ(bytes, 6536); ASSERT_EQ(bytes, 6536);
const auto transportType = const auto transportType =
profilingJSON[0]["transport_0"].value("type", "0"); profilingJSON[mpiRank]["transport_0"].value("type", "0");
ASSERT_EQ(transportType, "File_POSIX"); ASSERT_EQ(transportType, "File_POSIX");
} }
} }
//******************************************************************************
// main
//******************************************************************************
int main(int argc, char **argv)
{
#ifdef ADIOS2_HAVE_MPI
MPI_Init(nullptr, nullptr);
#endif
::testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();
#ifdef ADIOS2_HAVE_MPI
MPI_Finalize();
#endif
return result;
}
This diff is collapsed.
...@@ -30,33 +30,76 @@ public: ...@@ -30,33 +30,76 @@ public:
// ADIOS2 write, native ADIOS1 read for single value attributes // ADIOS2 write, native ADIOS1 read for single value attributes
TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadSingleTypes) TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadSingleTypes)
{ {
std::string fname = "ADIOS2BPWriteAttributeADIOS1ReadSingleTypes.bp"; std::string fname = "foo/ADIOS2BPWriteAttributeADIOS1ReadSingleTypes.bp";
std::string fRootName = "ADIOS2BPWriteAttributeADIOS1ReadSingleTypes.bp";
// Write test data using ADIOS2 int mpiRank = 0, mpiSize = 1;
#ifdef ADIOS2_HAVE_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize);
#endif
// FIXME: Since collective meta generation has not landed yet, so there is
// no way for us to gather different attribute data per process. Ideally we
// should use unique attribute data per process. Ex:
// std::to_string(mpiRank);
std::string mpiRankString = std::to_string(0);
std::string s1_Single = std::string("s1_Single_") + mpiRankString;
std::string i8_Single = std::string("i8_Single_") + mpiRankString;
std::string i16_Single = std::string("i16_Single_") + mpiRankString;
std::string i32_Single = std::string("i32_Single_") + mpiRankString;
std::string i64_Single = std::string("i64_Single_") + mpiRankString;
std::string u8_Single = std::string("u8_Single_") + mpiRankString;
std::string u16_Single = std::string("u16_Single_") + mpiRankString;
std::string u32_Single = std::string("u32_Single_") + mpiRankString;
std::string u64_Single = std::string("u64_Single_") + mpiRankString;
std::string float_Single = std::string("float_Single_") + mpiRankString;
std::string double_Single = std::string("double_Single_") + mpiRankString;
// When collective meta generation has landed, use
// generateNewSmallTestData(m_TestData, 0, 0, mpiSize);
// Generate current testing data
SmallTestData currentTestData =
generateNewSmallTestData(m_TestData, 0, 0, 0);
// Write test data using BP
{ {
#ifdef ADIOS2_HAVE_MPI
adios2::ADIOS adios(MPI_COMM_WORLD, adios2::DebugON);
#else
adios2::ADIOS adios(true); adios2::ADIOS adios(true);
#endif
adios2::IO &io = adios.DeclareIO("TestIO"); adios2::IO &io = adios.DeclareIO("TestIO");
// Declare Single Value Attributes // Declare Single Value Attributes
{ {
io.DefineAttribute<std::string>("s1_Single", m_TestData.S1); io.DefineAttribute<std::string>(s1_Single, currentTestData.S1);
io.DefineAttribute<int8_t>("i8_Single", m_TestData.I8.front()); io.DefineAttribute<int8_t>(i8_Single, currentTestData.I8.front());
io.DefineAttribute<int16_t>("i16_Single", m_TestData.I16.front()); io.DefineAttribute<int16_t>(i16_Single,
io.DefineAttribute<int32_t>("i32_Single", m_TestData.I32.front()); currentTestData.I16.front());
io.DefineAttribute<int64_t>("i64_Single", m_TestData.I64.front()); io.DefineAttribute<int32_t>(i32_Single,
currentTestData.I32.front());
io.DefineAttribute<uint8_t>("u8_Single", m_TestData.U8.front()); io.DefineAttribute<int64_t>(i64_Single,
io.DefineAttribute<uint16_t>("u16_Single", m_TestData.U16.front()); currentTestData.I64.front());
io.DefineAttribute<uint32_t>("u32_Single", m_TestData.U32.front());
io.DefineAttribute<uint64_t>("u64_Single", m_TestData.U64.front()); io.DefineAttribute<uint8_t>(u8_Single, currentTestData.U8.front());
io.DefineAttribute<uint16_t>(u16_Single,
io.DefineAttribute<float>("float_Single", m_TestData.R32.front()); currentTestData.U16.front());
io.DefineAttribute<double>("double_Single", m_TestData.R64.front()); io.DefineAttribute<uint32_t>(u32_Single,
currentTestData.U32.front());
io.DefineAttribute<uint64_t>(u64_Single,
currentTestData.U64.front());
io.DefineAttribute<float>(float_Single,
currentTestData.R32.front());
io.DefineAttribute<double>(double_Single,
currentTestData.R64.front());
} }
// Create the BP Engine // Create the BP Engine
io.SetEngine("BPFileWriter"); io.SetEngine("BPFileWriter");
io.AddTransport("File");
io.AddTransport("file");
auto engine = io.Open(fname, adios2::OpenMode::Write); auto engine = io.Open(fname, adios2::OpenMode::Write);
ASSERT_NE(engine.get(), nullptr); ASSERT_NE(engine.get(), nullptr);
...@@ -65,93 +108,97 @@ TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadSingleTypes) ...@@ -65,93 +108,97 @@ TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadSingleTypes)
engine->Close(); engine->Close();
} }
// Read test data using ADIOS1
#ifdef ADIOS2_HAVE_MPI
// Read everything from rank 0
int rank;
MPI_Comm_rank();
if (rank == 0)
#endif
{ {
adios_read_init_method(ADIOS_READ_METHOD_BP, MPI_COMM_WORLD, adios_read_init_method(ADIOS_READ_METHOD_BP, MPI_COMM_SELF,
"verbose=3"); "verbose=3");
// Open the file for reading // Open the file for reading
ADIOS_FILE *f = ADIOS_FILE *f = adios_read_open_file(
adios_read_open_file((fname + ".dir/" + fname + ".0").c_str(), (fname + ".dir/" + fRootName + "." + mpiRankString).c_str(),
ADIOS_READ_METHOD_BP, MPI_COMM_WORLD); ADIOS_READ_METHOD_BP, MPI_COMM_SELF);
ASSERT_NE(f, nullptr); ASSERT_NE(f, nullptr);
int size, status; int size, status;
enum ADIOS_DATATYPES type; enum ADIOS_DATATYPES type;
void *data = nullptr; void *data = nullptr;
status = adios_get_attr(f, "s1_Single", &type, &size, &data); // status = adios_get_attr(f, "s1_Single_0", &type, &size, &data);
status = adios_get_attr(f, s1_Single.c_str(), &type, &size, &data);
ASSERT_EQ(status, 0); ASSERT_EQ(status, 0);
ASSERT_NE(data, nullptr); ASSERT_NE(data, nullptr);
ASSERT_EQ(type, adios_string); ASSERT_EQ(type, adios_string);
std::string singleStringAttribute(reinterpret_cast<char *>(data), size); std::string singleStringAttribute(reinterpret_cast<char *>(data), size);
ASSERT_STREQ(singleStringAttribute.c_str(), m_TestData.S1.c_str()); ASSERT_STREQ(singleStringAttribute.c_str(), currentTestData.S1.c_str());
status = adios_get_attr(f, "i8_Single", &type, &size, &data); status = adios_get_attr(f, i8_Single.c_str(), &type, &size, &data);
ASSERT_EQ(status, 0); ASSERT_EQ(status, 0);
ASSERT_NE(data, nullptr); ASSERT_NE(data, nullptr);
ASSERT_EQ(type, adios_byte); ASSERT_EQ(type, adios_byte);
ASSERT_EQ(*reinterpret_cast<int8_t *>(data), m_TestData.I8.front()); ASSERT_EQ(*reinterpret_cast<int8_t *>(data),
currentTestData.I8.front());
status = adios_get_attr(f, "i16_Single", &type, &size, &data); status = adios_get_attr(f, i16_Single.c_str(), &type, &size, &data);
ASSERT_EQ(status, 0); ASSERT_EQ(status, 0);
ASSERT_NE(data, nullptr); ASSERT_NE(data, nullptr);
ASSERT_EQ(type, adios_short); ASSERT_EQ(type, adios_short);
ASSERT_EQ(*reinterpret_cast<int16_t *>(data), m_TestData.I16.front()); ASSERT_EQ(*reinterpret_cast<int16_t *>(data),
currentTestData.I16.front());
status = adios_get_attr(f, "i32_Single", &type, &size, &data); status = adios_get_attr(f, i32_Single.c_str(), &type, &size, &data);
ASSERT_EQ(status, 0); ASSERT_EQ(status, 0);
ASSERT_NE(data, nullptr); ASSERT_NE(data, nullptr);
ASSERT_EQ(type, adios_integer); ASSERT_EQ(type, adios_integer);
ASSERT_EQ(*reinterpret_cast<int32_t *>(data), m_TestData.I32.front()); ASSERT_EQ(*reinterpret_cast<int32_t *>(data),
currentTestData.I32.front());
status = adios_get_attr(f, "i64_Single", &type, &size, &data); status = adios_get_attr(f, i64_Single.c_str(), &type, &size, &data);
ASSERT_EQ(status, 0); ASSERT_EQ(status, 0);
ASSERT_NE(data, nullptr); ASSERT_NE(data, nullptr);
ASSERT_EQ(type, adios_long); ASSERT_EQ(type, adios_long);
ASSERT_EQ(*reinterpret_cast<int64_t *>(data), m_TestData.I64.front()); ASSERT_EQ(*reinterpret_cast<int64_t *>(data),
currentTestData.I64.front());
status = adios_get_attr(f, "u8_Single", &type, &size, &data); status = adios_get_attr(f, u8_Single.c_str(), &type, &size, &data);
ASSERT_EQ(status, 0); ASSERT_EQ(status, 0);
ASSERT_NE(data, nullptr); ASSERT_NE(data, nullptr);
ASSERT_EQ(type, adios_unsigned_byte); ASSERT_EQ(type, adios_unsigned_byte);
ASSERT_EQ(*reinterpret_cast<uint8_t *>(data), m_TestData.U8.front()); ASSERT_EQ(*reinterpret_cast<uint8_t *>(data),
currentTestData.U8.front());
status = adios_get_attr(f, "u16_Single", &type, &size, &data); status = adios_get_attr(f, u16_Single.c_str(), &type, &size, &data);
ASSERT_EQ(status, 0); ASSERT_EQ(status, 0);
ASSERT_NE(data, nullptr); ASSERT_NE(data, nullptr);
ASSERT_EQ(type, adios_unsigned_short); ASSERT_EQ(type, adios_unsigned_short);
ASSERT_EQ(*reinterpret_cast<uint16_t *>(data), m_TestData.U16.front()); ASSERT_EQ(*reinterpret_cast<uint16_t *>(data),
currentTestData.U16.front());
status = adios_get_attr(f, "u32_Single", &type, &size, &data); status = adios_get_attr(f, u32_Single.c_str(), &type, &size, &data);
ASSERT_EQ(status, 0); ASSERT_EQ(status, 0);
ASSERT_NE(data, nullptr); ASSERT_NE(data, nullptr);
ASSERT_EQ(type, adios_unsigned_integer); ASSERT_EQ(type, adios_unsigned_integer);
ASSERT_EQ(*reinterpret_cast<uint32_t *>(data), m_TestData.U32.front()); ASSERT_EQ(*reinterpret_cast<uint32_t *>(data),
currentTestData.U32.front());
status = adios_get_attr(f, "u64_Single", &type, &size, &data); status = adios_get_attr(f, u64_Single.c_str(), &type, &size, &data);
ASSERT_EQ(status, 0); ASSERT_EQ(status, 0);
ASSERT_NE(data, nullptr); ASSERT_NE(data, nullptr);
ASSERT_EQ(type, adios_unsigned_long); ASSERT_EQ(type, adios_unsigned_long);
ASSERT_EQ(*reinterpret_cast<uint64_t *>(data), m_TestData.U64.front()); ASSERT_EQ(*reinterpret_cast<uint64_t *>(data),
currentTestData.U64.front());
status = adios_get_attr(f, "float_Single", &type, &size, &data); status = adios_get_attr(f, float_Single.c_str(), &type, &size, &data);
ASSERT_EQ(status, 0); ASSERT_EQ(status, 0);
ASSERT_NE(data, nullptr); ASSERT_NE(data, nullptr);
ASSERT_EQ(type, adios_real); ASSERT_EQ(type, adios_real);
ASSERT_EQ(*reinterpret_cast<float *>(data), m_TestData.R32.front()); ASSERT_EQ(*reinterpret_cast<float *>(data),
currentTestData.R32.front());
status = adios_get_attr(f, "double_Single", &type, &size, &data); status = adios_get_attr(f, double_Single.c_str(), &type, &size, &data);
ASSERT_EQ(status, 0); ASSERT_EQ(status, 0);
ASSERT_NE(data, nullptr); ASSERT_NE(data, nullptr);
ASSERT_EQ(type, adios_double); ASSERT_EQ(type, adios_double);
ASSERT_EQ(*reinterpret_cast<double *>(data), m_TestData.R64.front()); ASSERT_EQ(*reinterpret_cast<double *>(data),
currentTestData.R64.front());
// Cleanup file // Cleanup file
adios_read_close(f); adios_read_close(f);
...@@ -161,7 +208,8 @@ TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadSingleTypes) ...@@ -161,7 +208,8 @@ TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadSingleTypes)
// ADIOS2 write, native ADIOS1 read for array attributes // ADIOS2 write, native ADIOS1 read for array attributes
TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadArrayTypes) TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadArrayTypes)
{ {
std::string fname = "ADIOS2BPWriteAttributeADIOS1ReadArrayTypes.bp"; std::string fname = "foo/bar/ADIOS2BPWriteAttributeADIOS1ReadArrayTypes.bp";
std::string fRootName = "ADIOS2BPWriteAttributeADIOS1ReadArrayTypes.bp";
// Write test data using ADIOS2 // Write test data using ADIOS2
{ {
...@@ -198,7 +246,8 @@ TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadArrayTypes) ...@@ -198,7 +246,8 @@ TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadArrayTypes)
// Create the BP Engine // Create the BP Engine
io.SetEngine("BPFileWriter"); io.SetEngine("BPFileWriter");
io.AddTransport("File");
io.AddTransport("file");
auto engine = io.Open(fname, adios2::OpenMode::Write); auto engine = io.Open(fname, adios2::OpenMode::Write);
ASSERT_NE(engine.get(), nullptr); ASSERT_NE(engine.get(), nullptr);
...@@ -207,20 +256,13 @@ TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadArrayTypes) ...@@ -207,20 +256,13 @@ TEST_F(BPWriteReadAttributeTest, ADIOS2BPWriteADIOS1ReadArrayTypes)
engine->Close(); engine->Close();
} }
// Read test data using ADIOS1
#ifdef ADIOS2_HAVE_MPI
// Read everything from rank 0
int rank;
MPI_Comm_rank();
if (rank == 0)
#endif
{ {
adios_read_init_method(ADIOS_READ_METHOD_BP, MPI_COMM_WORLD, adios_read_init_method(ADIOS_READ_METHOD_BP, MPI_COMM_WORLD,
"verbose=3"); "verbose=3");
// Open the file for reading // Open the file for reading
ADIOS_FILE *f = ADIOS_FILE *f =
adios_read_open_file((fname + ".dir/" + fname + ".0").c_str(), adios_read_open_file((fname + ".dir/" + fRootName + ".0").c_str(),
ADIOS_READ_METHOD_BP, MPI_COMM_WORLD); ADIOS_READ_METHOD_BP, MPI_COMM_WORLD);
ASSERT_NE(f, nullptr); ASSERT_NE(f, nullptr);
......
This diff is collapsed.
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