JuliaArrays / JuliaArrays/BlockArrays.jl
Matrix multiplication error when using BlockArrays and CUDA
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 254
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I'm trying to parallelize a code making use of BlockArrays. For this, I am using CUDA, and its array type CuArrays. However, I've noticed a strange behaviour when running the following script:
X = mortar((CUDA.randn(5,1),CUDA.randn(5,1)))
Y = mortar((CUDA.randn(5,1),CUDA.randn(5,1)))
X'*Y

Here is an part of the backtrace:

I have also encoutered the same kind of problem when using the mul! function from LinearAlgebra.
So far I haven't been able to come up with a smart workaround: I can always do CuArray(Array(mortar())) but then of course I loose all benefits of using CUDA because multiple data transfers must be made between the GPU and CPU.
On a side-note, the previous script also trigger the following warning in the REPL, and only in the REPL (doesn't appear when running a script with the julia myscript.jl command). I think it is because the default display method in the Julia REPL tries to access the array element-wise (not GPU compatible) and print every element. It's not really important (not a real error, and other packages have the same problem) but it was surprising at first to have an error when we're really doing nothing more than creating an array.

Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the script using BlockArrays.mortar with CUDA.randn arrays, then compare X'*Y with LinearAlgebra.mul!. Trace the BlockArrays and CUDA array interaction shown by the backtrace. Done means matrix multiplication works on CuArrays without converting through Array; the REPL display warning is noted separately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100