-
Notifications
You must be signed in to change notification settings - Fork 755
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
sycl::is_compatible is currently not very useful #7561
Comments
Tagging @gmlueck here to hear his feedback |
Related spec clarification: KhronosGroup/SYCL-Docs#381 |
KhronosGroup/SYCL-Docs#381 is in master, so it can be implemented now. |
Modify `is_compatible` to check if specific target is defined with `-fsycl-targets` and change the result. Previously there was a situation when kernel is compatible with the device by aspects, but actually it fails to run on this device as it was compiled for another target device. Related spec change: KhronosGroup/SYCL-Docs#381 Resolves #7561
#9769 fixes this issue only partially. |
Thank you! The fix behaves as you described.
The AMD devices are now hidden in the OpenCL backend, so cannot reproduce :) Full logs (click to expand)Using the same test code and IntelLLVM ef03323 (with #9769). $ clang++ -fsycl -fsycl-targets=spir64 test_7561.cpp -o test
$ ONEAPI_DEVICE_SELECTOR=level_zero:gpu ./test # Works OK!
Checking Intel(R) Arc(TM) A770 Graphics
Device is compatible
Checking Intel(R) UHD Graphics 770
Device is compatible
$ ONEAPI_DEVICE_SELECTOR=hip:gpu ./test # Now correctly returns false!
Checking AMD Radeon RX 6400
Device is incompatible
$ ONEAPI_DEVICE_SELECTOR=cuda:gpu ./test # Now correctly returns false!
Checking NVIDIA GeForce RTX 3060
Device is incompatible As mentioned, a mismatched architecture is not caught yet (neither for AMD nor for NVIDIA): $ clang++ -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --offload-arch=sm_90 test_7561.cpp -o test
$ ONEAPI_DEVICE_SELECTOR=level_zero:gpu ./test # Now correctly returns false!
Checking Intel(R) Arc(TM) A770 Graphics
Device is incompatible
Checking Intel(R) UHD Graphics 770
Device is incompatible
$ ONEAPI_DEVICE_SELECTOR=cuda:gpu ./test # I have sm_86 device, which is not compatible, yet the function reports that it is:
Checking NVIDIA GeForce RTX 3060
Device is compatible
UR CUDA ERROR:
Value: 209
Name: CUDA_ERROR_NO_BINARY_FOR_GPU
Description: no kernel image is available for execution on the device
Function: buildProgram
Source Location: /home/aland/intel-sycl/llvm/sycl/plugins/unified_runtime/ur/adapters/cuda/program.cpp:145
terminate called after throwing an instance of 'sycl::_V1::compile_program_error'
what(): The program was built for 1 devices
Build program log for 'NVIDIA GeForce RTX 3060':
-999 (Unknown PI error)
Aborted (core dumped)
$ ONEAPI_DEVICE_SELECTOR=hip:gpu ./test # Now correctly returns false!
Checking AMD Radeon RX 6400
Device is incompatible $ clang++ -fsycl -fsycl-targets=spir64,nvptx64-nvidia-cuda,amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx1031 test_7561.cpp -o test
$ ONEAPI_DEVICE_SELECTOR=hip:gpu ./test # Compiled for gfx1031, device is gfx1034
Checking AMD Radeon RX 6400
Device is compatible
PI HIP ERROR:
Value: 209
Name: hipErrorNoBinaryForGpu
Description: no kernel image is available for execution on the device
Function: build_program
Source Location: /home/aland/intel-sycl/llvm/sycl/plugins/hip/pi_hip.cpp:744
PI HIP ERROR:
Value: 400
Name: hipErrorInvalidHandle
Description: invalid resource handle
Function: hip_piProgramRelease
Source Location: /home/aland/intel-sycl/llvm/sycl/plugins/hip/pi_hip.cpp:3609
terminate called after throwing an instance of 'sycl::_V1::compile_program_error'
what(): The program was built for 1 devices
Build program log for 'AMD Radeon RX 6400':
5� -999 (Unknown PI error)
Aborted (core dumped)
# ^^^^ Uninitialized memory in the build log? Compiling for multiple architectures works fine too 👍 $ clang++ -fsycl -fsycl-targets=spir64,nvptx64-nvidia-cuda,amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx1034 test_7561.cpp -o test
$ ./test
Checking Intel(R) Arc(TM) A770 Graphics
Device is compatible
Checking Intel(R) UHD Graphics 770
Device is compatible
Checking 12th Gen Intel(R) Core(TM) i9-12900K
Device is compatible
Checking Intel(R) FPGA Emulation Device
Device is compatible
Checking Intel(R) Arc(TM) A770 Graphics
Device is compatible
Checking Intel(R) UHD Graphics 770
Device is compatible
Checking NVIDIA GeForce RTX 3060
Device is compatible
Checking AMD Radeon RX 6400
Device is compatible |
Modify `is_compatible` to check if specific target is defined with `-fsycl-targets` and change the result. Previously there was a situation when kernel is compatible with the device by aspects, but actually it fails to run on this device as it was compiled for another target device. Related spec change: KhronosGroup/SYCL-Docs#381 Resolves intel#7561
@al42and thanks for the quick feedback! I'll keep this issue opened until is_compatible() fully matches the requirements. |
Describe the bug
The spec is somewhat vague about the behavior of
is_compatible
:The current implementation seems to fulfill these requirements, so it is not technically broken.
However, it does not handle many cases related to whether the device was targeted during compilation. One would expect that
is_compatible
returningtrue
would mean that the kernel can be run on the device. This is not the case.E.g., when targeting SPIR-V, the function falsely reports OpenCL AMD device as compatible (an exception is thrown when trying to launch the kernel) and throws an exception when called for HIP and CUDA devices (one would expect it to return
false
):If we target NVPTX backed with unsupported
--offload-arch
, the kernel is anyway reported as compatible, while it cannot be launched:To Reproduce
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: