mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Fold code into loop (#1218)
Use one loop to read buffers from device, with the last read operation blocking until complete. This pattern cannot be elegantly refactored just yet, mainly for two reasons: - Some tests use goto statements to clean their resources. - Some tests (not modified in this patch) only use blocking read operations. Once code is further unified, this pattern can be refactored into a helper function. Signed-off-by: Marco Antognini <marco.antognini@arm.com>
This commit is contained in:
@@ -636,12 +636,13 @@ static cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
for (j = 0; j < buffer_elements; j++)
|
||||
r[j] = (cl_double)func.f_ff(s[j], s2[j]);
|
||||
|
||||
// Read the data back -- no need to wait for the first N-1 buffers. This is
|
||||
// an in order queue.
|
||||
for (j = gMinVectorSizeIndex; j + 1 < gMaxVectorSizeIndex; j++)
|
||||
// Read the data back -- no need to wait for the first N-1 buffers but wait
|
||||
// for the last buffer. This is an in order queue.
|
||||
for (j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
{
|
||||
cl_bool blocking = (j + 1 < gMaxVectorSizeIndex) ? CL_FALSE : CL_TRUE;
|
||||
out[j] = (cl_ulong *)clEnqueueMapBuffer(
|
||||
tinfo->tQueue, tinfo->outBuf[j], CL_FALSE, CL_MAP_READ, 0,
|
||||
tinfo->tQueue, tinfo->outBuf[j], blocking, CL_MAP_READ, 0,
|
||||
buffer_size, 0, NULL, NULL, &error);
|
||||
if (error || NULL == out[j])
|
||||
{
|
||||
@@ -651,16 +652,6 @@ static cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the last buffer
|
||||
out[j] = (cl_ulong *)clEnqueueMapBuffer(tinfo->tQueue, tinfo->outBuf[j],
|
||||
CL_TRUE, CL_MAP_READ, 0,
|
||||
buffer_size, 0, NULL, NULL, &error);
|
||||
if (error || NULL == out[j])
|
||||
{
|
||||
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j, error);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// Verify data
|
||||
t = (cl_ulong *)r;
|
||||
for (j = 0; j < buffer_elements; j++)
|
||||
|
||||
Reference in New Issue
Block a user