Skip to content

Commit

Permalink
tests: long double complex
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Dec 20, 2019
1 parent c945b39 commit 54bde93
Show file tree
Hide file tree
Showing 9 changed files with 401 additions and 1 deletion.
22 changes: 22 additions & 0 deletions testing/adios2/engine/SmallTestData.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ struct SmallTestData
std::complex<double>(14.2, 15.2), std::complex<double>(15.2, 16.2),
std::complex<double>(16.2, 17.2), std::complex<double>(17.2, 18.2),
std::complex<double>(18.2, 19.2), std::complex<double>(19.2, 20.2)}};

std::array<std::complex<long double>, 10> CR128 = {
{std::complex<long double>(410.2, 411.2),
std::complex<long double>(411.2, 412.2),
std::complex<long double>(412.2, 413.2),
std::complex<long double>(413.2, 414.2),
std::complex<long double>(414.2, 415.2),
std::complex<long double>(415.2, 416.2),
std::complex<long double>(416.2, 417.2),
std::complex<long double>(417.2, 418.2),
std::complex<long double>(418.2, 419.2),
std::complex<long double>(419.2, 420.2)}};
};

SmallTestData generateNewSmallTestData(SmallTestData in, int step, int rank,
Expand Down Expand Up @@ -90,6 +102,11 @@ SmallTestData generateNewSmallTestData(SmallTestData in, int step, int rank,
v.real(v.real() + static_cast<double>(j));
v.imag(v.imag() + static_cast<double>(j));
});
std::for_each(in.CR128.begin(), in.CR128.end(),
[&](std::complex<long double> &v) {
v.real(v.real() + static_cast<long double>(j));
v.imag(v.imag() + static_cast<long double>(j));
});

return in;
}
Expand Down Expand Up @@ -118,6 +135,11 @@ void UpdateSmallTestData(SmallTestData &in, int step, int rank, int size)
v.real(v.real() + static_cast<double>(j));
v.imag(v.imag() + static_cast<double>(j));
});
std::for_each(in.CR128.begin(), in.CR128.end(),
[&](std::complex<long double> &v) {
v.real(v.real() + static_cast<long double>(j));
v.imag(v.imag() + static_cast<long double>(j));
});
}

#endif // TESTING_ADIOS2_ENGINE_SMALLTESTDATA_H_
48 changes: 48 additions & 0 deletions testing/adios2/engine/bp/TestBPWriteReadAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ TEST_F(BPWriteReadAttributes, WriteReadSingleTypes)
const std::string r128_Single = std::string("r128_Single_") + zero;
const std::string cr32_Single = std::string("cr32_Single_") + zero;
const std::string cr64_Single = std::string("cr64_Single_") + zero;
const std::string cr128_Single = std::string("cr128_Single_") + zero;

// When collective meta generation has landed, use
// generateNewSmallTestData(m_TestData, 0, mpiRank, mpiSize);
Expand Down Expand Up @@ -88,6 +89,8 @@ TEST_F(BPWriteReadAttributes, WriteReadSingleTypes)
currentTestData.CR32.front());
io.DefineAttribute<std::complex<double>>(cr64_Single,
currentTestData.CR64.front());
io.DefineAttribute<std::complex<long double>>(
cr128_Single, currentTestData.CR128.front());

