You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using map! with a conditional on a CuArray there is an error when using a ternary operator but not when multiplying by the result of the conditional on the most recent CUDA.jl version. There are also no issues using map! with these inputs without the conditional. Below are the three implementations of map! I've used. I wasn't able to replicate this issue on a simplified version of this code, which I've also included. Any help is appreciated, thanks.
Setup for the following functions:
All variables are CUDA variables
lnA, Q, n, R = dynamics.lnA, dynamics.E, dynamics.n, dynamics.R
dt =Δt(dynamics, uₖ)
A_diag =@view A[1:(size(A, 1)+1):end]
I was unable to replicate this issue with a simplified version of this code, so I included my full implementation. Below is a simplified version of my code that works fine for both conditional map! implementations:
using CUDA
A =cu(ones(50))
B =cu(1:50)
C =cu(zeros(50, 100))
D =cu(zeros(50, 100))
C_diag =@view C[1:(size(C, 1)+1):end]
D_diag =@view D[1:(size(D, 1)+1):end]
map!((a, b) -> (b <25.0) * a, C_diag, A, B)
@show C_diag
map!((a, b) -> b >25.0?0: a, D_diag, A, B)
@show D_diag
Details on Julia:
Julia Version 1.11.4
Commit 8561cc3d68d (2025-03-10 11:36 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 32 × AMD Ryzen Threadripper PRO 5955WX 16-Cores
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 32 virtual cores)
I'd guess you're accidentally referencing a global CPU variable, leading to the GPU reading inaccessible memory. We currently don't spot those during compilation: JuliaGPU/GPUCompiler.jl#232
In any case, without a functioning reproducer there's not much we can do about this.
Why would using a ternary operator reference a global CPU variable but just a conditional statement does not? That's the only difference between the working and not-working lines of code, which is confusing to me.
When using map! with a conditional on a CuArray there is an error when using a ternary operator but not when multiplying by the result of the conditional on the most recent CUDA.jl version. There are also no issues using map! with these inputs without the conditional. Below are the three implementations of map! I've used. I wasn't able to replicate this issue on a simplified version of this code, which I've also included. Any help is appreciated, thanks.
Setup for the following functions:
All variables are CUDA variables
map! without conditional (no errors):
map! with conditional and ternary operator:
Error: CuError(CUDA.cudaError_enum(0x000002bc))
Error: illegal memory access was encountered (code 700, ERROR_ILLEGAL_ADDRESS)
map! multiplying by conditional (no errors):
I was unable to replicate this issue with a simplified version of this code, so I included my full implementation. Below is a simplified version of my code that works fine for both conditional map! implementations:
Details on Julia:
Details on CUDA:
The text was updated successfully, but these errors were encountered: