IntelLabs / ParallelAccelerator.jl

The ParallelAccelerator package, part of the High Performance Scripting project at Intel Labs
BSD 2-Clause "Simplified" License
294 stars 32 forks source link

`Diagonal` not supported? #128

Closed lkuper closed 7 years ago

lkuper commented 7 years ago

I tried fixing the following deprecation warning on 0.5:

WARNING: scale(A::AbstractMatrix,x::AbstractVector) is deprecated, use A * Diagonal(x) instead.
 in depwarn(::String, ::Symbol) at ./deprecated.jl:64
 in scale(::Array{Float64,2}, ::Array{Float64,1}) at ./deprecated.jl:50
 in ##normalizeW#282(::Array{Float64,2}, ::Int64) at /mnt/home/lkuper/.julia/v0.5/ParallelAccelerator/test/lib.jl:63
 in test7() at /mnt/home/lkuper/.julia/v0.5/ParallelAccelerator/test/lib.jl:111
 in include_from_node1(::String) at ./loading.jl:488 (repeats 2 times)
 in process_options(::Base.JLOptions) at ./client.jl:262
 in _start() at ./client.jl:318
while loading /mnt/home/lkuper/.julia/v0.5/ParallelAccelerator/test/lib.jl, in expression starting on line 130

but changing scale(W,s) to W * Diagonal(s) causes the following compiler error:

  Test threw an exception of type String
  Expression: APILibTest.test7()
  "Could not determine type for arg 1 to call .Base.#print_to_string#305 with name Base.nothing"
   in from_call(::Array{Any,1}, ::CompilerTools.LambdaHandling.LambdaVarInfo) at /home/lkuper/.julia/v0.5/ParallelAccelerator/src/cgen.jl:1737
   in from_expr(::Expr, ::CompilerTools.LambdaHandling.LambdaVarInfo) at /home/lkuper/.julia/v0.5/ParallelAccelerator/src/cgen.jl:2309
   in from_assignment(::Array{Any,1}, ::CompilerTools.LambdaHandling.LambdaVarInfo) at /home/lkuper/.julia/v0.5/ParallelAccelerator/src/cgen.jl:694
   in from_expr(::Expr, ::CompilerTools.LambdaHandling.LambdaVarInfo) at /home/lkuper/.julia/v0.5/ParallelAccelerator/src/cgen.jl:2299
   in from_exprs(::Array{Any,1}, ::CompilerTools.LambdaHandling.LambdaVarInfo) at /home/lkuper/.julia/v0.5/ParallelAccelerator/src/cgen.jl:588
   in from_expr(::Expr, ::CompilerTools.LambdaHandling.LambdaVarInfo) at /home/lkuper/.julia/v0.5/ParallelAccelerator/src/cgen.jl:2287
   in from_lambda(::CompilerTools.LambdaHandling.LambdaVarInfo, ::Expr) at /home/lkuper/.julia/v0.5/ParallelAccelerator/src/cgen.jl:570
   in from_root_nonentry(::LambdaInfo, ::String, ::Tuple{DataType,DataType,DataType}, ::Dict{DataType,Int64}) at /home/lkuper/.julia/v0.5/ParallelAccelerator/src/cgen.jl:2992
   in from_worklist() at /home/lkuper/.julia/v0.5/ParallelAccelerator/src/cgen.jl:3082
   in from_root_entry(::Tuple{CompilerTools.LambdaHandling.LambdaVarInfo,Expr}, ::String, ::Tuple{DataType,DataType}, ::Dict{DataType,Int64}) at /home/lkuper/.julia/v0.5/ParallelAccelerator/src/cgen.jl:2955
   in toCGen(::GlobalRef, ::Tuple{CompilerTools.LambdaHandling.LambdaVarInfo,Expr}, ::Tuple{DataType,DataType}) at /home/lkuper/.julia/v0.5/ParallelAccelerator/src/driver.jl:267
   in processFuncCall(::Any, ::Any, ::Any) at /home/lkuper/.julia/v0.5/CompilerTools/src/OptFramework.jl:463
   in normalizeW(::Array{Float64,2}, ::Int64) at /home/lkuper/.julia/v0.5/CompilerTools/src/OptFramework.jl:578
   in test7() at /mnt/home/lkuper/.julia/v0.5/ParallelAccelerator/test/lib.jl:109
   in include_from_node1(::String) at ./loading.jl:488 (repeats 2 times)
   in process_options(::Base.JLOptions) at ./client.jl:262
   in _start() at ./client.jl:318

Is this because we're not handling the Diagonal type correctly? It's a subtype of AbstractArray.

ninegua commented 7 years ago

You are right, currently only DenseArray is supported. Julia has many different Array types and does its own optimization in type-based method dispatching. CGen cannot deal with most of these data types.

lkuper commented 7 years ago

Is there a way to avoid the deprecation warning while also only using types we support?

ninegua commented 7 years ago

I'd say just disable this test. The test case was added due to an old ticket #35 . Since the function itself is being deprecated, I see no point to still keeping it in our test case.