if (!engineName.empty())
{
Expand Down Expand Up @@ -136,6 +139,8 @@ TEST_F(BPWriteReadAttributes, WriteReadSingleTypes)
ioRead.InquireAttribute<std::complex<float>>(cr32_Single);
auto attr_cr64 =
ioRead.InquireAttribute<std::complex<double>>(cr64_Single);
auto attr_cr128 =
ioRead.InquireAttribute<std::complex<long double>>(cr128_Single);

EXPECT_TRUE(attr_s1);
ASSERT_EQ(attr_s1.Name(), s1_Single);
Expand Down Expand Up @@ -227,6 +232,13 @@ TEST_F(BPWriteReadAttributes, WriteReadSingleTypes)
ASSERT_EQ(attr_cr64.Type(), adios2::GetType<std::complex<double>>());
ASSERT_EQ(attr_cr64.Data().front(), currentTestData.CR64.front());

EXPECT_TRUE(attr_cr128);
ASSERT_EQ(attr_cr128.Name(), cr128_Single);
ASSERT_EQ(attr_cr128.Data().size() == 1, true);
ASSERT_EQ(attr_cr128.Type(),
adios2::GetType<std::complex<long double>>());
ASSERT_EQ(attr_cr128.Data().front(), currentTestData.CR128.front());

bpRead.Close();
}
}
Expand Down Expand Up @@ -258,6 +270,7 @@ TEST_F(BPWriteReadAttributes, WriteReadArrayTypes)
const std::string r128_Array = std::string("r128_Array_") + zero;
const std::string cr32_Array = std::string("cr32_Array_") + zero;
const std::string cr64_Array = std::string("cr64_Array_") + zero;
const std::string cr128_Array = std::string("cr128_Array_") + zero;

// When collective meta generation has landed, use
// generateNewSmallTestData(m_TestData, 0, mpiRank, mpiSize);
Expand Down Expand Up @@ -309,6 +322,9 @@ TEST_F(BPWriteReadAttributes, WriteReadArrayTypes)
io.DefineAttribute<std::complex<double>>(cr64_Array,
currentTestData.CR64.data(),
currentTestData.CR64.size());
io.DefineAttribute<std::complex<long double>>(
cr128_Array, currentTestData.CR128.data(),
currentTestData.CR128.size());

if (!engineName.empty())
{
Expand Down Expand Up @@ -356,6 +372,8 @@ TEST_F(BPWriteReadAttributes, WriteReadArrayTypes)
ioRead.InquireAttribute<std::complex<float>>(cr32_Array);
auto attr_cr64 =
ioRead.InquireAttribute<std::complex<double>>(cr64_Array);
auto attr_cr128 =
ioRead.InquireAttribute<std::complex<long double>>(cr128_Array);

EXPECT_TRUE(attr_s1);
ASSERT_EQ(attr_s1.Name(), s1_Array);
Expand Down Expand Up @@ -427,6 +445,12 @@ TEST_F(BPWriteReadAttributes, WriteReadArrayTypes)
ASSERT_EQ(attr_cr64.Data().size() == 1, false);
ASSERT_EQ(attr_cr64.Type(), adios2::GetType<std::complex<double>>());

EXPECT_TRUE(attr_cr128);
ASSERT_EQ(attr_cr128.Name(), cr128_Array);
ASSERT_EQ(attr_cr128.Data().size() == 1, false);
ASSERT_EQ(attr_cr128.Type(),
adios2::GetType<std::complex<long double>>());

auto I8 = attr_i8.Data();
auto I16 = attr_i16.Data();
auto I32 = attr_i32.Data();
Expand Down Expand Up @@ -475,6 +499,7 @@ TEST_F(BPWriteReadAttributes, BPWriteReadSingleTypesVar)
const std::string r128_Single = std::string("r128_Single_") + zero;
const std::string cr32_Single = std::string("cr32_Single_") + zero;
const std::string cr64_Single = std::string("cr64_Single_") + zero;
const std::string cr128_Single = std::string("cr128_Single_") + zero;

// When collective meta generation has landed, use
// generateNewSmallTestData(m_TestData, 0, mpiRank, mpiSize);
Expand Down Expand Up @@ -531,6 +556,8 @@ TEST_F(BPWriteReadAttributes, BPWriteReadSingleTypesVar)
cr32_Single, currentTestData.CR32.front(), var.Name());
io.DefineAttribute<std::complex<double>>(
cr64_Single, currentTestData.CR64.front(), var.Name());
io.DefineAttribute<std::complex<long double>>(
cr128_Single, currentTestData.CR128.front(), var.Name());

