MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CreateDefaultGPUDevice

Function CreateDefaultGPUDevice

tensorflow/lite/delegates/gpu/cl/cl_device.cc:373–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371}
372
373Status CreateDefaultGPUDevice(CLDevice* result) {
374 cl_uint num_platforms;
375 clGetPlatformIDs(0, nullptr, &num_platforms);
376 if (num_platforms == 0) {
377 return UnknownError("No supported OpenCL platform.");
378 }
379 std::vector<cl_platform_id> platforms(num_platforms);
380 clGetPlatformIDs(num_platforms, platforms.data(), nullptr);
381
382 cl_uint num_devices;
383 clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU, 0, nullptr, &num_devices);
384 if (num_devices == 0) {
385 return UnknownError("No GPU on current platform.");
386 }
387
388 std::vector<cl_device_id> devices(num_devices);
389 clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU, num_devices, devices.data(),
390 nullptr);
391
392 *result = CLDevice(devices[0], platforms[0]);
393 return OkStatus();
394}
395
396} // namespace cl
397} // namespace gpu

Callers 1

CreateEnvironmentFunction · 0.85

Calls 4

CLDeviceClass · 0.85
OkStatusFunction · 0.85
UnknownErrorFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected