[tests] vecadd|sgemm|saxpy: save input buffers to file
This commit is contained in:
@@ -52,6 +52,25 @@ static int read_kernel_file(const char* filename, uint8_t** data, size_t* size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int write_operand_file(const char* filename, void* data, size_t size) {
|
||||
if (nullptr == filename || nullptr == data || 0 == size)
|
||||
return -1;
|
||||
|
||||
FILE* fp = fopen(filename, "wb");
|
||||
if (NULL == fp) {
|
||||
fprintf(stderr, "Failed to write operand data.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t wsize = fwrite(data, size, 1, fp);
|
||||
if (wsize != 1) {
|
||||
fprintf(stderr, "Failed to write operand data.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool almost_equal(float a, float b, int ulp = 4) {
|
||||
union fi_t { int i; float f; };
|
||||
fi_t fa, fb;
|
||||
@@ -175,6 +194,12 @@ int main (int argc, char **argv) {
|
||||
//printf("*** [%d]: h_a=%f, h_b=%f\n", i, h_a[i], h_b[i]);
|
||||
}
|
||||
|
||||
// NOTE(hansung): Dump operand buffer to a file
|
||||
if (write_operand_file("vecadd.input.a.bin", h_a, nbytes) != 0)
|
||||
return EXIT_FAILURE;
|
||||
if (write_operand_file("vecadd.input.b.bin", h_b, nbytes) != 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// Creating command queue
|
||||
// NOTE(hansung): The 3rd properties arg is a bit-field, where fields like
|
||||
// CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE can be set. With value of 0,
|
||||
|
||||
Reference in New Issue
Block a user