mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 14:09:03 +00:00
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:
@@ -222,24 +222,27 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
|
||||
Force64BitFPUPrecision();
|
||||
|
||||
// start the map of the output arrays
|
||||
cl_event e[VECTOR_SIZE_COUNT];
|
||||
cl_ulong *out[VECTOR_SIZE_COUNT];
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
if (gHostFill)
|
||||
{
|
||||
out[j] = (cl_ulong *)clEnqueueMapBuffer(
|
||||
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
|
||||
buffer_size, 0, NULL, e + j, &error);
|
||||
if (error || NULL == out[j])
|
||||
// start the map of the output arrays
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
{
|
||||
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
|
||||
error);
|
||||
return error;
|
||||
out[j] = (cl_ulong *)clEnqueueMapBuffer(
|
||||
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_WRITE, 0,
|
||||
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
|
||||
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
|
||||
// Get that moving
|
||||
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
|
||||
}
|
||||
|
||||
// Init input array
|
||||
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 lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements;
|
||||
|
||||
// Test edge cases
|
||||
if (job_id <= (cl_uint)lastSpecialJobIndex)
|
||||
{ // test edge cases
|
||||
{
|
||||
cl_double *fp = (cl_double *)p;
|
||||
cl_double *fp2 = (cl_double *)p2;
|
||||
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++)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
// Wait for the map to finish
|
||||
if ((error = clWaitForEvents(1, e + j)))
|
||||
if (gHostFill)
|
||||
{
|
||||
vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
|
||||
goto exit;
|
||||
}
|
||||
if ((error = clReleaseEvent(e[j])))
|
||||
{
|
||||
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
|
||||
goto exit;
|
||||
// Wait for the map to finish
|
||||
if ((error = clWaitForEvents(1, e + j)))
|
||||
{
|
||||
vlog_error("Error: clWaitForEvents 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
|
||||
// over
|
||||
uint32_t pattern = 0xffffdead;
|
||||
memset_pattern4(out[j], &pattern, buffer_size);
|
||||
if ((error = clEnqueueUnmapMemObject(tinfo->tQueue, tinfo->outBuf[j],
|
||||
out[j], 0, NULL, NULL)))
|
||||
if (gHostFill)
|
||||
{
|
||||
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
|
||||
error);
|
||||
goto exit;
|
||||
memset_pattern4(out[j], &pattern, buffer_size);
|
||||
if ((error = clEnqueueUnmapMemObject(
|
||||
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 =
|
||||
(buffer_elements + sizeValues[j] - 1) / sizeValues[j];
|
||||
cl_kernel kernel = job->k[j][thread_id]; // each worker thread has its
|
||||
|
||||
Reference in New Issue
Block a user