dogfood fmadd* update

This commit is contained in:
Blaise Tine 2020-09-06 04:18:33 -04:00
parent 033f9c00d9
commit 8eee036295
5 changed files with 2054 additions and 2051 deletions

Binary file not shown.

View file

@ -131,8 +131,9 @@ void kernel_fmadd(void* arg) {
for (uint32_t i = 0; i < count; ++i) {
float a = src0_ptr[offset+i];
float b = src1_ptr[offset+i];
float c = a * b + 0.5f;
dst_ptr[offset+i] = c;
float c = a - b;
float d = a * b + c;
dst_ptr[offset+i] = d;
}
}
@ -147,8 +148,9 @@ void kernel_fmsub(void* arg) {
for (uint32_t i = 0; i < count; ++i) {
float a = src0_ptr[offset+i];
float b = src1_ptr[offset+i];
float c = a * b - 0.5f;
dst_ptr[offset+i] = c;
float c = a - b;
float d = a * b - c;
dst_ptr[offset+i] = d;
}
}
@ -163,8 +165,9 @@ void kernel_fnmadd(void* arg) {
for (uint32_t i = 0; i < count; ++i) {
float a = src0_ptr[offset+i];
float b = src1_ptr[offset+i];
float c = -a * b - 0.5f;
dst_ptr[offset+i] = c;
float c = a - b;
float d =-a * b - c;
dst_ptr[offset+i] = d;
}
}
@ -179,8 +182,9 @@ void kernel_fnmsub(void* arg) {
for (uint32_t i = 0; i < count; ++i) {
float a = src0_ptr[offset+i];
float b = src1_ptr[offset+i];
float c = -a * b + 0.5f;
dst_ptr[offset+i] = c;
float c = a - b;
float d =-a * b + c;
dst_ptr[offset+i] = d;
}
}
@ -195,10 +199,11 @@ void kernel_fnmadd_madd(void* arg) {
for (uint32_t i = 0; i < count; ++i) {
float a = src0_ptr[offset+i];
float b = src1_ptr[offset+i];
float c =-a * b - 0.5f;
float d = a * b + 0.5f;
float e = c + d;
dst_ptr[offset+i] = e;
float c = a - b;
float d =-a * b - c;
float e = a * b + c;
float f = d + e;
dst_ptr[offset+i] = f;
}
}

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -19,7 +19,7 @@ inline bool almost_equal_eps(float a, float b, float eps = std::numeric_limits<f
return fabs(a - b) <= tolerance;
}
inline bool almost_equal_ulp(float a, float b, int32_t ulp = 4) {
inline bool almost_equal_ulp(float a, float b, int32_t ulp = 5) {
Float_t fa{a}, fb{b};
return std::abs(fa.i - fb.i) <= ulp;
}
@ -253,7 +253,8 @@ public:
auto b = (float*)src2;
auto c = (float*)dst;
for (int i = 0; i < n; ++i) {
auto ref = a[i] * b[i] + 0.5f;
auto x = a[i] - b[i];
auto ref = a[i] * b[i] + x;
if (!almost_equal(c[i], ref)) {
std::cout << "error at result #" << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
++errors;
@ -281,7 +282,8 @@ public:
auto b = (float*)src2;
auto c = (float*)dst;
for (int i = 0; i < n; ++i) {
auto ref = a[i] * b[i] - 0.5f;
auto x = a[i] - b[i];
auto ref = a[i] * b[i] - x;
if (!almost_equal(c[i], ref)) {
std::cout << "error at result #" << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
++errors;
@ -309,7 +311,8 @@ public:
auto b = (float*)src2;
auto c = (float*)dst;
for (int i = 0; i < n; ++i) {
auto ref = -a[i] * b[i] - 0.5f;
auto x = a[i] - b[i];
auto ref = -a[i] * b[i] - x;
if (!almost_equal(c[i], ref)) {
std::cout << "error at result #" << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
++errors;
@ -337,7 +340,8 @@ public:
auto b = (float*)src2;
auto c = (float*)dst;
for (int i = 0; i < n; ++i) {
auto ref = -a[i] * b[i] + 0.5f;
auto x = a[i] - b[i];
auto ref = -a[i] * b[i] + x;
if (!almost_equal(c[i], ref)) {
std::cout << "error at result #" << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
++errors;
@ -365,9 +369,10 @@ public:
auto b = (float*)src2;
auto c = (float*)dst;
for (int i = 0; i < n; ++i) {
auto x = -a[i] * b[i] - 0.5f;
auto y = a[i] * b[i] + 0.5f;
auto ref = x + y;
auto x = a[i] - b[i];
auto y = -a[i] * b[i] - x;
auto z = a[i] * b[i] + x;
auto ref = y + z;
if (!almost_equal(c[i], ref)) {
std::cout << "error at result #" << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
++errors;