getting dogfood tests passing on Verilator!
This commit is contained in:
@@ -77,6 +77,7 @@ const char* kernel_file = "kernel.bin";
|
||||
int count = 0;
|
||||
int testid_s = 0;
|
||||
int testid_e = (testMngr.size() - 1);
|
||||
bool stop_on_error = true;
|
||||
|
||||
vx_device_h device = nullptr;
|
||||
vx_buffer_h arg_buf = nullptr;
|
||||
@@ -86,12 +87,12 @@ vx_buffer_h dst_buf = nullptr;
|
||||
|
||||
static void show_usage() {
|
||||
std::cout << "Vortex Driver Test." << std::endl;
|
||||
std::cout << "Usage: [-s:testid] [-e:testid] [-k: kernel] [-n words] [-h: help]" << std::endl;
|
||||
std::cout << "Usage: [-s:testid] [-e:testid] [-k: kernel] [-n words] [-c] [-h: help]" << std::endl;
|
||||
}
|
||||
|
||||
static void parse_args(int argc, char **argv) {
|
||||
int c;
|
||||
while ((c = getopt(argc, argv, "n:s:e:k:h?")) != -1) {
|
||||
while ((c = getopt(argc, argv, "n:s:e:k:ch?")) != -1) {
|
||||
switch (c) {
|
||||
case 'n':
|
||||
count = atoi(optarg);
|
||||
@@ -105,6 +106,9 @@ static void parse_args(int argc, char **argv) {
|
||||
case 'k':
|
||||
kernel_file = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
stop_on_error = false;
|
||||
break;
|
||||
case 'h':
|
||||
case '?': {
|
||||
show_usage();
|
||||
@@ -136,6 +140,7 @@ void cleanup() {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int exitcode = 0;
|
||||
size_t value;
|
||||
kernel_arg_t kernel_arg;
|
||||
|
||||
@@ -146,6 +151,8 @@ int main(int argc, char *argv[]) {
|
||||
count = 1;
|
||||
}
|
||||
|
||||
std::cout << std::dec;
|
||||
|
||||
std::cout << "test ids: " << testid_s << " - " << testid_e << std::endl;
|
||||
std::cout << "workitem size: " << count << std::endl;
|
||||
std::cout << "using kernel: " << kernel_file << std::endl;
|
||||
@@ -163,9 +170,7 @@ int main(int argc, char *argv[]) {
|
||||
size_t buf_size = num_points * sizeof(uint32_t);
|
||||
|
||||
std::cout << "number of points: " << num_points << std::endl;
|
||||
std::cout << "number of points: " << num_points << std::endl;
|
||||
std::cout << "number of points: " << num_points << std::endl;
|
||||
std::cout << "buffer size: " << buf_size << " bytes" << std::endl;
|
||||
std::cout << "buffer size: " << std::hex << buf_size << std::dec << " bytes" << std::endl;
|
||||
|
||||
// upload program
|
||||
std::cout << "upload kernel" << std::endl;
|
||||
@@ -183,9 +188,9 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
kernel_arg.count = count;
|
||||
|
||||
std::cout << "dev_src0=" << std::hex << kernel_arg.src0_ptr << std::endl;
|
||||
std::cout << "dev_src1=" << std::hex << kernel_arg.src1_ptr << std::endl;
|
||||
std::cout << "dev_dst=" << std::hex << kernel_arg.dst_ptr << std::endl;
|
||||
std::cout << "dev_src0=" << std::hex << kernel_arg.src0_ptr << std::dec << std::endl;
|
||||
std::cout << "dev_src1=" << std::hex << kernel_arg.src1_ptr << std::dec << std::endl;
|
||||
std::cout << "dev_dst=" << std::hex << kernel_arg.dst_ptr << std::dec << std::endl;
|
||||
|
||||
// allocate shared memory
|
||||
std::cout << "allocate shared memory" << std::endl;
|
||||
@@ -250,15 +255,19 @@ int main(int argc, char *argv[]) {
|
||||
if (errors != 0) {
|
||||
std::cout << "found " << errors << " errors!" << std::endl;
|
||||
std::cout << "FAILED!" << std::endl << std::flush;
|
||||
cleanup();
|
||||
exit(1);
|
||||
if (stop_on_error) {
|
||||
cleanup();
|
||||
exit(1);
|
||||
}
|
||||
exitcode = 1;
|
||||
} else {
|
||||
std::cout << "PASSED!" << std::endl << std::flush;
|
||||
}
|
||||
std::cout << "PASSED!" << std::endl << std::flush;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
std::cout << "cleanup" << std::endl;
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
return exitcode;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ 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 * 0.5f + b;
|
||||
float c = a * b + 0.5f;
|
||||
dst_ptr[offset+i] = c;
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ 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 * 0.5f - b;
|
||||
float c = a * b - 0.5f;
|
||||
dst_ptr[offset+i] = c;
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ 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 * 0.5f - b;
|
||||
float c = -a * b - 0.5f;
|
||||
dst_ptr[offset+i] = c;
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ 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 * 0.5f + b;
|
||||
float c = -a * b + 0.5f;
|
||||
dst_ptr[offset+i] = c;
|
||||
}
|
||||
}
|
||||
@@ -195,8 +195,8 @@ 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 * 0.25f - b;
|
||||
float d = a * 0.25f + b;
|
||||
float c =-a * b - 0.5f;
|
||||
float d = a * b + 0.5f;
|
||||
float e = c + d;
|
||||
dst_ptr[offset+i] = e;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ void kernel_fsqrt(void* arg) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
float a = src0_ptr[offset+i];
|
||||
float b = src1_ptr[offset+i];
|
||||
float c = sqrt(a) + b;
|
||||
float c = sqrt(a * b);
|
||||
dst_ptr[offset+i] = c;
|
||||
}
|
||||
}
|
||||
@@ -289,38 +289,34 @@ void kernel_ftou(void* arg) {
|
||||
void kernel_itof(void* arg) {
|
||||
struct kernel_arg_t* _arg = (struct kernel_arg_t*)(arg);
|
||||
uint32_t count = _arg->count;
|
||||
float* src0_ptr = (float*)_arg->src0_ptr;
|
||||
float* src1_ptr = (float*)_arg->src1_ptr;
|
||||
int32_t* src0_ptr = (int32_t*)_arg->src0_ptr;
|
||||
int32_t* src1_ptr = (int32_t*)_arg->src1_ptr;
|
||||
float* dst_ptr = (float*)_arg->dst_ptr;
|
||||
uint32_t offset = vx_thread_gid() * count;
|
||||
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
float a = src0_ptr[offset+i];
|
||||
float b = src1_ptr[offset+i];
|
||||
int32_t c = (int32_t)a;
|
||||
int32_t d = (int32_t)b;
|
||||
int32_t e = c + d;
|
||||
float f = (float)e;
|
||||
dst_ptr[offset+i] = f;
|
||||
int32_t a = src0_ptr[offset+i];
|
||||
int32_t b = src1_ptr[offset+i];
|
||||
int32_t c = a + b;
|
||||
float d = (float)c;
|
||||
dst_ptr[offset+i] = d;
|
||||
}
|
||||
}
|
||||
|
||||
void kernel_utof(void* arg) {
|
||||
struct kernel_arg_t* _arg = (struct kernel_arg_t*)(arg);
|
||||
uint32_t count = _arg->count;
|
||||
float* src0_ptr = (float*)_arg->src0_ptr;
|
||||
float* src1_ptr = (float*)_arg->src1_ptr;
|
||||
int32_t* src0_ptr = (int32_t*)_arg->src0_ptr;
|
||||
int32_t* src1_ptr = (int32_t*)_arg->src1_ptr;
|
||||
float* dst_ptr = (float*)_arg->dst_ptr;
|
||||
uint32_t offset = vx_thread_gid() * count;
|
||||
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
float a = src0_ptr[offset+i];
|
||||
float b = src1_ptr[offset+i];
|
||||
uint32_t c = (uint32_t)a;
|
||||
uint32_t d = (uint32_t)b;
|
||||
uint32_t e = c + d;
|
||||
float f = (float)e;
|
||||
dst_ptr[offset+i] = f;
|
||||
int32_t a = src0_ptr[offset+i];
|
||||
int32_t b = src1_ptr[offset+i];
|
||||
uint32_t c = a + b;
|
||||
float d = (float)c;
|
||||
dst_ptr[offset+i] = d;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,31 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <limits>
|
||||
|
||||
union Float_t {
|
||||
float f;
|
||||
int32_t i;
|
||||
struct {
|
||||
uint32_t mantissa : 23;
|
||||
uint32_t exponent : 8;
|
||||
uint32_t sign : 1;
|
||||
} parts;
|
||||
};
|
||||
|
||||
inline bool almost_equal_eps(float a, float b, float eps = std::numeric_limits<float>::epsilon()) {
|
||||
auto tolerance = std::max(std::fabs(a), std::fabs(b)) * eps;
|
||||
return std::fabs(a - b) <= tolerance;
|
||||
}
|
||||
|
||||
inline bool almost_equal_ulp(float a, float b, int32_t ulp = 4) {
|
||||
Float_t fa{a}, fb{b};
|
||||
return std::abs(fa.i - fb.i) <= ulp;
|
||||
}
|
||||
|
||||
inline bool almost_equal(float a, float b) {
|
||||
return almost_equal_ulp(a, b);
|
||||
}
|
||||
|
||||
class ITestCase {
|
||||
public:
|
||||
@@ -19,8 +44,8 @@ public:
|
||||
auto a = (int32_t*)src1;
|
||||
auto b = (int32_t*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = n/2 + i;
|
||||
b[i] = n/2 - i;
|
||||
a[i] = n/2 - i;
|
||||
b[i] = n/2 + i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +57,7 @@ public:
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = a[i] + b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -47,8 +72,8 @@ public:
|
||||
auto a = (int32_t*)src1;
|
||||
auto b = (int32_t*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = n/2 + i;
|
||||
b[i] = n/2 - i;
|
||||
a[i] = n/2 - i;
|
||||
b[i] = n/2 + i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +85,7 @@ public:
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = a[i] * b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -88,7 +113,7 @@ public:
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = a[i] / b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -118,7 +143,7 @@ public:
|
||||
auto y = a[i] * b[i];
|
||||
auto ref = x + y;
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -133,8 +158,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n + i) * 0.125f;
|
||||
b[i] = (n - i) * 0.125f;
|
||||
a[i] = (n - i) * (1.0f/n);
|
||||
b[i] = (n + i) * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,8 +170,8 @@ public:
|
||||
auto c = (float*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = a[i] + b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -161,8 +186,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n + i) * 0.125f;
|
||||
b[i] = (n - i) * 0.125f;
|
||||
a[i] = (n - i) * (1.0f/n);
|
||||
b[i] = (n + i) * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,8 +198,8 @@ public:
|
||||
auto c = (float*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = a[i] - b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -189,8 +214,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n + i) * 0.125f;
|
||||
b[i] = (n - i) * 0.125f;
|
||||
a[i] = (n - i) * (1.0f/n);
|
||||
b[i] = (n + i) * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,8 +226,8 @@ public:
|
||||
auto c = (float*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = a[i] * b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -217,8 +242,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n + i) * 0.125f;
|
||||
b[i] = (n - i) * 0.125f;
|
||||
a[i] = (n - i) * (1.0f/n);
|
||||
b[i] = (n + i) * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,9 +253,9 @@ public:
|
||||
auto b = (float*)src2;
|
||||
auto c = (float*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = a[i] * 0.5f + b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
auto ref = a[i] * b[i] + 0.5f;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -245,8 +270,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n + i) * 0.125f;
|
||||
b[i] = (n - i) * 0.125f;
|
||||
a[i] = (n - i) * (1.0f/n);
|
||||
b[i] = (n + i) * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,9 +281,9 @@ public:
|
||||
auto b = (float*)src2;
|
||||
auto c = (float*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = a[i] * 0.5f - b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
auto ref = a[i] * b[i] - 0.5f;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -273,8 +298,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n + i) * 0.125f;
|
||||
b[i] = (n - i) * 0.125f;
|
||||
a[i] = (n - i) * (1.0f/n);
|
||||
b[i] = (n + i) * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,9 +309,9 @@ public:
|
||||
auto b = (float*)src2;
|
||||
auto c = (float*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = -a[i] * 0.5f - b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
auto ref = -a[i] * b[i] - 0.5f;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -301,8 +326,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n + i) * 0.125f;
|
||||
b[i] = (n - i) * 0.125f;
|
||||
a[i] = (n - i) * (1.0f/n);
|
||||
b[i] = (n + i) * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,9 +337,9 @@ public:
|
||||
auto b = (float*)src2;
|
||||
auto c = (float*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = -a[i] * 0.5f + b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
auto ref = -a[i] * b[i] + 0.5f;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -329,8 +354,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n + i) * 0.125f;
|
||||
b[i] = (n - i) * 0.125f;
|
||||
a[i] = (n - i) * (1.0f/n);
|
||||
b[i] = (n + i) * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,11 +365,11 @@ public:
|
||||
auto b = (float*)src2;
|
||||
auto c = (float*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto x = -a[i] * 0.5f - b[i];
|
||||
auto y = a[i] * 0.5f + b[i];
|
||||
auto x = -a[i] * b[i] - 0.5f;
|
||||
auto y = a[i] * b[i] + 0.5f;
|
||||
auto ref = x + y;
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -359,8 +384,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n - i) * 0.125f;
|
||||
b[i] = (n + i) * 0.125f;
|
||||
a[i] = (n - i) * (1.0f/n);
|
||||
b[i] = (n + i) * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,8 +396,8 @@ public:
|
||||
auto c = (float*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = a[i] / b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -387,8 +412,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n - i) * 0.125f;
|
||||
b[i] = (n + i) * 0.125f;
|
||||
a[i] = (n - i) * (1.0f/n);
|
||||
b[i] = (n + i) * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,8 +426,8 @@ public:
|
||||
auto x = a[i] / b[i];
|
||||
auto y = b[i] / a[i];
|
||||
auto ref = x + y;
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -417,8 +442,9 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n + i) * 0.125f;
|
||||
b[i] = (n - i) * 0.125f;
|
||||
int q = 1.0f + (i % 64);
|
||||
a[i] = q;
|
||||
b[i] = q;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,9 +454,9 @@ public:
|
||||
auto b = (float*)src2;
|
||||
auto c = (float*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ref = sqrt(a[i]) + b[i];
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
auto ref = sqrt(a[i] * b[i]);
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -445,8 +471,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n + i) * 0.5f;
|
||||
b[i] = (n - i) * 0.5f;
|
||||
a[i] = (n/2 - i) * (1.0f/n);
|
||||
b[i] = (n/2 - i) * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,12 +480,12 @@ public:
|
||||
int errors = 0;
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
auto c = (float*)dst;
|
||||
auto c = (int32_t*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto x = a[i] + b[i];
|
||||
auto ref = (int32_t)x;
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -474,8 +500,8 @@ public:
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = (n + i) * 0.5f;
|
||||
b[i] = (n - i) * 0.5f;
|
||||
a[i] = i * (1.0f/n);
|
||||
b[i] = i * (1.0f/n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,12 +509,12 @@ public:
|
||||
int errors = 0;
|
||||
auto a = (float*)src1;
|
||||
auto b = (float*)src2;
|
||||
auto c = (float*)dst;
|
||||
auto c = (uint32_t*)dst;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto x = a[i] + b[i];
|
||||
auto ref = (uint32_t)x;
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -503,7 +529,7 @@ public:
|
||||
auto a = (int32_t*)src1;
|
||||
auto b = (int32_t*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = n/2 + i;
|
||||
a[i] = n/2 - i;
|
||||
b[i] = n/2 - i;
|
||||
}
|
||||
}
|
||||
@@ -516,8 +542,8 @@ public:
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto x = a[i] + b[i];
|
||||
auto ref = (float)x;
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
@@ -532,8 +558,8 @@ public:
|
||||
auto a = (uint32_t*)src1;
|
||||
auto b = (uint32_t*)src2;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
a[i] = n/2 + i;
|
||||
b[i] = n/2 - i;
|
||||
a[i] = i;
|
||||
b[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -545,8 +571,8 @@ public:
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto x = a[i] + b[i];
|
||||
auto ref = (float)x;
|
||||
if (c[i] != ref) {
|
||||
std::cout << "error at value " << i << ": actual 0x" << c[i] << ", expected 0x" << ref << std::endl;
|
||||
if (!almost_equal(c[i], ref)) {
|
||||
std::cout << "error at value " << i << ": expected " << ref << ", actual " << c[i] << ", a=" << a[i] << ", b=" << b[i] << std::endl;
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user