Comments (6)
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.
Thank you for the suggestion!
from metal.jl.
Sorry, but I'm getting the same error.
x % Int
is not defined whenx <: 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.
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.
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.
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)
- tag new version HOT 1
- Panic during profiling tests on 14.4 beta HOT 5
- M3 backend cannot handle atomics with complicated pointer conversions HOT 3
- Int128 does not compile HOT 4
- Two suspicious `mtl`-related behaviours HOT 6
- Add Support for BFloat16 HOT 3
- LU factorization: add allowsingular keyword argument HOT 1
- Autorelease changes lead to use after free with errors
- Shader validator error with linear broadcast kernel HOT 3
- Support for Paravirtualized Graphics for Github Actions CI HOT 4
- Reductions don't work on Shared Arrays HOT 1
- Port the opportunistic synchronization from CUDA.jl HOT 1
- Register v1.1.0 HOT 4
- Tests sporadically timing out on 1.11 HOT 9
- ReshapedArray indexing broken because of Int128 operation HOT 11
- KernelAbstractions copyto! typo
- Segmentation Faults HOT 11
- Port `accmulate!` and `findall` from CUDA.jl HOT 4
- `MTL.append_copy!` silently ignores Metal documentation restriction HOT 1
- Tests failing with `GPUCompiler` v0.26.5 and `LLVM` v7.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from metal.jl.