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

Muladd fallback #21

Closed
ChrisRackauckas opened this issue Jun 5, 2017 · 4 comments
Closed

Muladd fallback #21

ChrisRackauckas opened this issue Jun 5, 2017 · 4 comments

Comments

@ChrisRackauckas
Copy link
Member

u0 = GPUArray(rand(Float32, 32, 32))
k1 = similar(u0)
uprev = similar(u0)
muladd.(2,k1,uprev)
MethodError: no method matching clintrinsic(::Tuple{Expr,DataType})
Closest candidates are:
  clintrinsic(!Matched::Base.#getindex, !Matched::Type{Tuple{Tuple{Vararg{T,N}},I<:Integer}}) where {N, T, I<:Integer} at C:\Users\Chris\.julia\v0.6\Transpiler\src\clike/opencl\intrinsics.jl:172
  clintrinsic(!Matched::Base.#getindex, !Matched::Type{Tuple{T,I<:Union{Int32, Int64, UInt64}}}) where {T, I<:Union{Int32, Int64, UInt64}} at C:\Users\Chris\.julia\v0.6\Transpiler\src\clike/opencl\intrinsics.jl:178
  clintrinsic(!Matched::Base.#setindex!, !Matched::Type{Tuple{T<:Union{Transpiler.CLTranspiler.CLIntrinsics.CLArray, Transpiler.CLTranspiler.CLIntrinsics.LocalMemory},Val,I<:Integer}}) where {T<:Union{Transpiler.CLTranspiler.CLIntrinsics.CLArray, Transpiler.CLTranspiler.CLIntrinsics.LocalMemory}, Val, I<:Integer} at C:\Users\Chris\.julia\v0.6\Transpiler\src\clike/opencl\intrinsics.jl:183
  ...
isintrinsic(::Sugar.LazyMethod{:CL}) at intrinsics.jl:157
_dependencies!(::DataStructures.OrderedSet{Sugar.LazyMethod}, ::Sugar.LazyMethod{:CL}) at methods.jl:330
_dependencies!(::Sugar.LazyMethod{:CL}, ::Sugar.LazyMethod{:CL}) at methods.jl:323
_dependencies!(::DataStructures.OrderedSet{Sugar.LazyMethod}, ::Sugar.LazyMethod{:CL}) at methods.jl:331
_dependencies!(::Sugar.LazyMethod{:CL}, ::Sugar.LazyMethod{:CL}) at methods.jl:323
_dependencies!(::DataStructures.OrderedSet{Sugar.LazyMethod}, ::Sugar.LazyMethod{:CL}) at methods.jl:331
_dependencies!(::Sugar.LazyMethod{:CL}, ::Sugar.LazyMethod{:CL}) at methods.jl:323
_dependencies!(::DataStructures.OrderedSet{Sugar.LazyMethod}, ::Sugar.LazyMethod{:CL}) at methods.jl:331
dependencies!(::Sugar.LazyMethod{:CL}, ::Bool) at methods.jl:310
(::Transpiler.CLTranspiler.##27#28{Tuple{GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext},##13#14,Tuple{Int32,Int32},GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext},GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext}},GPUArrays.CLBackend.#broadcast_kernel,OpenCL.cl.CmdQueue,OpenCL.cl.Context,NTuple{5,DataType}})() at compilation.jl:84
get!(::Transpiler.CLTranspiler.##27#28{Tuple{GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext},##13#14,Tuple{Int32,Int32},GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext},GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext}},GPUArrays.CLBackend.#broadcast_kernel,OpenCL.cl.CmdQueue,OpenCL.cl.Context,NTuple{5,DataType}}, ::Dict{Any,Transpiler.CLTranspiler.CLFunction}, ::Tuple{GPUArrays.CLBackend.#broadcast_kernel,NTuple{5,DataType}}) at dict.jl:449
Transpiler.CLTranspiler.CLFunction(::Function, ::Tuple{GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext},##13#14,Tuple{Int32,Int32},GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext},GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext}}, ::OpenCL.cl.CmdQueue) at compilation.jl:79
acc_broadcast!(::##13#14, ::GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext}, ::Tuple{GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext},GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext}}) at opencl.jl:168
broadcast(::Function, ::GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext}, ::GPUArrays.GPUArray{Float32,2,OpenCL.cl.Buffer{Float32},GPUArrays.CLBackend.CLContext}) at abstractarray.jl:196
include_string(::String, ::String) at loading.jl:515
eval(::Module, ::Any) at boot.jl:235
(::Atom.##61#64)() at eval.jl:102
withpath(::Atom.##61#64, ::Void) at utils.jl:30
withpath(::Function, ::Void) at eval.jl:38
macro expansion at eval.jl:101 [inlined]
(::Atom.##60#63{Dict{String,Any}})() at task.jl:80

Would a simple fallback would be fine?

uprev .+ 2.*k1

That works. If it can FMA, that's better.

@SimonDanisch
Copy link
Member

I think I should just add fma as an intrinsic... Allthough when I look at the implementation of muladd, it ultimately relies on float_muladd, which will make it hard to transpile!
We could make those equal to fma in the transpiler

@ChrisRackauckas
Copy link
Member Author

We could make those equal to fma in the transpiler

That's probably a good idea. muladd makes sense for pure-Julia codes because of potential CPU limitations, but if you're going to the GPU or other accelerators, 99.999% of the time you should be using FMA.

SimonDanisch added a commit that referenced this issue Jun 6, 2017
SimonDanisch added a commit to SimonDanisch/Transpiler.jl that referenced this issue Jun 6, 2017
@SimonDanisch
Copy link
Member

added this as part of my transpiler rewrite branch... Will try to merge it soon!

SimonDanisch added a commit that referenced this issue Jul 23, 2017
@SimonDanisch
Copy link
Member

Solved by #37

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