Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to create array on Rusticl driver #255

Open
VarLad opened this issue Oct 9, 2024 · 6 comments
Open

Fails to create array on Rusticl driver #255

VarLad opened this issue Oct 9, 2024 · 6 comments

Comments

@VarLad
Copy link

VarLad commented Oct 9, 2024

Tried with AMD Vega8 GPU as well as RTX3050M
The command to run julia:

RUSTICL_ENABLE=zink julia

and to reproduce:

julia> using OpenCL

julia> OpenCL.versioninfo()
OpenCL.jl version 0.10.0

Toolchain:
 - Julia v1.11.0-rc4
 - OpenCL_jll v2024.5.8+1

Available platforms: 2
 - Clover
   OpenCL 1.1, Mesa 24.2.4
   · AMD Radeon Graphics (radeonsi, renoir, LLVM 19.1.0, DRM 3.59, 6.11.2-300.fc41.x86_64) (fp64)
 - rusticl
   OpenCL 3.0
   · zink Vulkan 1.3(NVIDIA GeForce RTX 3050 Laptop GPU (NVK GA107) (MESA_NVK)) (il)
   · zink Vulkan 1.3(AMD Radeon Graphics (RADV RENOIR) (MESA_RADV)) (il)

julia> OpenCL.cl.device!(OpenCL.cl.devices(OpenCL.cl.platform!("rusticl"))[1])
┌ Warning: No OpenCL driver JLLs were detected at the time of the first call into OpenCL.jl.
│ Only system drivers will be available.
└ @ OpenCL.cl ~/.julia/packages/OpenCL/VxZWM/lib/cl/api.jl:80
OpenCL.Device(zink Vulkan 1.3(NVIDIA GeForce RTX 3050 Laptop GPU (NVK GA107) (MESA_NVK)) on rusticl @0x00000000323d75b8)

julia> CLArray([1,2])
ERROR: CLError(code=-59, CL_INVALID_OPERATION)
Stacktrace:
  [1] throw_api_error(res::Int32)
    @ OpenCL.cl ~/.julia/packages/OpenCL/VxZWM/lib/cl/libopencl.jl:3
  [2] check
    @ ~/.julia/packages/OpenCL/VxZWM/lib/cl/libopencl.jl:14 [inlined]
  [3] clEnqueueSVMMemcpy
    @ ~/.julia/packages/OpenCL/VxZWM/lib/cl/api.jl:34 [inlined]
  [4] enqueue_svm_memcpy(dst::Ptr{Int64}, src::Ptr{Int64}, nbytes::Int64; blocking::Bool, wait_for::Vector{OpenCL.cl.Event})
    @ OpenCL.cl ~/.julia/packages/OpenCL/VxZWM/lib/cl/svm.jl:63
  [5] enqueue_svm_memcpy
    @ ~/.julia/packages/OpenCL/VxZWM/lib/cl/svm.jl:57 [inlined]
  [6] unsafe_copyto!(dst::CLArray{Int64, 1}, dst_off::Int64, src::Vector{Int64}, src_off::Int64, N::Int64; blocking::Bool)
    @ OpenCL ~/.julia/packages/OpenCL/VxZWM/src/array.jl:226
  [7] unsafe_copyto!
    @ ~/.julia/packages/OpenCL/VxZWM/src/array.jl:222 [inlined]
  [8] copyto!
    @ ~/.julia/packages/OpenCL/VxZWM/src/array.jl:175 [inlined]
  [9] copyto!
    @ ~/.julia/packages/OpenCL/VxZWM/src/array.jl:181 [inlined]
 [10] CLArray{Int64, 1}(hostarray::Vector{Int64}; kwargs::@Kwargs{})
    @ OpenCL ~/.julia/packages/OpenCL/VxZWM/src/array.jl:119
 [11] CLArray
    @ ~/.julia/packages/OpenCL/VxZWM/src/array.jl:117 [inlined]
 [12] CLArray(A::Vector{Int64})
    @ OpenCL ~/.julia/packages/OpenCL/VxZWM/src/array.jl:123
 [13] top-level scope
    @ REPL[3]:1
 [14] top-level scope
    @ ~/.julia/packages/OpenCL/VxZWM/lib/cl/api.jl:113
@maleadt
Copy link
Member

maleadt commented Oct 9, 2024

What does cl.svm_capabilities(cl.device()) return?

@VarLad
Copy link
Author

VarLad commented Oct 9, 2024

For both my NVIDIA and AMD GPUs (with Zink), that is, running with:

RUSTICL_ENABLE=zink julia

I get: (coarse_grain_buffer = false, fine_grain_buffer = false, fine_grain_system = false)

I'm guessing that I'll need to wait for proper SVM support in RustiCL to start using OpenCL.jl.


That being said, this is different for CPU.
For CPU (running with RUSTICL_ENABLE=llvmpipe julia)
I get (coarse_grain_buffer = true, fine_grain_buffer = true, fine_grain_system = true)
But when I try creating an array, I get a slightly different error:

julia> CLArray([1,2])
2-element CLArray{Int64, 1}:
Error showing value of type CLArray{Int64, 1}:
ERROR: CLError(code=-59, CL_INVALID_OPERATION)
Stacktrace:
  [1] throw_api_error(res::Int32)
    @ OpenCL.cl ~/.julia/packages/OpenCL/VxZWM/lib/cl/libopencl.jl:3
  [2] check
    @ ~/.julia/packages/OpenCL/VxZWM/lib/cl/libopencl.jl:14 [inlined]
  [3] clEnqueueSVMMemcpy
    @ ~/.julia/packages/OpenCL/VxZWM/lib/cl/api.jl:34 [inlined]
  [4] enqueue_svm_memcpy(dst::Ptr{Int64}, src::Ptr{Int64}, nbytes::Int64; blocking::Bool, wait_for::Vector{OpenCL.cl.Event})
    @ OpenCL.cl ~/.julia/packages/OpenCL/VxZWM/lib/cl/svm.jl:63
  [5] enqueue_svm_memcpy
    @ ~/.julia/packages/OpenCL/VxZWM/lib/cl/svm.jl:57 [inlined]
  [6] unsafe_copyto!(dst::Vector{Int64}, dst_off::Int64, src::CLArray{Int64, 1}, src_off::Int64, N::Int64; blocking::Bool)
    @ OpenCL ~/.julia/packages/OpenCL/VxZWM/src/array.jl:226
  [7] unsafe_copyto!
    @ ~/.julia/packages/OpenCL/VxZWM/src/array.jl:222 [inlined]
  [8] copyto!
    @ ~/.julia/packages/OpenCL/VxZWM/src/array.jl:191 [inlined]
  [9] copyto!
    @ ~/.julia/packages/OpenCL/VxZWM/src/array.jl:202 [inlined]
 [10] Array
    @ ~/.julia/packages/OpenCL/VxZWM/src/array.jl:127 [inlined]
 [11] Array
    @ ./boot.jl:605 [inlined]
 [12] convert
    @ ./array.jl:607 [inlined]
 [13] adapt_storage
    @ ~/.julia/packages/GPUArrays/qt4ax/src/host/abstractarray.jl:115 [inlined]
 [14] adapt_structure
    @ ~/.julia/packages/Adapt/7T9au/src/Adapt.jl:57 [inlined]
 [15] adapt
    @ ~/.julia/packages/Adapt/7T9au/src/Adapt.jl:40 [inlined]
 [16] print_array
    @ ~/.julia/packages/GPUArrays/qt4ax/src/host/abstractarray.jl:118 [inlined]
 [17] show(io::IOContext{Base.TTY}, ::MIME{Symbol("text/plain")}, X::CLArray{Int64, 1})
    @ Base ./arrayshow.jl:399
 [18] (::REPL.var"#68#69"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:348
 [19] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:646
 [20] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:334
 [21] display
    @ ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:353 [inlined]
 [22] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:340
 [23] #invokelatest#2
    @ ./essentials.jl:1054 [inlined]
 [24] invokelatest
    @ ./essentials.jl:1051 [inlined]
 [25] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:390
 [26] (::REPL.var"#70#71"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:359
 [27] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:646
 [28] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:357
 [29] (::REPL.var"#do_respond#96"{Bool, Bool, REPL.var"#112#130"{}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:988
 [30] #invokelatest#2
    @ ./essentials.jl:1054 [inlined]
 [31] invokelatest
    @ ./essentials.jl:1051 [inlined]
 [32] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/LineEdit.jl:2749
 [33] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:1456
 [34] (::REPL.var"#75#81"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ~/.julia/juliaup/julia-1.11.0-rc4+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/REPL.jl:461
Some type information was truncated. Use `show(err)` to see complete types.

@VarLad
Copy link
Author

VarLad commented Oct 9, 2024

Is the latter a display issue where its having trouble displaying the elements of type CLAarray on the REPL? 🤔

@maleadt
Copy link
Member

maleadt commented Oct 9, 2024

Is the latter a display issue where its having trouble displaying the elements of type CLAarray on the REPL? 🤔

Looks like it. Does manually copying back to an Array work?

I get: (coarse_grain_buffer = false, fine_grain_buffer = false, fine_grain_system = false)

Guess I didn't add the check; the CLArray constructor should probably detect this and error out.

@VarLad
Copy link
Author

VarLad commented Oct 9, 2024

Apparently this works (for CPU):

julia> x = CLArray([1,2]);

julia> y = CLArray([2,3]);

julia> v = x + y;

julia> u = x .* y;

julia> typeof(u)
CLArray{Int64, 1}

@maleadt
Copy link
Member

maleadt commented Oct 15, 2024

That's interesting. I wonder if it's something to do with the cross-queue usage of the allocations (the REPL display code runs on another task, which uses another queue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants