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

Function test_vload

test_conformance/basic/test_vloadstore.cpp:112–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110 unsigned int, create_program_fn, size_t);
111
112static int test_vload(cl_device_id device, cl_context context,
113 cl_command_queue queue, ExplicitType type,
114 unsigned int vecSize, create_program_fn createFn,
115 size_t bufferSize)
116{
117 clProgramWrapper program;
118 clKernelWrapper kernel;
119 clMemWrapper streams[ 4 ];
120 MTdataHolder d(gRandomSeed);
121 const size_t numLoads = (DEBUG) ? 16 : NUM_LOADS;
122
123 if (DEBUG) bufferSize = (bufferSize < 128) ? bufferSize : 128;
124
125 size_t threads[ 1 ], localThreads[ 1 ];
126 clProtectedArray inBuffer( bufferSize );
127 cl_uint offsets[ numLoads ], alignmentOffsets[ numLoads ];
128 size_t numElements, typeSize, i;
129 unsigned int outVectorSize;
130
131 pragma_str[0] = '\0';
132 if (type == kDouble)
133 std::snprintf(pragma_str, sizeof(pragma_str),
134 "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n");
135 else if (type == kHalf)
136 std::snprintf(pragma_str, sizeof(pragma_str),
137 "#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n");
138
139 typeSize = get_explicit_type_size( type );
140 numElements = bufferSize / ( typeSize * vecSize );
141 bufferSize = numElements * typeSize * vecSize; // To account for rounding
142
143 if (DEBUG) log_info("Testing: numLoads: %d, typeSize: %d, vecSize: %d, numElements: %d, bufferSize: %d\n", (int)numLoads, (int)typeSize, vecSize, (int)numElements, (int)bufferSize);
144
145 // Create some random input data and random offsets to load from
146 generate_random_data( type, numElements * vecSize, d, (void *)inBuffer );
147 for( i = 0; i < numLoads; i++ )
148 {
149 offsets[ i ] = (cl_uint)random_in_range( 0, (int)numElements - 1, d );
150 if( offsets[ i ] < numElements - 2 )
151 alignmentOffsets[ i ] = (cl_uint)random_in_range( 0, (int)vecSize - 1, d );
152 else
153 alignmentOffsets[ i ] = 0;
154 if (LINEAR_OFFSETS) offsets[i] = (cl_uint)i;
155 }
156 if (LINEAR_OFFSETS) log_info("Offsets set to thread IDs to simplify output.\n");
157
158 // 32-bit fixup
159 outVectorSize = vecSize;
160
161 // Declare output buffers now
162 std::vector<char> outBuffer(numLoads * typeSize * outVectorSize);
163 std::vector<char> referenceBuffer(numLoads * typeSize * vecSize);
164
165 // Create the program
166 std::string programSrc;
167 createFn( programSrc, numElements, type, vecSize, outVectorSize);
168
169 // Create our kernel

Callers

nothing calls this directly

Calls 7

get_explicit_type_sizeFunction · 0.85
generate_random_dataFunction · 0.85
random_in_rangeFunction · 0.85
GetDataVectorStringFunction · 0.85
get_explicit_type_nameFunction · 0.85

Tested by

no test coverage detected