mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
select: using clEnqueueReadBuffer rather than clEnqueueMapBuffer (#1712)
* select: using clEnqueueReadBuffer rather than clEnqueueMapBuffer * Update code to be compatible with clang-format * update code again to be compatible with clang-format * update code again to comply with clang-format * updata code again to be compatible with clang-format The clang-format tool is so weird, it's not even consistent between runs...
This commit is contained in:
@@ -303,6 +303,10 @@ static int doTest(cl_command_queue queue, cl_context context, Type stype, Type c
|
||||
cl_mem dest = NULL;
|
||||
void *ref = NULL;
|
||||
void *sref = NULL;
|
||||
void *src1_host = NULL;
|
||||
void *src2_host = NULL;
|
||||
void *cmp_host = NULL;
|
||||
void *dest_host = NULL;
|
||||
|
||||
cl_ulong blocks = type_size[stype] * 0x100000000ULL / BUFFER_SIZE;
|
||||
size_t block_elements = BUFFER_SIZE / type_size[stype];
|
||||
@@ -359,6 +363,30 @@ static int doTest(cl_command_queue queue, cl_context context, Type stype, Type c
|
||||
dest = clCreateBuffer( context, CL_MEM_WRITE_ONLY, BUFFER_SIZE, NULL, &err );
|
||||
if( err ) { log_error( "Error: could not allocate dest buffer\n" ); ++s_test_fail; goto exit; }
|
||||
|
||||
src1_host = malloc(BUFFER_SIZE);
|
||||
if (NULL == src1_host)
|
||||
{
|
||||
log_error("Error: could not allocate src1_host buffer\n");
|
||||
goto exit;
|
||||
}
|
||||
src2_host = malloc(BUFFER_SIZE);
|
||||
if (NULL == src2_host)
|
||||
{
|
||||
log_error("Error: could not allocate src2_host buffer\n");
|
||||
goto exit;
|
||||
}
|
||||
cmp_host = malloc(BUFFER_SIZE);
|
||||
if (NULL == cmp_host)
|
||||
{
|
||||
log_error("Error: could not allocate cmp_host buffer\n");
|
||||
goto exit;
|
||||
}
|
||||
dest_host = malloc(BUFFER_SIZE);
|
||||
if (NULL == dest_host)
|
||||
{
|
||||
log_error("Error: could not allocate dest_host buffer\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// We block the test as we are running over the range of compare values
|
||||
// "block the test" means "break the test into blocks"
|
||||
@@ -387,13 +415,6 @@ static int doTest(cl_command_queue queue, cl_context context, Type stype, Type c
|
||||
// Setup the input data to change for each block
|
||||
initCmpBuffer(s3, cmptype, i * cmp_stride, block_elements);
|
||||
|
||||
// Create the reference result
|
||||
Select sfunc = (cmptype == ctype[stype][0]) ? vrefSelects[stype][0] : vrefSelects[stype][1];
|
||||
(*sfunc)(ref, s1, s2, s3, block_elements);
|
||||
|
||||
sfunc = (cmptype == ctype[stype][0]) ? refSelects[stype][0] : refSelects[stype][1];
|
||||
(*sfunc)(sref, s1, s2, s3, block_elements);
|
||||
|
||||
if( (err = clEnqueueUnmapMemObject( queue, src1, s1, 0, NULL, NULL )))
|
||||
{ log_error( "Error: coult not unmap src1\n" ); ++s_test_fail; goto exit; }
|
||||
if( (err = clEnqueueUnmapMemObject( queue, src2, s2, 0, NULL, NULL )))
|
||||
@@ -401,6 +422,40 @@ static int doTest(cl_command_queue queue, cl_context context, Type stype, Type c
|
||||
if( (err = clEnqueueUnmapMemObject( queue, cmp, s3, 0, NULL, NULL )))
|
||||
{ log_error( "Error: coult not unmap cmp\n" ); ++s_test_fail; goto exit; }
|
||||
|
||||
// Create the reference result
|
||||
err = clEnqueueReadBuffer(queue, src1, CL_TRUE, 0, BUFFER_SIZE,
|
||||
src1_host, 0, NULL, NULL);
|
||||
if (err)
|
||||
{
|
||||
log_error("Error: Reading buffer from src1 to src1_host failed\n");
|
||||
++s_test_fail;
|
||||
goto exit;
|
||||
}
|
||||
err = clEnqueueReadBuffer(queue, src2, CL_TRUE, 0, BUFFER_SIZE,
|
||||
src2_host, 0, NULL, NULL);
|
||||
if (err)
|
||||
{
|
||||
log_error("Error: Reading buffer from src2 to src2_host failed\n");
|
||||
++s_test_fail;
|
||||
goto exit;
|
||||
}
|
||||
err = clEnqueueReadBuffer(queue, cmp, CL_TRUE, 0, BUFFER_SIZE, cmp_host,
|
||||
0, NULL, NULL);
|
||||
if (err)
|
||||
{
|
||||
log_error("Error: Reading buffer from cmp to cmp_host failed\n");
|
||||
++s_test_fail;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
Select sfunc = (cmptype == ctype[stype][0]) ? vrefSelects[stype][0]
|
||||
: vrefSelects[stype][1];
|
||||
(*sfunc)(ref, src1_host, src2_host, cmp_host, block_elements);
|
||||
|
||||
sfunc = (cmptype == ctype[stype][0]) ? refSelects[stype][0]
|
||||
: refSelects[stype][1];
|
||||
(*sfunc)(sref, src1_host, src2_host, cmp_host, block_elements);
|
||||
|
||||
for (vecsize = 0; vecsize < VECTOR_SIZE_COUNT; ++vecsize)
|
||||
{
|
||||
size_t vector_size = element_count[vecsize] * type_size[stype];
|
||||
@@ -415,7 +470,6 @@ static int doTest(cl_command_queue queue, cl_context context, Type stype, Type c
|
||||
if((err = clSetKernelArg(kernels[vecsize], 3, sizeof cmp, &cmp) ))
|
||||
{ log_error( "Error: Cannot set kernel arg dest! %d\n", err ); ++s_test_fail; goto exit; }
|
||||
|
||||
|
||||
// Wipe destination
|
||||
void *d = clEnqueueMapBuffer( queue, dest, CL_TRUE, CL_MAP_WRITE, 0, BUFFER_SIZE, 0, NULL, NULL, &err );
|
||||
if( err ){ log_error( "Error: Could not map dest" ); ++s_test_fail; goto exit; }
|
||||
@@ -429,18 +483,22 @@ static int doTest(cl_command_queue queue, cl_context context, Type stype, Type c
|
||||
goto exit;
|
||||
}
|
||||
|
||||
d = clEnqueueMapBuffer( queue, dest, CL_TRUE, CL_MAP_READ, 0, BUFFER_SIZE, 0, NULL, NULL, &err );
|
||||
if( err ){ log_error( "Error: Could not map dest # 2" ); ++s_test_fail; goto exit; }
|
||||
|
||||
if ((*checkResults[stype])(d, vecsize == 0 ? sref : ref, block_elements, element_count[vecsize])!=0){
|
||||
log_error("vec_size:%d indx: 0x%16.16llx\n", (int)element_count[vecsize], i);
|
||||
err = clEnqueueReadBuffer(queue, dest, CL_TRUE, 0, BUFFER_SIZE,
|
||||
dest_host, 0, NULL, NULL);
|
||||
if (err)
|
||||
{
|
||||
log_error(
|
||||
"Error: Reading buffer from dest to dest_host failed\n");
|
||||
++s_test_fail;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( (err = clEnqueueUnmapMemObject( queue, dest, d, 0, NULL, NULL ) ) )
|
||||
if ((*checkResults[stype])(dest_host, vecsize == 0 ? sref : ref,
|
||||
block_elements, element_count[vecsize])
|
||||
!= 0)
|
||||
{
|
||||
log_error( "Error: Could not unmap dest" );
|
||||
log_error("vec_size:%d indx: 0x%16.16llx\n",
|
||||
(int)element_count[vecsize], i);
|
||||
++s_test_fail;
|
||||
goto exit;
|
||||
}
|
||||
@@ -459,6 +517,10 @@ exit:
|
||||
if( dest) clReleaseMemObject( dest );
|
||||
if( ref ) free(ref );
|
||||
if( sref ) free(sref );
|
||||
if (src1_host) free(src1_host);
|
||||
if (src2_host) free(src2_host);
|
||||
if (cmp_host) free(cmp_host);
|
||||
if (dest_host) free(dest_host);
|
||||
|
||||
for (vecsize = 0; vecsize < VECTOR_SIZE_COUNT; vecsize++) {
|
||||
clReleaseKernel(kernels[vecsize]);
|
||||
|
||||
Reference in New Issue
Block a user