echuraev commented on code in PR #12711:
URL: https://github.com/apache/tvm/pull/12711#discussion_r964492908
##########
src/runtime/contrib/clml/clml_runtime.cc:
##########
@@ -499,8 +484,17 @@ class CLMLRuntime : public JSONRuntimeBase {
uint32_t n, c, h, w;
};
- bool ExtensionStringPresent(cl_device_id device_id) {
+ bool ExtensionStringPresent(void) {
cl_int result = 0;
+ cl_platform_id platform;
+ cl_device_id device_id;
+ result = clGetPlatformIDs(1, &platform, NULL);
+ ICHECK(result == CL_SUCCESS) << "clGetPlatformIDs:" << result;
+ uint32_t num_devices = 0;
+ result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL,
&num_devices);
+ ICHECK(result == CL_SUCCESS && num_devices == 1) << "clGetDeviceIDs:" <<
result;
+ result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device_id, NULL);
+ ICHECK(device_id && result == CL_SUCCESS) << "clGetDeviceIDs:" << result;
Review Comment:
> The device_id from workspace is a sequence number in our case it's always
0.
I'm not agreed with you. You can also get real id from driver. In your code,
you get the number of available GPU devices and then get id of one GPU device.
Please, take a look into the method
[Init](https://github.com/apache/tvm/blob/main/src/runtime/opencl/opencl_device_api.cc#L412-L459).
We do absolutely the same things and
[here](https://github.com/apache/tvm/blob/main/src/runtime/opencl/opencl_device_api.cc#L430)
we create a vector of real device ids from driver. And next we store these
values in a member `devices`. So you can extract the real device id from this
vector.
When you call `workspace->Init();` it will also create an OpenCL workspace
for GPU device. In case if no GPU devices found, it will print a warning
message. If you need only a GPU device, then you can add a check/assert for it
in the CLML specific code.
Only one thing why I suggested adding a new method `GetClDeviceId` because
in this method we can do all necessary boundary and other checks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]