all tests passing again
This commit is contained in:
parent
d09155736f
commit
8999c8b9ec
7 changed files with 912 additions and 914 deletions
209
tests/Vector.cpp
209
tests/Vector.cpp
|
|
@ -45,17 +45,26 @@ consteval std::array<std::uint8_t, Len> GetCountReverse() {
|
|||
return result;
|
||||
}
|
||||
|
||||
template <typename T, template<std::uint32_t, std::uint32_t> class VectorType, std::uint32_t MaxSize, std::uint32_t Len = 1, std::uint32_t Packing = 1>
|
||||
template <typename To, typename From, std::size_t N>
|
||||
constexpr std::array<To, N> array_cast(const std::array<From, N>& src) {
|
||||
std::array<To, N> dst{};
|
||||
for (std::size_t i = 0; i < N; ++i) {
|
||||
dst[i] = static_cast<To>(src[i]);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
template <typename T, template<std::uint8_t, std::uint8_t> class VectorType, std::uint32_t MaxSize, std::uint32_t Len = 1, std::uint32_t Packing = 1>
|
||||
std::string* TestAllCombinations() {
|
||||
if constexpr (Len > MaxSize) {
|
||||
return nullptr;
|
||||
} else if constexpr (Len * Packing > MaxSize) {
|
||||
return TestAllCombinations<T, VectorType, MaxSize, Len + 1, 1>();
|
||||
} else {
|
||||
T floats[VectorType<Len, Packing>::Alignment];
|
||||
T floats1[VectorType<Len, Packing>::Alignment];
|
||||
T floats2[VectorType<Len, Packing>::Alignment];
|
||||
for (std::uint32_t i = 0; i < VectorType<Len, Packing>::Alignment; i++) {
|
||||
T floats[VectorType<Len, Packing>::AlignmentElement];
|
||||
T floats1[VectorType<Len, Packing>::AlignmentElement];
|
||||
T floats2[VectorType<Len, Packing>::AlignmentElement];
|
||||
for (std::uint32_t i = 0; i < VectorType<Len, Packing>::AlignmentElement; i++) {
|
||||
floats[i] = static_cast<T>(i+1);
|
||||
}
|
||||
for (std::uint32_t i = 0; i < Packing*Len; i++) {
|
||||
|
|
@ -64,7 +73,7 @@ std::string* TestAllCombinations() {
|
|||
for (std::uint32_t i = 0; i < Packing*Len; i++) {
|
||||
floats2[i] = static_cast<T>(i+1+Len);
|
||||
}
|
||||
for (std::uint32_t i = Len*Packing; i < VectorType<Len, Packing>::Alignment; i++) {
|
||||
for (std::uint32_t i = Len*Packing; i < VectorType<Len, Packing>::AlignmentElement; i++) {
|
||||
floats1[i] = 0;
|
||||
floats2[i] = 0;
|
||||
}
|
||||
|
|
@ -81,10 +90,10 @@ std::string* TestAllCombinations() {
|
|||
if constexpr(total > 0 && (total & (total - 1)) == 0) {
|
||||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = vec.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = vec.Store();
|
||||
for (std::uint32_t i = 0; i < Len * Packing; i++) {
|
||||
if (!FloatEquals(stored.v[i], floats[i])) {
|
||||
return new std::string(std::format("Load/Store mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i]), (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], floats[i])) {
|
||||
return new std::string(std::format("Load/Store mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i]), (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -92,10 +101,10 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
vec = vec + vec;
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = vec.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = vec.Store();
|
||||
for (std::uint32_t i = 0; i < Len * Packing; i++) {
|
||||
if (!FloatEquals(stored.v[i], floats[i] + floats[i])) {
|
||||
return new std::string(std::format("Add mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] + floats[i]), (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], floats[i] + floats[i])) {
|
||||
return new std::string(std::format("Add mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] + floats[i]), (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -103,10 +112,10 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
vec = vec - vec;
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = vec.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = vec.Store();
|
||||
for (std::uint32_t i = 0; i < Len * Packing; i++) {
|
||||
if (!FloatEquals(stored.v[i], T(0))) {
|
||||
return new std::string(std::format("Subtract mismatch at Len={} Packing={}, Expected: 0, Got: {}", Len, Packing, (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], T(0))) {
|
||||
return new std::string(std::format("Subtract mismatch at Len={} Packing={}, Expected: 0, Got: {}", Len, Packing, (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -114,10 +123,10 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
vec = vec * vec;
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = vec.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = vec.Store();
|
||||
for (std::uint32_t i = 0; i < Len * Packing; i++) {
|
||||
if (!FloatEquals(stored.v[i], floats[i] * floats[i])) {
|
||||
return new std::string(std::format("Multiply mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] * floats[i]), (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], floats[i] * floats[i])) {
|
||||
return new std::string(std::format("Multiply mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] * floats[i]), (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -125,10 +134,10 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
vec = vec / vec;
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = vec.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = vec.Store();
|
||||
for (std::uint32_t i = 0; i < Len * Packing; i++) {
|
||||
if (!FloatEquals(stored.v[i], T(1))) {
|
||||
return new std::string(std::format("Divide mismatch at Len={} Packing={}, Expected: 1, Got: {}", Len, Packing, (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], T(1))) {
|
||||
return new std::string(std::format("Divide mismatch at Len={} Packing={}, Expected: 1, Got: {}", Len, Packing, (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -136,10 +145,10 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
vec = vec + T(2);
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = vec.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = vec.Store();
|
||||
for (std::uint32_t i = 0; i < Len * Packing; i++) {
|
||||
if (!FloatEquals(stored.v[i], floats[i] + T(2))) {
|
||||
return new std::string(std::format("Scalar add mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] + T(2)), (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], floats[i] + T(2))) {
|
||||
return new std::string(std::format("Scalar add mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] + T(2)), (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -147,10 +156,10 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
vec = vec - T(2);
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = vec.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = vec.Store();
|
||||
for (std::uint32_t i = 0; i < Len * Packing; i++) {
|
||||
if (!FloatEquals(stored.v[i], floats[i] - T(2))) {
|
||||
return new std::string(std::format("Scalar add mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] + T(2)), (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], floats[i] - T(2))) {
|
||||
return new std::string(std::format("Scalar add mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] + T(2)), (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -158,10 +167,10 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
vec = vec * T(2);
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = vec.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = vec.Store();
|
||||
for (std::uint32_t i = 0; i < Len * Packing; i++) {
|
||||
if (!FloatEquals(stored.v[i], floats[i] * T(2))) {
|
||||
return new std::string(std::format("Scalar multiply mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] * T(2)), (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], floats[i] * T(2))) {
|
||||
return new std::string(std::format("Scalar multiply mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] * T(2)), (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -169,10 +178,10 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
vec = vec / T(2);
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = vec.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = vec.Store();
|
||||
for (std::uint32_t i = 0; i < Len * Packing; i++) {
|
||||
if (!FloatEquals(stored.v[i], floats[i] / T(2))) {
|
||||
return new std::string(std::format("Scalar divide mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] * T(2)), (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], floats[i] / T(2))) {
|
||||
return new std::string(std::format("Scalar divide mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(floats[i] * T(2)), (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -216,10 +225,10 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
vec = -vec;
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> result = vec.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> result = vec.Store();
|
||||
for (std::uint32_t i = 0; i < Len * Packing; i++) {
|
||||
if (!FloatEquals(result.v[i], -floats[i])) {
|
||||
return new std::string(std::format("Negate mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(-floats[i]), (float)result.v[i]));
|
||||
if (!FloatEquals(result[i], -floats[i])) {
|
||||
return new std::string(std::format("Negate mismatch at Len={} Packing={}, Expected: {}, Got: {}", Len, Packing, (float)(-floats[i]), (float)result[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -228,12 +237,12 @@ std::string* TestAllCombinations() {
|
|||
VectorType<Len, Packing> vecA(floats1);
|
||||
VectorType<Len, Packing> vecB(floats2);
|
||||
VectorType<Len, Packing> result = VectorType<Len, Packing>::template Blend<AlternateTrueFalse<Len>()>(vecA, vecB);
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = result.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result.Store();
|
||||
for (std::uint32_t i = 0; i < Len; i++) {
|
||||
bool useB = (i % 2 == 0);
|
||||
T expected = useB ? floats2[i]: floats1[i];
|
||||
if (!FloatEquals(stored.v[i], expected)) {
|
||||
return new std::string(std::format("Blend mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], expected)) {
|
||||
return new std::string(std::format("Blend mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -243,11 +252,11 @@ std::string* TestAllCombinations() {
|
|||
VectorType<Len, Packing> vecB(floats);
|
||||
VectorType<Len, Packing> vecAdd(floats);
|
||||
VectorType<Len, Packing> result = VectorType<Len, Packing>::MulitplyAdd(vecA, vecB, vecAdd);
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = result.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result.Store();
|
||||
for (std::uint32_t i = 0; i < Len; i++) {
|
||||
T expected = floats[i] * floats[i] + floats[i];
|
||||
if (!FloatEquals(stored.v[i], expected)) {
|
||||
return new std::string(std::format("MulitplyAdd mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], expected)) {
|
||||
return new std::string(std::format("MulitplyAdd mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -257,11 +266,11 @@ std::string* TestAllCombinations() {
|
|||
VectorType<Len, Packing> vecB(floats);
|
||||
VectorType<Len, Packing> vecSub(floats);
|
||||
VectorType<Len, Packing> result = VectorType<Len, Packing>::MulitplySub(vecA, vecB, vecSub);
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = result.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result.Store();
|
||||
for (std::uint32_t i = 0; i < Len; i++) {
|
||||
T expected = floats[i] * floats[i] - floats[i];
|
||||
if (!FloatEquals(stored.v[i], expected)) {
|
||||
return new std::string(std::format("MulitplySub mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], expected)) {
|
||||
return new std::string(std::format("MulitplySub mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -269,12 +278,12 @@ std::string* TestAllCombinations() {
|
|||
if constexpr(Len > 2){
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
VectorType<Len-1, Packing> result = vec.template ExtractLo<Len-1>();
|
||||
Vector<T, (Len-1)*Packing, VectorType<Len-1, Packing>::Alignment> stored = result.Store();
|
||||
std::array<T, VectorType<Len-1, Packing>::AlignmentElement> stored = result.Store();
|
||||
for(std::uint32_t i2 = 0; i2 < Packing; i2++){
|
||||
for (std::uint32_t i = 0; i < Len-1; i++) {
|
||||
T expected = floats[i2*(Len)+i];
|
||||
if (!FloatEquals(stored.v[i2*(Len-1)+i], expected)) {
|
||||
return new std::string(std::format("ExtractLo mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored.v[i2*(Len-1)+i]));
|
||||
if (!FloatEquals(stored[i2*(Len-1)+i], expected)) {
|
||||
return new std::string(std::format("ExtractLo mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored[i2*(Len-1)+i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -283,12 +292,12 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
VectorType<Len, Packing> result = vec.Sin();
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = result.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result.Store();
|
||||
for(std::uint32_t i2 = 0; i2 < Packing; i2++){
|
||||
for (std::uint32_t i = 0; i < Len; i++) {
|
||||
T expected = (T)std::sin((float)floats[i2*Len+i]);
|
||||
if (!FloatEquals(stored.v[i2*Len+i], expected)) {
|
||||
return new std::string(std::format("Sin mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored.v[i2*(Len-1)+i]));
|
||||
if (!FloatEquals(stored[i2*Len+i], expected)) {
|
||||
return new std::string(std::format("Sin mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored[i2*(Len-1)+i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -297,12 +306,12 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
VectorType<Len, Packing> result = vec.Cos();
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = result.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result.Store();
|
||||
for(std::uint32_t i2 = 0; i2 < Packing; i2++){
|
||||
for (std::uint32_t i = 0; i < Len; i++) {
|
||||
T expected = (T)std::cos((float)floats[i2*Len+i]);
|
||||
if (!FloatEquals(stored.v[i2*Len+i], expected)) {
|
||||
return new std::string(std::format("Cos mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored.v[i2*(Len-1)+i]));
|
||||
if (!FloatEquals(stored[i2*Len+i], expected)) {
|
||||
return new std::string(std::format("Cos mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored[i2*(Len-1)+i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -311,18 +320,18 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
auto result = vec.SinCos();
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> storedSin = std::get<0>(result).Store();
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> storedCos = std::get<1>(result).Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> storedSin = std::get<0>(result).Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> storedCos = std::get<1>(result).Store();
|
||||
for(std::uint32_t i2 = 0; i2 < Packing; i2++){
|
||||
for (std::uint32_t i = 0; i < Len; i++) {
|
||||
T expected = (T)std::sin((float)floats[i2*Len+i]);
|
||||
if (!FloatEquals(storedSin.v[i2*Len+i], expected)) {
|
||||
return new std::string(std::format("SinCos sin mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)storedSin.v[i2*(Len-1)+i]));
|
||||
if (!FloatEquals(storedSin[i2*Len+i], expected)) {
|
||||
return new std::string(std::format("SinCos sin mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)storedSin[i2*(Len-1)+i]));
|
||||
}
|
||||
|
||||
expected = (T)std::cos((float)floats[i2*Len+i]);
|
||||
if (!FloatEquals(storedCos.v[i2*Len+i], expected)) {
|
||||
return new std::string(std::format("SinCos cos mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)storedCos.v[i2*(Len-1)+i]));
|
||||
if (!FloatEquals(storedCos[i2*Len+i], expected)) {
|
||||
return new std::string(std::format("SinCos cos mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)storedCos[i2*(Len-1)+i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -331,11 +340,11 @@ std::string* TestAllCombinations() {
|
|||
{
|
||||
VectorType<Len, Packing> vec(floats);
|
||||
VectorType<Len, Packing> result = vec.template Shuffle<GetCountReverse<Len>()>();
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = result.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result.Store();
|
||||
for (std::uint32_t i = 0; i < Len; i++) {
|
||||
T expected = floats[Len - 1 - i];
|
||||
if (!FloatEquals(stored.v[i], expected)) {
|
||||
return new std::string(std::format("Shuffle mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], expected)) {
|
||||
return new std::string(std::format("Shuffle mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)expected, (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -343,7 +352,7 @@ std::string* TestAllCombinations() {
|
|||
|
||||
if constexpr(Packing == 1) {
|
||||
T expectedLengthSq = T(0);
|
||||
for (std::uint32_t i = 0; i < VectorType<Len, Packing>::Alignment; i++) {
|
||||
for (std::uint32_t i = 0; i < VectorType<Len, Packing>::AlignmentElement; i++) {
|
||||
expectedLengthSq += floats[i] * floats[i];
|
||||
}
|
||||
|
||||
|
|
@ -387,13 +396,13 @@ std::string* TestAllCombinations() {
|
|||
VectorType<Len, Packing> vec1(floats1);
|
||||
VectorType<Len, Packing> vec2(floats2);
|
||||
VectorType<Len, Packing> result = VectorType<Len, Packing>::Cross(vec1, vec2);
|
||||
Vector<T, Len*Packing, VectorType<Len, Packing>::Alignment> stored = result.Store();
|
||||
if (!FloatEquals(stored.v[0], T(-3)) || !FloatEquals(stored.v[1], T(6)) || !FloatEquals(stored.v[2], T(-3))) {
|
||||
return new std::string(std::format("Cross mismatch at Len={} Packing={}, Expected: -3,6,-3, Got: {},{},{}", Len, Packing, (float)stored.v[0], (float)stored.v[1], (float)stored.v[2]));
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result.Store();
|
||||
if (!FloatEquals(stored[0], T(-3)) || !FloatEquals(stored[1], T(6)) || !FloatEquals(stored[2], T(-3))) {
|
||||
return new std::string(std::format("Cross mismatch at Len={} Packing={}, Expected: -3,6,-3, Got: {},{},{}", Len, Packing, (float)stored[0], (float)stored[1], (float)stored[2]));
|
||||
}
|
||||
}
|
||||
if constexpr(4 * Packing < VectorType<1, 1>::MaxSize) {
|
||||
T qData[VectorType<4, Packing>::Alignment];
|
||||
if constexpr(4 * Packing < VectorType<1, 1>::MaxElement) {
|
||||
T qData[VectorType<4, Packing>::AlignmentElement];
|
||||
qData[0] = T(0);
|
||||
qData[1] = T(0);
|
||||
qData[2] = T(0);
|
||||
|
|
@ -402,18 +411,18 @@ std::string* TestAllCombinations() {
|
|||
VectorType<3, Packing> vecV(floats);
|
||||
VectorType<4, Packing> vecQ(qData);
|
||||
VectorType<3, Packing> result = VectorType<3, Packing>::Rotate(vecV, vecQ);
|
||||
Vector<T, 3*Packing, VectorType<3, Packing>::Alignment> stored = result.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result.Store();
|
||||
|
||||
for (std::uint32_t i = 0; i < 3; i++) {
|
||||
if (!FloatEquals(stored.v[i], floats[i])) {
|
||||
return new std::string(std::format("Rotate mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)floats[i], (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], floats[i])) {
|
||||
return new std::string(std::format("Rotate mismatch at Len={} Packing={}, Index={}, Expected: {}, Got: {}", Len, Packing, i, (float)floats[i], (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr(Len == 4) {
|
||||
T eulerData[VectorType<3, Packing>::Alignment];
|
||||
T eulerData[VectorType<3, Packing>::AlignmentElement];
|
||||
for(std::uint8_t i = 0; i < Packing; i++) {
|
||||
eulerData[i*3] = T(0.7853981);
|
||||
eulerData[i*3+1] = T(0.1243412);
|
||||
|
|
@ -421,27 +430,27 @@ std::string* TestAllCombinations() {
|
|||
}
|
||||
VectorType<3, Packing> eulerVec(eulerData);
|
||||
VectorType<4, Packing> result = VectorType<4, Packing>::QuanternionFromEuler(eulerVec);
|
||||
Vector<T, 4*Packing, VectorType<4, Packing>::Alignment> stored = result.Store();
|
||||
std::array<T, VectorType<4, Packing>::AlignmentElement> stored = result.Store();
|
||||
|
||||
if (!FloatEquals(stored.v[0], T(0.63720703)) || !FloatEquals(stored.v[1], T(0.30688477)) ||
|
||||
!FloatEquals(stored.v[2], T(0.14074707)) || !FloatEquals(stored.v[3], T(0.6933594))) {
|
||||
return new std::string(std::format("QuanternionFromEuler mismatch at Len={} Packing={}, Expected: 0.63720703,0.30688477,0.14074707,0.6933594, Got: {},{},{},{}", Len, Packing, (float)stored.v[0], (float)stored.v[1], (float)stored.v[2], (float)stored.v[3]));
|
||||
if (!FloatEquals(stored[0], T(0.63720703)) || !FloatEquals(stored[1], T(0.30688477)) ||
|
||||
!FloatEquals(stored[2], T(0.14074707)) || !FloatEquals(stored[3], T(0.6933594))) {
|
||||
return new std::string(std::format("QuanternionFromEuler mismatch at Len={} Packing={}, Expected: 0.63720703,0.30688477,0.14074707,0.6933594, Got: {},{},{},{}", Len, Packing, (float)stored[0], (float)stored[1], (float)stored[2], (float)stored[3]));
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr(Len == 2 && Packing*Len == VectorType<Len, Packing>::Alignment) {
|
||||
if constexpr(Len == 2 && Packing*Len == VectorType<Len, Packing>::AlignmentElement) {
|
||||
{
|
||||
VectorType<Len, Packing> vecA(floats);
|
||||
VectorType<Len, Packing> vecE = vecA *2;
|
||||
VectorType<1, Packing*2> result = VectorType<Len, Packing>::Length(vecA, vecE);
|
||||
Vector<T, Packing*2, VectorType<Len, Packing>::Alignment> stored = result.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result.Store();
|
||||
|
||||
if (!FloatEquals(stored.v[0], expectedLength[0])) {
|
||||
return new std::string(std::format("Length 2 vecA test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0], (float)stored.v[0]));
|
||||
if (!FloatEquals(stored[0], expectedLength[0])) {
|
||||
return new std::string(std::format("Length 2 vecA test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0], (float)stored[0]));
|
||||
}
|
||||
|
||||
if (!FloatEquals(stored.v[(Len*Packing)/2], expectedLength[0] * 2)) {
|
||||
return new std::string(std::format("Length 2 vecE test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0] * 2, (float)stored.v[(Len*Packing)/2]));
|
||||
if (!FloatEquals(stored[(Len*Packing)/2], expectedLength[0] * 2)) {
|
||||
return new std::string(std::format("Length 2 vecE test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0] * 2, (float)stored[(Len*Packing)/2]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -450,39 +459,39 @@ std::string* TestAllCombinations() {
|
|||
VectorType<Len, Packing> vecE = vecA * 2;
|
||||
auto result = VectorType<Len, Packing>::Normalize(vecA, vecE);
|
||||
VectorType<1, Packing*2> result2 = VectorType<Len, Packing>::Length(std::get<0>(result), std::get<1>(result));
|
||||
Vector<T, Packing*2, VectorType<Len, Packing>::Alignment> stored = result2.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result2.Store();
|
||||
|
||||
for(std::uint8_t i = 0; i < Len*Packing; i++) {
|
||||
if (!FloatEquals(stored.v[i], T(1))) {
|
||||
return new std::string(std::format("Normalize {} test failed at Len={} Packing={} Expected: {}, Got: {}", i, Len, Packing, 1, (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], T(1))) {
|
||||
return new std::string(std::format("Normalize {} test failed at Len={} Packing={} Expected: {}, Got: {}", i, Len, Packing, 1, (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr(Len == 4 && Packing*Len == VectorType<Len, Packing>::Alignment) {
|
||||
if constexpr(Len == 4 && Packing*Len == VectorType<Len, Packing>::AlignmentElement) {
|
||||
{
|
||||
VectorType<Len, Packing> vecA(floats);
|
||||
VectorType<Len, Packing> vecC = vecA * 2;
|
||||
VectorType<Len, Packing> vecE = vecA * 3;
|
||||
VectorType<Len, Packing> vecG = vecA * 4;
|
||||
VectorType<1, Packing*4> result = VectorType<Len, Packing>::Length(vecA, vecC, vecE, vecG);
|
||||
Vector<T, Packing*4, VectorType<Len, Packing>::Alignment> stored = result.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result.Store();
|
||||
|
||||
if (!FloatEquals(stored.v[0], expectedLength[0])) {
|
||||
return new std::string(std::format("Length 4 vecA test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0], (float)stored.v[0]));
|
||||
if (!FloatEquals(stored[0], expectedLength[0])) {
|
||||
return new std::string(std::format("Length 4 vecA test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0], (float)stored[0]));
|
||||
}
|
||||
|
||||
if (!FloatEquals(stored.v[Packing], expectedLength[0] * 2)) {
|
||||
return new std::string(std::format("Length 4 vecC test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0] * 2, (float)stored.v[Packing]));
|
||||
if (!FloatEquals(stored[Packing], expectedLength[0] * 2)) {
|
||||
return new std::string(std::format("Length 4 vecC test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0] * 2, (float)stored[Packing]));
|
||||
}
|
||||
|
||||
if (!FloatEquals(stored.v[Packing*2], expectedLength[0] * 3)) {
|
||||
return new std::string(std::format("Length 4 vecE test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0] * 3, (float)stored.v[Packing*2]));
|
||||
if (!FloatEquals(stored[Packing*2], expectedLength[0] * 3)) {
|
||||
return new std::string(std::format("Length 4 vecE test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0] * 3, (float)stored[Packing*2]));
|
||||
}
|
||||
|
||||
if (!FloatEquals(stored.v[Packing*3], expectedLength[0] * 4)) {
|
||||
return new std::string(std::format("Length 4 vecG test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0] * 4, (float)stored.v[Packing*3]));
|
||||
if (!FloatEquals(stored[Packing*3], expectedLength[0] * 4)) {
|
||||
return new std::string(std::format("Length 4 vecG test failed at Len={} Packing={} Expected: {}, Got: {}", Len, Packing, (float)expectedLength[0] * 4, (float)stored[Packing*3]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -493,11 +502,11 @@ std::string* TestAllCombinations() {
|
|||
VectorType<Len, Packing> vecG = vecA * 4;
|
||||
auto result = VectorType<Len, Packing>::Normalize(vecA, vecC, vecE, vecG);
|
||||
VectorType<1, Packing*4> result2 = VectorType<Len, Packing>::Length(std::get<0>(result), std::get<1>(result), std::get<2>(result), std::get<3>(result));
|
||||
Vector<T, Packing*4, VectorType<Len, Packing>::Alignment> stored = result2.Store();
|
||||
std::array<T, VectorType<Len, Packing>::AlignmentElement> stored = result2.Store();
|
||||
|
||||
for(std::uint8_t i = 0; i < Len*Packing; i++) {
|
||||
if (!FloatEquals(stored.v[i], T(1))) {
|
||||
return new std::string(std::format("Normalize {} test failed at Len={} Packing={} Expected: {}, Got: {}", i, Len, Packing, 1, (float)stored.v[i]));
|
||||
if (!FloatEquals(stored[i], T(1))) {
|
||||
return new std::string(std::format("Normalize {} test failed at Len={} Packing={} Expected: {}, Got: {}", i, Len, Packing, 1, (float)stored[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -509,7 +518,7 @@ std::string* TestAllCombinations() {
|
|||
|
||||
extern "C" {
|
||||
std::string* RunTest() {
|
||||
std::string* err = TestAllCombinations<_Float16, VectorF16, VectorF16<1, 1>::MaxSize>();
|
||||
std::string* err = TestAllCombinations<_Float16, VectorF16, VectorF16<1, 1>::MaxElement>();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue