[OpenCL] Improve OpenCL version detection #13434
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As it was mentioned in #13362, it would be nice to add check when the user is using a version of libOpenCL.so that is too old.
In this PR we introduce this functionality. In the
initmethod, we traverse through all OpenCL devices and check their version. If the version is older than the target version in TVM, then we notify the user that we will skip this device. We cannot throw any exception from methodinitbecause it is possible that you have compiled host code with OpenCL support, but the host device won't have any OpenCL device which is supported by TVM (e.g. they all have too old version of libOpenCL.so or there is no OpenCL driver installed). From OpenCL codegen we call function OpenCLModuleCreate. In the OpenCLModuleCreate init function might be called and in this case an exception will be generated on the host side although that the target device might be supported by TVM. This is why we don't throw any exceptions in the init function.If in the runtime we use some OpenCL methods and the list of the devices is empty, then we will generate an exception and notify user that possible reason is because version of libOpenCL.so is too old.