JuliaGPU / CLBLAS.jl

CLBLAS integration for Julia
Apache License 2.0
22 stars 14 forks source link

Unable to use Dgemm #12

Open nstiurca opened 8 years ago

nstiurca commented 8 years ago

I'm trying to use GEMM with double-precision floats, but that doesn't seem supported? I tried a straight-forward adaptation of the clblasSgemm_future.jl and clblasSgemmRandomBufferFuture.jl examples to use Float64/cl.cl_double, but I get the following errors.

$ julia clblasDgemm_future.jl
WARNING: float64(x::AbstractArray) is deprecated, use map(Float64,x) instead.
 in depwarn at deprecated.jl:73
 in float64 at deprecated.jl:50
 in include at ./boot.jl:261
 in include_from_node1 at ./loading.jl:304
 in process_options at ./client.jl:308
 in _start at ./client.jl:411
while loading /home/nstiurca/.julia/v0.4/CLBLAS/examples/clblasDgemm_future.jl, in expression starting on line 9
WARNING: float64(x::AbstractArray) is deprecated, use map(Float64,x) instead.
 in depwarn at deprecated.jl:73
 in float64 at deprecated.jl:50
 in include at ./boot.jl:261
 in include_from_node1 at ./loading.jl:304
 in process_options at ./client.jl:308
 in _start at ./client.jl:411
while loading /home/nstiurca/.julia/v0.4/CLBLAS/examples/clblasDgemm_future.jl, in expression starting on line 10
ERROR: LoadError: MethodError: `clblasDgemm` has no method matching clblasDgemm(::UInt32, ::UInt32, ::Float64, ::Array{Float64,2}, ::Array{Float64,2}, ::Float64, ::Array{Float64,2})
Closest candidates are:
  clblasDgemm(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Array{OpenCL.CmdQueue,1})
  clblasDgemm(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Array{OpenCL.CmdQueue,1}, !Matched::Union{Array{Ptr{Void},1},Void})
  clblasDgemm(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any)
 in include at ./boot.jl:261
 in include_from_node1 at ./loading.jl:304
 in process_options at ./client.jl:308
 in _start at ./client.jl:411
while loading /home/nstiurca/.julia/v0.4/CLBLAS/examples/clblasDgemm_future.jl, in expression starting on line 15

and

$ julia clblasDgemmRandomBufferFuture.jl
ERROR: LoadError: MethodError: `clblasDgemm` has no method matching clblasDgemm(::UInt32, ::UInt32, ::Float64, ::OpenCL.Buffer{Float64}, ::OpenCL.Buffer{Float64}, ::Float64, ::OpenCL.Buffer{Float64})
Closest candidates are:
  clblasDgemm(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Array{OpenCL.CmdQueue,1})
  clblasDgemm(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Array{OpenCL.CmdQueue,1}, !Matched::Union{Array{Ptr{Void},1},Void})
  clblasDgemm(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any)
 in include at ./boot.jl:261
 in include_from_node1 at ./loading.jl:304
 in process_options at ./client.jl:308
 in _start at ./client.jl:411
while loading /home/nstiurca/.julia/v0.4/CLBLAS/examples/clblasDgemmRandomBufferFuture.jl, in expression starting on line 26

I am using Linux Mint 17.2 (essentially Ubuntu 14.04), clBLAS v2.6, Julia v0.4, latest CLBLAS.jl master (currently 1555379).

nstiurca commented 8 years ago

Here is the code I used: https://gist.github.com/nstiurca/6b91103ad31a4d9b5c09

jakebolewski commented 8 years ago

@nstiurca can you try again now that #11 is merged?

dfdx commented 8 years ago

It's pretty possible that you will still get an error, because clblasSgemm uses a type trick, replacing enum parameter with UInt, and newer API controls argument types much more strictly.

Note, that I'm currently working on a high-level interface for CLBLAS.jl based on CLArrays. So if futures aren't essential for your work, you can just wait for a couple of days and get all "GEMM" functions out of the box.

nstiurca commented 8 years ago

Thank you guys. I haven't gotten my code working yet, but that is largely because I was working on a patch to address the issues with enum/UInt and the very strict new API. My approach is that if the C type is a specific thing like size_t, then the corresponding Julia function should accept any Number, and do the conversion as necessary when actually invoking ccall. That would allow passing in 0 instead of UInt(0), etc.

By the way, I think enums should map to Cint rather than UInt, which I think would be the correct signed-ness and bit-size.

And I look forward to the CLArray implementation.

nstiurca commented 8 years ago

See PR #13 for my aforementioned patch.