Commit 6b57eaa5 authored by Berenger Bramas's avatar Berenger Bramas
Browse files

Update unit tests -- add tests for aligned memory output

parent 3c5e0f39
...@@ -33,6 +33,16 @@ class TestAll : public UTester< TestAll< VecType > > { ...@@ -33,6 +33,16 @@ class TestAll : public UTester< TestAll< VecType > > {
for (int idx = 0; idx < VecType::VecLength; ++idx) { for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTEEQUAL(reals[idx], realsReals[idx]); UASSERTEEQUAL(reals[idx], realsReals[idx]);
} }
alignas(128) RealType realsalign[VecType::VecLength];
vec.storeInAlignedArray( realsalign);
alignas(128) RealType realsRealsalign[VecType::VecLength];
inReal.storeInArray( realsRealsalign);
for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTEEQUAL(realsalign[idx], realsRealsalign[idx]);
}
} }
void equalToScalar(const VecType vec, void equalToScalar(const VecType vec,
...@@ -47,6 +57,13 @@ class TestAll : public UTester< TestAll< VecType > > { ...@@ -47,6 +57,13 @@ class TestAll : public UTester< TestAll< VecType > > {
for (int idx = 0; idx < VecType::VecLength; ++idx) { for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTEEQUAL(reals[idx], inReal); UASSERTEEQUAL(reals[idx], inReal);
} }
alignas(128) RealType realsalign[VecType::VecLength];
vec.storeInAlignedArray( realsalign);
for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTEEQUAL(realsalign[idx], inReal);
}
} }
void equalToScalarMask(const MaskType vec, void equalToScalarMask(const MaskType vec,
...@@ -68,6 +85,13 @@ class TestAll : public UTester< TestAll< VecType > > { ...@@ -68,6 +85,13 @@ class TestAll : public UTester< TestAll< VecType > > {
for (int idx = 0; idx < VecType::VecLength; ++idx) { for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTEEQUAL(reals[idx], inReals[idx]); UASSERTEEQUAL(reals[idx], inReals[idx]);
} }
alignas(128) RealType realsalign[VecType::VecLength];
vec.storeInAlignedArray( realsalign);
for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTEEQUAL(realsalign[idx], inReals[idx]);
}
} }
bool approxEqual(const float v1, const float v2) { bool approxEqual(const float v1, const float v2) {
...@@ -98,6 +122,13 @@ class TestAll : public UTester< TestAll< VecType > > { ...@@ -98,6 +122,13 @@ class TestAll : public UTester< TestAll< VecType > > {
for (int idx = 0; idx < VecType::VecLength; ++idx) { for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTETRUE(approxEqual(reals[idx], inReal)); UASSERTETRUE(approxEqual(reals[idx], inReal));
} }
alignas(128) RealType realsalign[VecType::VecLength];
vec.storeInAlignedArray( realsalign);
for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTETRUE(approxEqual(realsalign[idx], inReal));
}
} }
void approxEqualToArray(const VecType vec, void approxEqualToArray(const VecType vec,
...@@ -112,6 +143,13 @@ class TestAll : public UTester< TestAll< VecType > > { ...@@ -112,6 +143,13 @@ class TestAll : public UTester< TestAll< VecType > > {
for (int idx = 0; idx < VecType::VecLength; ++idx) { for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTETRUE(approxEqual(reals[idx], inReals[idx])); UASSERTETRUE(approxEqual(reals[idx], inReals[idx]));
} }
alignas(128) RealType realsalign[VecType::VecLength];
vec.storeInAlignedArray( realsalign);
for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTETRUE(approxEqual(realsalign[idx], inReals[idx]));
}
} }
void approxLowAccEqualToArray(const VecType vec, void approxLowAccEqualToArray(const VecType vec,
...@@ -126,6 +164,13 @@ class TestAll : public UTester< TestAll< VecType > > { ...@@ -126,6 +164,13 @@ class TestAll : public UTester< TestAll< VecType > > {
for (int idx = 0; idx < VecType::VecLength; ++idx) { for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTETRUE(approxEqualLowAcc(reals[idx], inReals[idx])); UASSERTETRUE(approxEqualLowAcc(reals[idx], inReals[idx]));
} }
alignas(128) RealType realsalign[VecType::VecLength];
vec.storeInAlignedArray( realsalign);
for (int idx = 0; idx < VecType::VecLength; ++idx) {
UASSERTETRUE(approxEqualLowAcc(realsalign[idx], inReals[idx]));
}
} }
void TestBasic() { void TestBasic() {
...@@ -257,6 +302,28 @@ class TestAll : public UTester< TestAll< VecType > > { ...@@ -257,6 +302,28 @@ class TestAll : public UTester< TestAll< VecType > > {
approxEqualToScalar(VecType(RealType(0)).exp(), std::exp(RealType(0))); approxEqualToScalar(VecType(RealType(0)).exp(), std::exp(RealType(0)));
} }
{
alignas(128) RealType reals[VecType::VecLength];
alignas(128) RealType expres[VecType::VecLength];
alignas(128) RealType expreslowacc[VecType::VecLength];
alignas(128) RealType sqrtres[VecType::VecLength];
alignas(128) RealType rsqrtres[VecType::VecLength];
for (int idx = 0; idx < VecType::VecLength; ++idx) {
reals[idx] = RealType(idx + 1);
expres[idx] = RealType(exp(reals[idx]));
expreslowacc[idx] = RealType(exp(reals[idx]));
sqrtres[idx] = RealType(sqrt(reals[idx]));
rsqrtres[idx] = RealType(1 / sqrt(reals[idx]));
}
approxEqualToArray(VecType().setFromAlignedArray(reals).exp(), expres);
approxLowAccEqualToArray(VecType().setFromAlignedArray(reals).expLowAcc(), expreslowacc);
approxEqualToArray(VecType().setFromAlignedArray(reals).sqrt(), sqrtres);
approxEqualToArray(VecType().setFromAlignedArray(reals).rsqrt(), rsqrtres);
}
{ {
equalToScalar(VecType(RealType(0)).signOf(), 0); equalToScalar(VecType(RealType(0)).signOf(), 0);
equalToScalar(VecType(-1).signOf(), -1); equalToScalar(VecType(-1).signOf(), -1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment