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

Function copy_size

test_conformance/profiling/copy.cpp:98–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96
97
98static int copy_size( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements, MTdata d )
99{
100 cl_mem streams[2];
101 cl_event copyEvent;
102 cl_ulong queueStart, submitStart, writeStart, writeEnd;
103 cl_int *int_input_ptr, *int_output_ptr;
104 int err = 0;
105 int i;
106
107 int_input_ptr = (cl_int*)malloc(sizeof(cl_int) * num_elements);
108 int_output_ptr = (cl_int*)malloc(sizeof(cl_int) * num_elements);
109
110 streams[0] = clCreateBuffer(context, CL_MEM_READ_WRITE,
111 sizeof(cl_int) * num_elements, NULL, &err);
112 if( !streams[0] ){
113 log_error("clCreateBuffer failed\n");
114 return -1;
115 }
116 streams[1] = clCreateBuffer(context, CL_MEM_READ_WRITE,
117 sizeof(cl_int) * num_elements, NULL, &err);
118 if( !streams[1] ){
119 log_error("clCreateBuffer failed\n");
120 return -1;
121 }
122
123 for (i=0; i<num_elements; i++){
124 int_input_ptr[i] = (int)genrand_int32(d);
125 int_output_ptr[i] = (int)genrand_int32(d) >> 30; // seed with incorrect data
126 }
127
128 err = clEnqueueWriteBuffer( queue, streams[0], true, 0, sizeof(cl_int)*num_elements, (void *)int_input_ptr, 0, NULL, NULL );
129 if( err != CL_SUCCESS ){
130 print_error( err, "clWriteArray failed" );
131 clReleaseMemObject( streams[0] );
132 clReleaseMemObject( streams[1] );
133 free( (void *)int_output_ptr );
134 free( (void *)int_input_ptr );
135 return -1;
136 }
137
138 err = clEnqueueCopyBuffer( queue, streams[0], streams[1], 0, 0, sizeof(cl_int)*num_elements, 0, NULL, &copyEvent );
139 if( err != CL_SUCCESS ){
140 print_error( err, "clCopyArray failed" );
141 clReleaseMemObject( streams[0] );
142 clReleaseMemObject( streams[1] );
143 free( (void *)int_output_ptr );
144 free( (void *)int_input_ptr );
145 return -1;
146 }
147
148 // This synchronization point is needed in order to assume the data is valid.
149 // Getting profiling information is not a synchronization point.
150 err = clWaitForEvents( 1, &copyEvent );
151 if( err != CL_SUCCESS )
152 {
153 clReleaseEvent(copyEvent);
154 clReleaseMemObject( streams[0] );
155 clReleaseMemObject( streams[1] );

Callers 1

REGISTER_TESTFunction · 0.85

Calls 3

genrand_int32Function · 0.85
verify_copy_arrayFunction · 0.85
check_timesFunction · 0.85

Tested by

no test coverage detected