adios2::Engine engine = io.Open(fName, adios2::Mode::Write);
engine.Put(var, 10);
Expand Down Expand Up @@ -575,6 +602,8 @@ TEST_F(BPWriteReadAttributes, BPWriteReadSingleTypesVar)
cr32_Single, var.Name());
auto attr_cr64 = ioRead.InquireAttribute<std::complex<double>>(
cr64_Single, var.Name());
auto attr_cr128 = ioRead.InquireAttribute<std::complex<long double>>(
cr128_Single, var.Name());

EXPECT_TRUE(attr_s1);
ASSERT_EQ(attr_s1.Name(), var.Name() + separator + s1_Single);
Expand Down Expand Up @@ -660,6 +689,13 @@ TEST_F(BPWriteReadAttributes, BPWriteReadSingleTypesVar)
ASSERT_EQ(attr_cr64.Type(), adios2::GetType<std::complex<double>>());
ASSERT_EQ(attr_cr64.Data().front(), currentTestData.CR64.front());

EXPECT_TRUE(attr_cr128);
ASSERT_EQ(attr_cr128.Name(), var.Name() + separator + cr128_Single);
ASSERT_EQ(attr_cr128.Data().size() == 1, true);
ASSERT_EQ(attr_cr128.Type(),
adios2::GetType<std::complex<long double>>());
ASSERT_EQ(attr_cr128.Data().front(), currentTestData.CR128.front());

bpRead.Close();
}
}
Expand Down Expand Up @@ -691,6 +727,7 @@ TEST_F(BPWriteReadAttributes, WriteReadArrayTypesVar)
const std::string r128_Array = std::string("r128_Array_") + zero;
const std::string cr32_Array = std::string("cr32_Array_") + zero;
const std::string cr64_Array = std::string("cr64_Array_") + zero;
const std::string cr128_Array = std::string("cr128_Array_") + zero;

const std::string separator = "/";

Expand Down Expand Up @@ -743,6 +780,9 @@ TEST_F(BPWriteReadAttributes, WriteReadArrayTypesVar)
io.DefineAttribute<std::complex<double>>(
cr64_Array, currentTestData.CR64.data(),
currentTestData.CR64.size(), var.Name());
io.DefineAttribute<std::complex<long double>>(
cr128_Array, currentTestData.CR128.data(),
currentTestData.CR128.size(), var.Name());

if (!engineName.empty())
{
Expand Down Expand Up @@ -796,6 +836,8 @@ TEST_F(BPWriteReadAttributes, WriteReadArrayTypesVar)
cr32_Array, var.Name());
auto attr_cr64 = ioRead.InquireAttribute<std::complex<double>>(
cr64_Array, var.Name());
auto attr_cr128 = ioRead.InquireAttribute<std::complex<long double>>(
cr128_Array, var.Name());

EXPECT_TRUE(attr_s1);
ASSERT_EQ(attr_s1.Name(), var.Name() + separator + s1_Array);
Expand Down Expand Up @@ -867,6 +909,12 @@ TEST_F(BPWriteReadAttributes, WriteReadArrayTypesVar)
ASSERT_EQ(attr_cr64.Data().size() == 1, false);
ASSERT_EQ(attr_cr64.Type(), adios2::GetType<std::complex<double>>());

EXPECT_TRUE(attr_cr128);
ASSERT_EQ(attr_cr128.Name(), var.Name() + separator + cr128_Array);
ASSERT_EQ(attr_cr128.Data().size() == 1, false);
ASSERT_EQ(attr_cr128.Type(),
adios2::GetType<std::complex<long double>>());

auto I8 = attr_i8.Data();
auto I16 = attr_i16.Data();
auto I32 = attr_i32.Data();
Expand Down
Loading

0 comments on commit 54bde93

Please sign in to comment.