MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCL-CTS / copy_partial_size

Function copy_partial_size

test_conformance/profiling/copy.cpp:243–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241
242
243static int copy_partial_size( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements, cl_uint srcStart, cl_uint dstStart, int size, MTdata d )
244{
245 cl_mem streams[2];
246 cl_event copyEvent;
247 cl_ulong queueStart, submitStart, writeStart, writeEnd;
248 cl_int *inptr, *outptr;
249 int err = 0;
250 int i;
251
252 inptr = (cl_int *)malloc(sizeof(cl_int) * num_elements);
253 outptr = (cl_int *)malloc(sizeof(cl_int) * num_elements);
254
255 streams[0] = clCreateBuffer(context, CL_MEM_READ_WRITE,
256 sizeof(cl_int) * num_elements, NULL, &err);
257 if (!streams[0])
258 {
259 log_error("clCreateBuffer failed\n");
260 return -1;
261 }
262 streams[1] = clCreateBuffer(context, CL_MEM_READ_WRITE,
263 sizeof(cl_int) * num_elements, NULL, &err);
264 if (!streams[1])
265 {
266 log_error("clCreateBuffer failed\n");
267 return -1;
268 }
269
270 for (i=0; i<num_elements; i++){
271 inptr[i] = (int)genrand_int32(d);
272 outptr[i] = (int)get_random_float( -1.f, 1.f, d ); // seed with incorrect data
273 }
274
275 err = clEnqueueWriteBuffer(queue, streams[0], true, 0, sizeof(cl_int)*num_elements, (void *)inptr, 0, NULL, NULL);
276 if (err != CL_SUCCESS)
277 {
278 log_error("clWriteArray failed\n");
279 return -1;
280 }
281
282 err = clEnqueueCopyBuffer( queue, streams[0], streams[1], srcStart*sizeof(cl_int), dstStart*sizeof(cl_int),
283 sizeof(cl_int)*size, 0, NULL, &copyEvent );
284 if( err != CL_SUCCESS){
285 print_error( err, "clCopyArray failed" );
286 clReleaseMemObject( streams[0] );
287 clReleaseMemObject( streams[1] );
288 free( outptr );
289 free( inptr );
290 return -1;
291 }
292
293 // This synchronization point is needed in order to assume the data is valid.
294 // Getting profiling information is not a synchronization point.
295 err = clWaitForEvents( 1, &copyEvent );
296 if( err != CL_SUCCESS )
297 {
298 clReleaseEvent(copyEvent);
299 clReleaseMemObject( streams[0] );
300 clReleaseMemObject( streams[1] );

Callers 1

REGISTER_TESTFunction · 0.85

Calls 4

genrand_int32Function · 0.85
get_random_floatFunction · 0.85
verify_copy_arrayFunction · 0.85
check_timesFunction · 0.85

Tested by

no test coverage detected