Giter VIP home page Giter VIP logo

Comments (6)

maleadt avatar maleadt commented on May 25, 2024

Yeah, this is currently expected, due to Metal.jl not supporting exceptions yet. You can work around this by doing a non-throwing conversion, e.g. trunc(Int, x) or x % Int.

from metal.jl.

nicolamos avatar nicolamos commented on May 25, 2024

Thank you for the suggestion!

from metal.jl.

nicolamos avatar nicolamos commented on May 25, 2024

Sorry, but I'm getting the same error.

  • x % Int is not defined when x <: AbstractFloat;
  • trunc(Int, x) does throw as well;
  • unsafe_trunc(Int, x) can not be ported to the GPU, I guess;
  • MT.trunc_fast does not accept an output type argument.

The error is the following:

ERROR: InvalidIRError: compiling kernel #55#56(Metal.MtlDeviceVector{Float32, 1}) resulted in invalid LLVM IR
Reason: unsupported call to an unknown function (call to gpu_malloc)
Stacktrace:
 [1] malloc
   @ ~/.julia/packages/GPUCompiler/hi5Wg/src/runtime.jl:89
 [2] macro expansion
   @ ~/.julia/packages/GPUCompiler/hi5Wg/src/runtime.jl:184
 [3] macro expansion
   @ ./none:0
 [4] box
   @ ./none:0
 [5] box_float32
   @ ~/.julia/packages/GPUCompiler/hi5Wg/src/runtime.jl:213
 [6] Int64
   @ ./float.jl:788
 [7] convert
   @ ./number.jl:7
 [8] #55
   @ ./REPL[32]:1
Hint: catch this exception as `err` and call `code_typed(err; interactive = true)` to introspect the erronous code with Cthulhu.jl
Stacktrace:
  [1] check_ir(job::GPUCompiler.CompilerJob{GPUCompiler.MetalCompilerTarget, Metal.MetalCompilerParams, GPUCompiler.FunctionSpec{var"#55#56", Tuple{Metal.MtlDeviceVector{Float32, 1}}}}, args::LLVM.Module)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/hi5Wg/src/validation.jl:141
  [2] macro expansion
    @ ~/.julia/packages/GPUCompiler/hi5Wg/src/driver.jl:418 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/TimerOutputs/LHjFw/src/TimerOutput.jl:253 [inlined]
  [4] macro expansion
    @ ~/.julia/packages/GPUCompiler/hi5Wg/src/driver.jl:416 [inlined]
  [5] emit_asm(job::GPUCompiler.CompilerJob, ir::LLVM.Module; strip::Bool, validate::Bool, format::LLVM.API.LLVMCodeGenFileType)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/hi5Wg/src/utils.jl:68
  [6] mtlfunction_compile(job::GPUCompiler.CompilerJob, ctx::LLVM.Context)
    @ Metal ~/.julia/packages/Metal/pfCxO/src/compiler/execution.jl:168
  [7] #32
    @ ~/.julia/packages/Metal/pfCxO/src/compiler/execution.jl:161 [inlined]
  [8] JuliaContext(f::Metal.var"#32#33"{GPUCompiler.CompilerJob{GPUCompiler.MetalCompilerTarget, Metal.MetalCompilerParams, GPUCompiler.FunctionSpec{var"#55#56", Tuple{Metal.MtlDeviceVector{Float32, 1}}}}})
    @ GPUCompiler ~/.julia/packages/GPUCompiler/hi5Wg/src/driver.jl:76
  [9] mtlfunction_compile(job::GPUCompiler.CompilerJob)
    @ Metal ~/.julia/packages/Metal/pfCxO/src/compiler/execution.jl:160
 [10] cached_compilation(cache::Dict{UInt64, Any}, job::GPUCompiler.CompilerJob, compiler::typeof(Metal.mtlfunction_compile), linker::typeof(Metal.mtlfunction_link))
    @ GPUCompiler ~/.julia/packages/GPUCompiler/hi5Wg/src/cache.jl:90
 [11] mtlfunction(f::var"#55#56", tt::Type{Tuple{Metal.MtlDeviceVector{Float32, 1}}}; name::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Metal ~/.julia/packages/Metal/pfCxO/src/compiler/execution.jl:148
 [12] mtlfunction(f::var"#55#56", tt::Type{Tuple{Metal.MtlDeviceVector{Float32, 1}}})
    @ Metal ~/.julia/packages/Metal/pfCxO/src/compiler/execution.jl:141
 [13] macro expansion
    @ ~/.julia/packages/Metal/pfCxO/src/compiler/execution.jl:64 [inlined]
 [14] top-level scope
    @ ~/.julia/packages/GPUCompiler/hi5Wg/src/reflection.jl:201

from metal.jl.

maleadt avatar maleadt commented on May 25, 2024

unsafe_trunc(Int, x) can not be ported to the GPU, I guess;

Sorry, that's the one I meant, not plain trunc. Why does that not work for you on the GPU? k = unsafe_trunc(Int, x) does the job here.

from metal.jl.

nicolamos avatar nicolamos commented on May 25, 2024

Yes sorry, it works. I don’t know what was the issue… maybe I forgot the Int argument somewhere.

I also have another issue. I don’t really understand how can I use a function from another package. If I define the function in the same module (Main in this case), it works; but if import it from another package Metal complains that it is not defined.

from metal.jl.

maleadt avatar maleadt commented on May 25, 2024

I also have another issue. I don’t really understand how can I use a function from another package. If I define the function in the same module (Main in this case), it works; but if import it from another package Metal complains that it is not defined.

That obviously should work fine. The bug tracker is not really suited for such queries though, but you can open a thread on Discourse with some actual code to demonstrate the issue.

from metal.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.