Enqueue fill buffer (#1561)

* grab latest from upstream OpenCL

* Use clEnqueueFillBuffer rather than memset4 in all test files

* Cleanup leftover code from memset_pattern4

* Remove unnecessary map, unmap, writeBuffer from math_brute_force tests

* Remove extraneous build system change

* Appease clang-format

* Add option to perform buffer fills on the host

Co-authored-by: Taeten Prettyman <taeten.j@gmail.com>
Co-authored-by: taetenp <taet@holochip.com>
Co-authored-by: Chip Davis <chip@holochip.com>
This commit is contained in:
Steven Winston
2023-01-24 08:51:00 -08:00
committed by GitHub
parent 77e4fe5588
commit 4759159a50
29 changed files with 1027 additions and 506 deletions

View File

@@ -1,4 +1,4 @@
#!/usr/bin/csh #!/bin/bash
# #
# This runs the conversions in 32- and 64-bit modes, split into 9 processes for better throughput. # This runs the conversions in 32- and 64-bit modes, split into 9 processes for better throughput.
# It is intended to allow for quicker debugging turnaround for code development purposes # It is intended to allow for quicker debugging turnaround for code development purposes

View File

@@ -222,24 +222,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
Force64BitFPUPrecision(); Force64BitFPUPrecision();
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_ulong *out[VECTOR_SIZE_COUNT]; cl_ulong *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_ulong *)clEnqueueMapBuffer( // start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_ulong *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
}
// Get that moving // Get that moving
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n"); if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
}
// Init input array // Init input array
cl_ulong *p = (cl_ulong *)gIn + thread_id * buffer_elements; cl_ulong *p = (cl_ulong *)gIn + thread_id * buffer_elements;
@@ -248,8 +251,9 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
int totalSpecialValueCount = specialValuesCount * specialValuesCount; int totalSpecialValueCount = specialValuesCount * specialValuesCount;
int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements; int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements;
// Test edge cases
if (job_id <= (cl_uint)lastSpecialJobIndex) if (job_id <= (cl_uint)lastSpecialJobIndex)
{ // test edge cases {
cl_double *fp = (cl_double *)p; cl_double *fp = (cl_double *)p;
cl_double *fp2 = (cl_double *)p2; cl_double *fp2 = (cl_double *)p2;
uint32_t x, y; uint32_t x, y;
@@ -270,7 +274,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
} }
} }
// Init any remaining values. // Init any remaining values
for (; idx < buffer_elements; idx++) for (; idx < buffer_elements; idx++)
{ {
p[idx] = genrand_int64(d); p[idx] = genrand_int64(d);
@@ -293,31 +297,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
goto exit; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ goto exit;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
goto exit; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
goto exit;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
goto exit; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -227,24 +227,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
} }
} }
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_uint *out[VECTOR_SIZE_COUNT]; cl_uint *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_uint *)clEnqueueMapBuffer( // start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_uint *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
}
// Get that moving // Get that moving
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n"); if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
}
// Init input array // Init input array
cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements; cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements;
@@ -253,8 +256,9 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
int totalSpecialValueCount = specialValuesCount * specialValuesCount; int totalSpecialValueCount = specialValuesCount * specialValuesCount;
int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements; int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements;
// Test edge cases
if (job_id <= (cl_uint)lastSpecialJobIndex) if (job_id <= (cl_uint)lastSpecialJobIndex)
{ // test edge cases {
float *fp = (float *)p; float *fp = (float *)p;
float *fp2 = (float *)p2; float *fp2 = (float *)p2;
uint32_t x, y; uint32_t x, y;
@@ -276,7 +280,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
} }
} }
// Init any remaining values. // Init any remaining values
for (; idx < buffer_elements; idx++) for (; idx < buffer_elements; idx++)
{ {
p[idx] = genrand_int32(d); p[idx] = genrand_int32(d);
@@ -299,31 +303,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
goto exit; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ goto exit;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
goto exit; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
goto exit;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
goto exit; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -225,24 +225,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
Force64BitFPUPrecision(); Force64BitFPUPrecision();
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_ulong *out[VECTOR_SIZE_COUNT]; cl_ulong *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_ulong *)clEnqueueMapBuffer( // Start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_ulong *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
}
// Get that moving // Get that moving
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n"); if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
}
// Init input array // Init input array
cl_ulong *p = (cl_ulong *)gIn + thread_id * buffer_elements; cl_ulong *p = (cl_ulong *)gIn + thread_id * buffer_elements;
@@ -251,8 +254,9 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
int totalSpecialValueCount = specialValuesCount * specialValuesIntCount; int totalSpecialValueCount = specialValuesCount * specialValuesIntCount;
int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements; int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements;
// Test edge cases
if (job_id <= (cl_uint)lastSpecialJobIndex) if (job_id <= (cl_uint)lastSpecialJobIndex)
{ // test edge cases {
cl_double *fp = (cl_double *)p; cl_double *fp = (cl_double *)p;
cl_int *ip2 = (cl_int *)p2; cl_int *ip2 = (cl_int *)p2;
uint32_t x, y; uint32_t x, y;
@@ -296,31 +300,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
goto exit; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ goto exit;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
goto exit; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
goto exit;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
goto exit; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -216,24 +216,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
cl_float *s = 0; cl_float *s = 0;
cl_int *s2 = 0; cl_int *s2 = 0;
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_uint *out[VECTOR_SIZE_COUNT]; cl_uint *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_uint *)clEnqueueMapBuffer( // start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_uint *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
}
// Get that moving // Get that moving
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n"); if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
}
// Init input array // Init input array
cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements; cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements;
@@ -288,31 +291,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
goto exit; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ goto exit;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
goto exit; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
goto exit;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
goto exit; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -216,19 +216,22 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
Force64BitFPUPrecision(); Force64BitFPUPrecision();
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_ulong *out[VECTOR_SIZE_COUNT]; cl_ulong *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_ulong *)clEnqueueMapBuffer( // start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_ulong *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
} }
@@ -242,8 +245,9 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
int totalSpecialValueCount = specialValuesCount * specialValuesCount; int totalSpecialValueCount = specialValuesCount * specialValuesCount;
int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements; int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements;
// Test edge cases
if (job_id <= (cl_uint)lastSpecialJobIndex) if (job_id <= (cl_uint)lastSpecialJobIndex)
{ // test edge cases {
cl_double *fp = (cl_double *)p; cl_double *fp = (cl_double *)p;
cl_double *fp2 = (cl_double *)p2; cl_double *fp2 = (cl_double *)p2;
uint32_t x, y; uint32_t x, y;
@@ -264,7 +268,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
} }
} }
// Init any remaining values. // Init any remaining values
for (; idx < buffer_elements; idx++) for (; idx < buffer_elements; idx++)
{ {
p[idx] = genrand_int64(d); p[idx] = genrand_int64(d);
@@ -287,31 +291,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
goto exit; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ goto exit;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
goto exit; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
goto exit;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
goto exit; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -213,24 +213,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
func = job->f->rfunc; func = job->f->rfunc;
} }
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_uint *out[VECTOR_SIZE_COUNT]; cl_uint *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_uint *)clEnqueueMapBuffer( // start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_uint *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
}
// Get that moving // Get that moving
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n"); if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
}
// Init input array // Init input array
cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements; cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements;
@@ -269,7 +272,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
} }
} }
// Init any remaining values. // Init any remaining values
for (; idx < buffer_elements; idx++) for (; idx < buffer_elements; idx++)
{ {
p[idx] = genrand_int32(d); p[idx] = genrand_int32(d);
@@ -301,31 +304,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
goto exit; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ goto exit;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
goto exit; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
goto exit;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
goto exit; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -146,28 +146,53 @@ int TestFunc_DoubleI_Double_Double(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
} gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE); memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE);
if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j], CL_FALSE, if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j],
0, BUFFER_SIZE, gOut2[j], 0, NULL, CL_FALSE, 0, BUFFER_SIZE,
NULL))) gOut2[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n",
error, j);
goto exit;
}
}
else
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n", if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
error, j); &pattern, sizeof(pattern), 0,
goto exit; BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 1 failed! err: %d\n",
error);
return error;
}
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer2[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 2 failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -149,28 +149,53 @@ int TestFunc_FloatI_Float_Float(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
} gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE); memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE);
if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j], CL_FALSE, if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j],
0, BUFFER_SIZE, gOut2[j], 0, NULL, CL_FALSE, 0, BUFFER_SIZE,
NULL))) gOut2[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n",
error, j);
goto exit;
}
}
else
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n", if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
error, j); &pattern, sizeof(pattern), 0,
goto exit; BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 1 failed! err: %d\n",
error);
return error;
}
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer2[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 2 failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -107,18 +107,33 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -106,18 +106,33 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -208,24 +208,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
Force64BitFPUPrecision(); Force64BitFPUPrecision();
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_long *out[VECTOR_SIZE_COUNT]; cl_long *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_long *)clEnqueueMapBuffer( // start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_long *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
}
// Get that moving // Get that moving
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n"); if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
}
// Init input array // Init input array
double *p = (double *)gIn + thread_id * buffer_elements; double *p = (double *)gIn + thread_id * buffer_elements;
@@ -234,8 +237,9 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
int totalSpecialValueCount = specialValuesCount * specialValuesCount; int totalSpecialValueCount = specialValuesCount * specialValuesCount;
int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements; int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements;
// Test edge cases
if (job_id <= (cl_uint)lastSpecialJobIndex) if (job_id <= (cl_uint)lastSpecialJobIndex)
{ // test edge cases {
uint32_t x, y; uint32_t x, y;
x = (job_id * buffer_elements) % specialValuesCount; x = (job_id * buffer_elements) % specialValuesCount;
@@ -254,7 +258,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
} }
} }
// Init any remaining values. // Init any remaining values
for (; idx < buffer_elements; idx++) for (; idx < buffer_elements; idx++)
{ {
((cl_ulong *)p)[idx] = genrand_int64(d); ((cl_ulong *)p)[idx] = genrand_int64(d);
@@ -277,31 +281,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
goto exit; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ goto exit;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
goto exit; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
goto exit;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
goto exit; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -197,24 +197,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
cl_float *s = 0; cl_float *s = 0;
cl_float *s2 = 0; cl_float *s2 = 0;
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_int *out[VECTOR_SIZE_COUNT]; cl_int *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_int *)clEnqueueMapBuffer( // start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_int *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
}
// Get that moving // Get that moving
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n"); if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
}
// Init input array // Init input array
cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements; cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements;
@@ -224,8 +227,9 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
int totalSpecialValueCount = specialValuesCount * specialValuesCount; int totalSpecialValueCount = specialValuesCount * specialValuesCount;
int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements; int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements;
// Test edge cases
if (job_id <= (cl_uint)lastSpecialJobIndex) if (job_id <= (cl_uint)lastSpecialJobIndex)
{ // test edge cases {
float *fp = (float *)p; float *fp = (float *)p;
float *fp2 = (float *)p2; float *fp2 = (float *)p2;
uint32_t x, y; uint32_t x, y;
@@ -247,7 +251,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
} }
} }
// Init any remaining values. // Init any remaining values
for (; idx < buffer_elements; idx++) for (; idx < buffer_elements; idx++)
{ {
p[idx] = genrand_int32(d); p[idx] = genrand_int32(d);
@@ -270,31 +274,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
goto exit; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ goto exit;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
goto exit; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
goto exit;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
goto exit; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -86,24 +86,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
Force64BitFPUPrecision(); Force64BitFPUPrecision();
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_long *out[VECTOR_SIZE_COUNT]; cl_long *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_long *)clEnqueueMapBuffer( // start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_long *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
}
// Get that moving // Get that moving
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n"); if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
}
// Write the new values to the input array // Write the new values to the input array
cl_double *p = (cl_double *)gIn + thread_id * buffer_elements; cl_double *p = (cl_double *)gIn + thread_id * buffer_elements;
@@ -119,31 +122,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
return error; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ return error;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
return error; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
return error;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
return error; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
return error;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -89,24 +89,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
#define ref_func(s) (signbit_test ? func.i_f_f(s) : func.i_f(s)) #define ref_func(s) (signbit_test ? func.i_f_f(s) : func.i_f(s))
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_int *out[VECTOR_SIZE_COUNT]; cl_int *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_int *)clEnqueueMapBuffer( // start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_int *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
}
// Get that moving // Get that moving
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n"); if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
}
// Init input array // Init input array
cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements; cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements;
@@ -121,31 +124,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
return error; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ return error;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
return error; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
return error;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
return error; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
return error;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -113,18 +113,33 @@ int TestFunc_mad_Double(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -114,18 +114,33 @@ int TestFunc_mad_Float(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -65,6 +65,7 @@ static int gStopOnError = 0;
static bool gSkipRestOfTests; static bool gSkipRestOfTests;
int gForceFTZ = 0; int gForceFTZ = 0;
int gWimpyMode = 0; int gWimpyMode = 0;
int gHostFill = 0;
static int gHasDouble = 0; static int gHasDouble = 0;
static int gTestFloat = 1; static int gTestFloat = 1;
// This flag should be 'ON' by default and it can be changed through the command // This flag should be 'ON' by default and it can be changed through the command
@@ -421,6 +422,8 @@ static int ParseArgs(int argc, const char **argv)
parseWimpyReductionFactor(arg, gWimpyReductionFactor); parseWimpyReductionFactor(arg, gWimpyReductionFactor);
break; break;
case 'b': gHostFill ^= 1; break;
case 'z': gForceFTZ ^= 1; break; case 'z': gForceFTZ ^= 1; break;
case '1': case '1':
@@ -550,6 +553,7 @@ static void PrintUsage(void)
vlog("\t\t-[2^n]\tSet wimpy reduction factor, recommended range of n is " vlog("\t\t-[2^n]\tSet wimpy reduction factor, recommended range of n is "
"1-10, default factor(%u)\n", "1-10, default factor(%u)\n",
gWimpyReductionFactor); gWimpyReductionFactor);
vlog("\t\t-b\tFill buffers on host instead of device. (Default: off)\n");
vlog("\t\t-z\tToggle FTZ mode (Section 6.5.3) for all functions. (Set by " vlog("\t\t-z\tToggle FTZ mode (Section 6.5.3) for all functions. (Set by "
"device capabilities by default.)\n"); "device capabilities by default.)\n");
vlog("\t\t-v\tToggle Verbosity (Default: off)\n "); vlog("\t\t-v\tToggle Verbosity (Default: off)\n ");

View File

@@ -218,18 +218,33 @@ int TestFunc_Double_Double_Double_Double(const Func *f, MTdata d,
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -240,18 +240,33 @@ int TestFunc_Float_Float_Float_Float(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -94,24 +94,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
Force64BitFPUPrecision(); Force64BitFPUPrecision();
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_ulong *out[VECTOR_SIZE_COUNT]; cl_ulong *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_ulong *)clEnqueueMapBuffer( // start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_ulong *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
}
// Get that moving // Get that moving
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n"); if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
}
// Write the new values to the input array // Write the new values to the input array
cl_double *p = (cl_double *)gIn + thread_id * buffer_elements; cl_double *p = (cl_double *)gIn + thread_id * buffer_elements;
@@ -127,31 +130,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
return error; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ return error;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
return error; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
return error;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
return error; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
return error;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -100,24 +100,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
float half_sin_cos_tan_limit = job->half_sin_cos_tan_limit; float half_sin_cos_tan_limit = job->half_sin_cos_tan_limit;
int ftz = job->ftz; int ftz = job->ftz;
// start the map of the output arrays
cl_event e[VECTOR_SIZE_COUNT]; cl_event e[VECTOR_SIZE_COUNT];
cl_uint *out[VECTOR_SIZE_COUNT]; cl_uint *out[VECTOR_SIZE_COUNT];
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) if (gHostFill)
{ {
out[j] = (cl_uint *)clEnqueueMapBuffer( // start the map of the output arrays
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0, for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{ {
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, out[j] = (cl_uint *)clEnqueueMapBuffer(
error); tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
return error; buffer_size, 0, NULL, e + j, &error);
if (error || NULL == out[j])
{
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
error);
return error;
}
} }
}
// Get that moving // Get that moving
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n"); if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
}
// Write the new values to the input array // Write the new values to the input array
cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements; cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements;
@@ -156,31 +159,48 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
// Wait for the map to finish if (gHostFill)
if ((error = clWaitForEvents(1, e + j)))
{ {
vlog_error("Error: clWaitForEvents failed! err: %d\n", error); // Wait for the map to finish
return error; if ((error = clWaitForEvents(1, e + j)))
} {
if ((error = clReleaseEvent(e[j]))) vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
{ return error;
vlog_error("Error: clReleaseEvent failed! err: %d\n", error); }
return error; if ((error = clReleaseEvent(e[j])))
{
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
return error;
}
} }
// Fill the result buffer with garbage, so that old results don't carry // Fill the result buffer with garbage, so that old results don't carry
// over // over
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(out[j], &pattern, buffer_size); if (gHostFill)
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
out[j], 0, NULL, NULL)))
{ {
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n", memset_pattern4(out[j], &pattern, buffer_size);
error); if ((error = clEnqueueUnmapMemObject(
return error; tinfo->tQueue, tinfo->outBuf[j], out[j], 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
error);
return error;
}
}
else
{
if ((error = clEnqueueFillBuffer(tinfo->tQueue, tinfo->outBuf[j],
&pattern, sizeof(pattern), 0,
buffer_size, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
// run the kernel // Run the kernel
size_t vectorCount = size_t vectorCount =
(buffer_elements + sizeValues[j] - 1) / sizeValues[j]; (buffer_elements + sizeValues[j] - 1) / sizeValues[j];
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its

View File

@@ -106,28 +106,53 @@ int TestFunc_Double2_Double(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
} gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE); memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE);
if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j], CL_FALSE, if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j],
0, BUFFER_SIZE, gOut2[j], 0, NULL, CL_FALSE, 0, BUFFER_SIZE,
NULL))) gOut2[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n",
error, j);
goto exit;
}
}
else
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n", if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
error, j); &pattern, sizeof(pattern), 0,
goto exit; BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 1 failed! err: %d\n",
error);
return error;
}
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer2[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 2 failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -122,28 +122,53 @@ int TestFunc_Float2_Float(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
} gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE); memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE);
if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j], CL_FALSE, if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j],
0, BUFFER_SIZE, gOut2[j], 0, NULL, CL_FALSE, 0, BUFFER_SIZE,
NULL))) gOut2[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n",
error, j);
goto exit;
}
}
else
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n", if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
error, j); &pattern, sizeof(pattern), 0,
goto exit; BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 1 failed! err: %d\n",
error);
return error;
}
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 2 failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -114,28 +114,53 @@ int TestFunc_DoubleI_Double(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
} gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE); memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE);
if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j], CL_FALSE, if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j],
0, BUFFER_SIZE, gOut2[j], 0, NULL, CL_FALSE, 0, BUFFER_SIZE,
NULL))) gOut2[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n",
error, j);
goto exit;
}
}
else
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n", if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
error, j); &pattern, sizeof(pattern), 0,
goto exit; BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 1 failed! err: %d\n",
error);
return error;
}
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer2[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 2 failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -119,28 +119,53 @@ int TestFunc_FloatI_Float(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
} gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE); memset_pattern4(gOut2[j], &pattern, BUFFER_SIZE);
if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j], CL_FALSE, if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer2[j],
0, BUFFER_SIZE, gOut2[j], 0, NULL, CL_FALSE, 0, BUFFER_SIZE,
NULL))) gOut2[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n",
error, j);
goto exit;
}
}
else
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2b(%d) ***\n", if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
error, j); &pattern, sizeof(pattern), 0,
goto exit; BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 1 failed! err: %d\n",
error);
return error;
}
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer2[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer 2 failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -99,18 +99,33 @@ int TestFunc_Double_ULong(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -106,18 +106,33 @@ int TestFunc_Float_UInt(const Func *f, MTdata d, bool relaxedMode)
return error; return error;
} }
// write garbage into output arrays // Write garbage into output arrays
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
{ {
uint32_t pattern = 0xffffdead; uint32_t pattern = 0xffffdead;
memset_pattern4(gOut[j], &pattern, BUFFER_SIZE); if (gHostFill)
if ((error =
clEnqueueWriteBuffer(gQueue, gOutBuffer[j], CL_FALSE, 0,
BUFFER_SIZE, gOut[j], 0, NULL, NULL)))
{ {
vlog_error("\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", memset_pattern4(gOut[j], &pattern, BUFFER_SIZE);
error, j); if ((error = clEnqueueWriteBuffer(gQueue, gOutBuffer[j],
goto exit; CL_FALSE, 0, BUFFER_SIZE,
gOut[j], 0, NULL, NULL)))
{
vlog_error(
"\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n",
error, j);
goto exit;
}
}
else
{
if ((error = clEnqueueFillBuffer(gQueue, gOutBuffer[j],
&pattern, sizeof(pattern), 0,
BUFFER_SIZE, 0, NULL, NULL)))
{
vlog_error("Error: clEnqueueFillBuffer failed! err: %d\n",
error);
return error;
}
} }
} }

View File

@@ -59,6 +59,7 @@ extern int gSkipCorrectnessTesting;
extern int gForceFTZ; extern int gForceFTZ;
extern int gFastRelaxedDerived; extern int gFastRelaxedDerived;
extern int gWimpyMode; extern int gWimpyMode;
extern int gHostFill;
extern int gIsInRTZMode; extern int gIsInRTZMode;
extern int gInfNanSupport; extern int gInfNanSupport;
extern int gIsEmbedded; extern int gIsEmbedded;