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

ERROR: InvalidIRError: compiling kernel broadcast_kernel; Reason unsupported dynamic function invocation #95

Closed
chriselrod opened this issue Aug 8, 2021 · 3 comments

Comments

@chriselrod
Copy link

Reason: unsupported dynamic function invocation (call to emit_printf(::Val{fmt}, argspec...) where fmt in oneAPI at /home/chriselrod/.julia/packages/oneAPI/bEvNc/src/device/opencl/printf.jl:27)

julia> using oneAPI

julia> a = oneArray(rand(2,2))
2×2 oneArray{Float64, 2}:
 0.94417   0.947858
 0.463884  0.31073

julia> a .+ 1
WARNING: both LLVM and ExprTools export "parameters"; uses of it in module oneAPI must be qualified
ERROR: InvalidIRError: compiling kernel broadcast_kernel(oneAPI.oneKernelContext, oneDeviceMatrix{Float64, 1}, Base.Broadcast.Broadcasted{Nothing, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, typeof(+), Tuple{Base.Broadcast.Extruded{oneDeviceMatrix{Float64, 1}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}, Int64}}, Int64) resulted in invalid LLVM IR
Reason: unsupported dynamic function invocation (call to emit_printf(::Val{fmt}, argspec...) where fmt in oneAPI at /home/chriselrod/.julia/packages/oneAPI/bEvNc/src/device/opencl/printf.jl:27)
Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/oneAPI/bEvNc/src/device/opencl/printf.jl:129
  [2] _print
    @ ~/.julia/packages/oneAPI/bEvNc/src/device/opencl/printf.jl:91
  [3] macro expansion
    @ ~/.julia/packages/oneAPI/bEvNc/src/device/opencl/printf.jl:178
  [4] throw_boundserror
    @ ~/.julia/packages/oneAPI/bEvNc/src/device/quirks.jl:3
  [5] getindex
    @ range.jl:702
  [6] _broadcast_getindex_evalf
    @ broadcast.jl:648
  [7] _broadcast_getindex
    @ broadcast.jl:621
  [8] #19
    @ broadcast.jl:1098
  [9] ntuple
    @ ntuple.jl:49
 [10] copy
    @ broadcast.jl:1098
 [11] materialize
    @ broadcast.jl:883
 [12] getindex
    @ multidimensional.jl:353
 [13] _getindex
    @ abstractarray.jl:1209
 [14] getindex
    @ abstractarray.jl:1170
 [15] macro expansion
    @ ~/.julia/packages/GPUArrays/8dzSJ/src/device/indexing.jl:81
 [16] broadcast_kernel
    @ ~/.julia/packages/GPUArrays/8dzSJ/src/host/broadcast.jl:58
Stacktrace:
  [1] check_ir(job::GPUCompiler.CompilerJob{GPUCompiler.SPIRVCompilerTarget, oneAPI.oneAPICompilerParams, GPUCompiler.FunctionSpec{GPUArrays.var"#broadcast_kernel#16", Tuple{oneAPI.oneKernelContext, oneDeviceMatrix{Float64, 1}, Base.Broadcast.Broadcasted{Nothing, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, typeof(+), Tuple{Base.Broadcast.Extruded{oneDeviceMatrix{Float64, 1}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}, Int64}}, Int64}}}, args::LLVM.Module)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/QjFdA/src/validation.jl:111
  [2] macro expansion
    @ ~/.julia/packages/GPUCompiler/QjFdA/src/driver.jl:319 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/TimerOutputs/ZQ0rt/src/TimerOutput.jl:236 [inlined]
  [4] macro expansion
    @ ~/.julia/packages/GPUCompiler/QjFdA/src/driver.jl:317 [inlined]
  [5] emit_asm(job::GPUCompiler.CompilerJob, ir::LLVM.Module; strip::Bool, validate::Bool, format::LLVM.API.LLVMCodeGenFileType)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/QjFdA/src/utils.jl:62
  [6] zefunction_compile(job::GPUCompiler.CompilerJob)
    @ oneAPI ~/.julia/packages/oneAPI/bEvNc/src/compiler/execution.jl:131
  [7] cached_compilation(cache::Dict{UInt64, Any}, job::GPUCompiler.CompilerJob, compiler::typeof(oneAPI.zefunction_compile), linker::typeof(oneAPI.zefunction_link))
    @ GPUCompiler ~/.julia/packages/GPUCompiler/QjFdA/src/cache.jl:89
  [8] zefunction(f::Function, tt::Type; name::Nothing, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ oneAPI ~/.julia/packages/oneAPI/bEvNc/src/compiler/execution.jl:122
  [9] macro expansion
    @ ~/.julia/packages/oneAPI/bEvNc/src/compiler/execution.jl:34 [inlined]
 [10] #gpu_call#77
    @ ~/.julia/packages/oneAPI/bEvNc/src/gpuarrays.jl:29 [inlined]
 [11] gpu_call(::GPUArrays.var"#broadcast_kernel#16", ::oneArray{Float64, 2}, ::Base.Broadcast.Broadcasted{Nothing, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, typeof(+), Tuple{Base.Broadcast.Extruded{oneArray{Float64, 2}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}, Int64}}, ::Int64; target::oneArray{Float64, 2}, total_threads::Nothing, threads::Int64, blocks::Int64, name::Nothing)
    @ GPUArrays ~/.julia/packages/GPUArrays/8dzSJ/src/device/execution.jl:67
 [12] copyto!
    @ ~/.julia/packages/GPUArrays/8dzSJ/src/host/broadcast.jl:65 [inlined]
 [13] copyto!
    @ ./broadcast.jl:936 [inlined]
 [14] copy
    @ ~/.julia/packages/GPUArrays/8dzSJ/src/host/broadcast.jl:47 [inlined]
 [15] materialize(bc::Base.Broadcast.Broadcasted{oneAPI.oneArrayStyle{2}, Nothing, typeof(+), Tuple{oneArray{Float64, 2}, Int64}})
    @ Base.Broadcast ./broadcast.jl:883
 [16] top-level scope
    @ REPL[3]:1

julia> versioninfo()
Julia Version 1.6.3-pre.1
Commit 7c45ff0e94* (2021-07-16 20:20 UTC)
Platform Info:
  OS: Linux (x86_64-redhat-linux)
  CPU: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, tigerlake)
