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

Function create_cl_objects

test_conformance/SVM/main.cpp:171–261  ·  view source on GitHub ↗

Note that we don't use the context provided by the test harness since it doesn't support multiple devices, so we create are own context here that has all devices, we use the same platform that the harness used.

Source from the content-addressed store, hash-verified

169// Note that we don't use the context provided by the test harness since it doesn't support multiple devices,
170// so we create are own context here that has all devices, we use the same platform that the harness used.
171cl_int create_cl_objects(cl_device_id device_from_harness, const char** ppCodeString, cl_context* context, cl_program *program, cl_command_queue *queues, cl_uint *num_devices, cl_device_svm_capabilities required_svm_caps, std::vector<std::string> extensions_list)
172{
173 cl_int error;
174
175 cl_platform_id platform_id;
176 // find out what platform the harness is using.
177 error = clGetDeviceInfo(device_from_harness, CL_DEVICE_PLATFORM,sizeof(cl_platform_id),&platform_id,NULL);
178 test_error(error,"clGetDeviceInfo failed");
179
180 error = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, 0, NULL, num_devices );
181 test_error(error, "clGetDeviceIDs failed");
182
183 std::vector<cl_device_id> devicesTmp(*num_devices), devices, capable_devices;
184
185 error = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, *num_devices, &devicesTmp[0], NULL );
186 test_error(error, "clGetDeviceIDs failed");
187
188 devices.push_back(device_from_harness);
189 for (size_t i = 0; i < devicesTmp.size(); ++i)
190 {
191 if (device_from_harness != devicesTmp[i])
192 devices.push_back(devicesTmp[i]);
193 }
194
195 // Select only the devices that support the SVM level needed for the test.
196 // Note that if requested SVM capabilities are not supported by any device then the test still passes (even though it does not execute).
197 cl_device_svm_capabilities caps;
198 cl_uint num_capable_devices = 0;
199 for(cl_uint i = 0; i < *num_devices; i++)
200 {
201 Version version = get_device_cl_version(devices[i]);
202
203 if(device_from_harness != devices[i] && version < Version(2,0))
204 {
205 continue;
206 }
207
208 error = clGetDeviceInfo(devices[i], CL_DEVICE_SVM_CAPABILITIES, sizeof(cl_device_svm_capabilities), &caps, NULL);
209 test_error(error,"clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES");
210 if(caps & (~(CL_DEVICE_SVM_COARSE_GRAIN_BUFFER | CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_FINE_GRAIN_SYSTEM | CL_DEVICE_SVM_ATOMICS)))
211 {
212 log_error("clGetDeviceInfo returned an invalid cl_device_svm_capabilities value");
213 return -1;
214 }
215 bool extensions_supported = true;
216 for (auto extension : extensions_list)
217 {
218 if (!is_extension_available(devices[i], extension.c_str()))
219 {
220 log_error("Required extension not found - device id %d - %s\n", i,
221 extension.c_str());
222 extensions_supported = false;
223 break;
224 }
225 }
226 if((caps & required_svm_caps) == required_svm_caps && extensions_supported)
227 {
228 capable_devices.push_back(devices[i]);

Callers 15

REGISTER_TESTFunction · 0.85
REGISTER_TESTFunction · 0.85
REGISTER_TESTFunction · 0.85
REGISTER_TESTFunction · 0.85
REGISTER_TESTFunction · 0.85
REGISTER_TESTFunction · 0.85
REGISTER_TESTFunction · 0.85
REGISTER_TESTFunction · 0.85
REGISTER_TESTFunction · 0.85
REGISTER_TESTFunction · 0.85
REGISTER_TESTFunction · 0.85

Calls 5

get_device_cl_versionFunction · 0.85
VersionClass · 0.85
is_extension_availableFunction · 0.85
sizeMethod · 0.45

Tested by 15

REGISTER_TESTFunction · 0.68
REGISTER_TESTFunction · 0.68
REGISTER_TESTFunction · 0.68
REGISTER_TESTFunction · 0.68
REGISTER_TESTFunction · 0.68
REGISTER_TESTFunction · 0.68
REGISTER_TESTFunction · 0.68
REGISTER_TESTFunction · 0.68
REGISTER_TESTFunction · 0.68
REGISTER_TESTFunction · 0.68
REGISTER_TESTFunction · 0.68