Repository navigation
Conversation
trailing_zeros becomes SPIR-V's ctz, which spirv2clc can't translate, so reductions over several non-contiguous dims failed to compile on OpenCL.jl's OpenCL C path (e.g. pocl with program_backend!(:opencl)). For a power of two, count_ones(sz - 1) is the same shift.
This was referenced Oct 7, 2026
Member
Author
|
Fixing this in spirv2clc instead (JuliaGPU/spirv2clc#6), which translates |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reductions over several non-contiguous
dimsdecode the reduced offset withtrailing_zeros(sz)for power-of-two extents. That lowers to SPIR-V'sctz, which spirv2clc can't translate ("UNIMPLEMENTED extended instruction 152"), so on OpenCL.jl's OpenCL C path these reductions fail to compile:For a power of two,
count_ones(sz - 1)is the same shift, andispow2already usescount_ones, which translates. With this changedims=(1,3),(2,4)and(1,3,4)compile and match Base on pocl's OpenCL C path. Found by OpenCL.jl'spoclctest target, running the GPUArrays 12 testsuite (meanandmapreducewith severaldims).(The
trailing_zeroscalls in the bitonic sort are on compile-time constants and fold away.)