Environment:
  JULIA_NUM_THREADS = 8

julia> using oneAPI.oneL0

julia> drv = first(drivers());

julia> dev = first(devices(drv))
ZeDevice(GPU, vendor 0x8086, device 0x9a49): Intel(R) Iris(R) Xe Graphics [0x9a49]

julia> compute_properties(dev)
(maxTotalGroupSize = 512, maxGroupSizeX = 512, maxGroupSizeY = 512, maxGroupSizeZ = 512, maxGroupCountX = 4294967295, maxGroupCountY = 4294967295, maxGroupCountZ = 4294967295, maxSharedLocalMemory = 65536, subGroupSizes = (8, 16, 32))

julia> ctx = ZeContext(drv);

julia> queue = ZeCommandQueue(ctx, dev);

julia> execute!(queue) do list
         append_barrier!(list)
       end

julia> function kernel()
         barrier()
         return
       end
kernel (generic function with 1 method)

julia> @oneapi items=1 kernel()

julia> @device_code_llvm @oneapi items=1 kernel()
; CompilerJob of kernel kernel() for GPUCompiler.SPIRVCompilerTarget
define spir_kernel void @_Z17julia_kernel_4443() local_unnamed_addr {
entry:
;  @ REPL[18]:2 within `kernel'
; ┌ @ /home/chriselrod/.julia/packages/oneAPI/bEvNc/src/device/opencl/synchronization.jl:9 within `barrier' @ /home/chriselrod/.julia/packages/oneAPI/bEvNc/src/device/opencl/synchronization.jl:9
; │┌ @ /home/chriselrod/.julia/packages/oneAPI/bEvNc/src/device/utils.jl:47 within `macro expansion'
    call void @_Z7barrierj(i32 0)
    ret void
; └└
}
@maleadt
Copy link
Member

maleadt commented Aug 9, 2021

This is JuliaGPU/GPUCompiler.jl#214, due to that ambiguity the implementation of printf doesn't infer (but wants to throw a run-time error).

Shouldn't happen on the master branch, and I'll be tagging a release soon!

@maleadt maleadt closed this as completed Aug 9, 2021
@chriselrod
Copy link
Author

As an update:

julia> a = oneArray(rand(Float32, 2,2))
2×2 oneArray{Float32, 2}:
 0.787535  0.849568
 0.418914  0.621363

julia> a .+ 1f0
2×2 oneArray{Float32, 2}:
 1.78754  1.84957
 1.41891  1.62136

julia> a = oneArray(rand(2,2))
2×2 oneArray{Float64, 2}:
 0.130347  0.95715
 0.450905  0.869891

julia> a .+ 1
┌ Error: Module compilation failed:
│
│ error: double type is not supported on this platform

Perhaps worth making the example use Float32 by default?
Iris(R) Xe Graphics are common in laptop iGPUs over the past year.

@maleadt
Copy link
Member

maleadt commented Aug 13, 2021

Yeah that makes sense, I've updated the README.
(My IGP did have Float64 support, is why I didn't run into it earlier.)

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