Repository navigation
Copy from BitArrays to GPU arrays without scalar indexing - #849
Merged
Merged
Conversation
sasmith-14
force-pushed
the
bitarray-copyto
branch
from
November 12, 2026 11:33
9375010 to
272a20c
Compare
Contributor
Author
|
hey @maleadt, friendly ping on this one when you get a chance! the red Metal 1.10 job is the Rational crash from JuliaGPU/Metal.jl#1139 (same on the other open PRs, e.g. #857), so it's not from this change. it should go green once JuliaGPU/Metal.jl#1138 is in. |
The host-to-device `copyto!` methods only took `Array` sources, so a `BitArray` fell back to Base's elementwise copy. Unpack it into a `Vector` on the CPU first, as is already done for mismatched element types. Fixes JuliaGPU#836
The reverse of the previous change: device-to-host `copyto!` methods only took `Array` destinations, so copying into a `BitArray` fell back to elementwise indexing of the GPU array. Download into a `Vector` first and pack it on the CPU.
`x[inds] = v` uploads a CPU `Array` value before launching the kernel, but passed a `BitArray` through as is, which failed to compile. Upload it the same way, now that `copyto!` accepts `BitArray` sources.
maleadt
force-pushed
the
bitarray-copyto
branch
from
November 19, 2026 14:11
272a20c to
83c0f17
Compare
maleadt
approved these changes
Nov 19, 2026
Member
|
Thanks! I rebased this and added the reverse direction ( |
Contributor
Author
|
Thanks for extending it, makes sense to cover both directions. |
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.
Fixes #836.
GPUArrays' host-device copies only handled
Arrays on the CPU side, so aBitArrayfell back to Base's elementwise copy and hit scalar indexing. Because its elements are packed into bits, this stages aBitArraythrough aVectoron the CPU, as the methods that convert between element types already do:copyto!from aBitArrayto a GPU array (this also fixescopy!andappend!);copyto!from a GPU array to aBitArray;BitArrayvalue,x[inds] = bitvec, which passed theBitArrayinto the kernel and failed to compile.Block copies (
copyto!withCartesianIndices) from or to aBitArraystill go through Base.(Used Claude to help with this; I've reviewed the change.)