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

Function test_stream_read

test_conformance/profiling/readArray.cpp:562–705  ·  view source on GitHub ↗

----- the test functions

Source from the content-addressed store, hash-verified

560
561//----- the test functions
562int test_stream_read( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements, size_t size, const char *type, int loops,
563 const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) )
564{
565 cl_mem streams[5];
566 void *outptr[5];
567 cl_program program[5];
568 cl_kernel kernel[5];
569 cl_event readEvent;
570 cl_ulong queueStart, submitStart, readStart, readEnd;
571 size_t threads[1];
572 int err, err_count = 0;
573 int i;
574 size_t ptrSizes[5];
575
576 threads[0] = (size_t)num_elements;
577
578 ptrSizes[0] = size;
579 ptrSizes[1] = ptrSizes[0] << 1;
580 ptrSizes[2] = ptrSizes[1] << 1;
581 ptrSizes[3] = ptrSizes[2] << 1;
582 ptrSizes[4] = ptrSizes[3] << 1;
583 for( i = 0; i < loops; i++ ){
584 outptr[i] = malloc( ptrSizes[i] * num_elements );
585 if( ! outptr[i] ){
586 log_error( " unable to allocate %d bytes for outptr\n", (int)( ptrSizes[i] * num_elements ) );
587 return -1;
588 }
589 streams[i] = clCreateBuffer(context, CL_MEM_READ_WRITE,
590 ptrSizes[i] * num_elements, NULL, &err);
591 if( !streams[i] ){
592 log_error( " clCreateBuffer failed\n" );
593 free( outptr[i] );
594 return -1;
595 }
596 err = create_single_kernel_helper( context, &program[i], &kernel[i], 1, &kernelCode[i], kernelName[i] );
597 if( err ){
598 log_error( " Error creating program for %s\n", type );
599 clReleaseMemObject(streams[i]);
600 free( outptr[i] );
601 return -1;
602 }
603
604 err = clSetKernelArg( kernel[i], 0, sizeof( cl_mem ), (void *)&streams[i] );
605 if( err != CL_SUCCESS ){
606 print_error( err, "clSetKernelArg failed" );
607 clReleaseProgram( program[i] );
608 clReleaseKernel( kernel[i] );
609 clReleaseMemObject( streams[i] );
610 free( outptr[i] );
611 return -1;
612 }
613
614 err = clEnqueueNDRangeKernel( queue, kernel[i], 1, NULL, threads, NULL, 0, NULL, NULL );
615
616 if( err != CL_SUCCESS ){
617 print_error( err, "clEnqueueNDRangeKernel failed" );
618 clReleaseKernel( kernel[i] );
619 clReleaseProgram( program[i] );

Callers 1

REGISTER_TESTFunction · 0.85

Calls 2

check_timesFunction · 0.85

Tested by

no test coverage detected