Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenCL] Refactor OpenCL init function #13919

Merged
merged 1 commit into from
Feb 7, 2023

Conversation

echuraev
Copy link
Contributor

@echuraev echuraev commented Feb 6, 2023

On the platforms with several OpenCL platforms (e.g. Intel CPU and NVidia GPU) it was possible to use OpenCL device only from one platform. And in case when Intel was the first in the platforms list than it wasn't possible to run model on NVidia GPU.

In this PR the init function was modified and now it is possible to use OpenCL devices from different platforms. In case when there are several GPU accelerators then it is possible to select one of them. You can use device id to select GPU device. On the code below the device names of two OpenCL devices are printed:

import tvm

print("opencl 0: ", tvm.opencl(0).device_name)
print("opencl 1: ", tvm.opencl(1).device_name)

In case then the machine doesn't contain any GPUs then we will try to use CPU if OpenCL runtime is available.

On the platforms with several OpenCL platforms (e.g. Intel CPU and
NVidia GPU) it was possible to use OpenCL device only from one
platform. And in case when Intel was the first in the platforms list
than it wasn't possible to run model on NVidia GPU.

In this PR the init function was modified and now it is possible to use
OpenCL devices from different platforms. In case when there are several
GPU accelerators then it is possible to select one of them. You can use
device id to select GPU device. On the code below the device names of
two OpenCL devices are printed:
```python
import tvm

print("opencl 0: ", tvm.opencl(0).device_name)
print("opencl 1: ", tvm.opencl(1).device_name)
```

In case then the machine doesn't contain any GPUs then we will try to
use CPU if OpenCL runtime is available.
@tvm-bot
Copy link
Collaborator

tvm-bot commented Feb 6, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@echuraev echuraev marked this pull request as ready for review February 6, 2023 13:19
@echuraev
Copy link
Contributor Author

echuraev commented Feb 7, 2023

cc: @masahi, @elvin-n, @srkreddy1238

@masahi masahi merged commit 7323e1d into apache:main Feb 7, 2023
@echuraev echuraev deleted the echuraev/refactor_opencl_device_api branch April 14, 2023 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants