Fix OpenCL kernel compilation for AMD Radeon devices #8
+62
−9
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.
This PR resolves OpenCL kernel compilation failures on AMD Radeon devices, specifically addressing the issue reported with Radeon RX 5500 where the application would panic with
CL_BUILD_PROGRAM_FAILURE.Root Cause
The primary issue was in the OpenCL kernel's type definitions that were incompatible with AMD's OpenCL implementation:
Incorrect uint64_t typedef: The kernel used
typedef unsigned long uint64_t;which assumesunsigned longis 64-bit. On AMD OpenCL implementations,unsigned longcan be 32-bit, causing type mismatches.Improper literal suffixes: Used
0xFFFFFFFFFFFFFFFFULwhich may not guarantee 64-bit on all platforms.Solution
Kernel Fixes
typedef unsigned long uint64_t;totypedef ulong uint64_t;using OpenCL's guaranteed 64-bit type0xFFFFFFFFFFFFFFFFULto0xFFFFFFFFFFFFFFFFULLfor proper 64-bit literalsRuntime Improvements
User Experience
--kernelflag for custom kernels if neededTesting
The changes have been validated to:
This approach ensures compatibility across both AMD and NVIDIA OpenCL implementations while maintaining backward compatibility.
Fixes #5.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.