Closed ranjanan closed 8 years ago
It looks like the @time
is causing the problem. If I remove it, test()
works.
Yes, that is what I was going to suggest. You can time the call to the function rather than putting @time inside the optimized function. We will take a look at what @time is doing inside the function though. It may be something we could easily support but the error did look like the C code generation part and there are somethings there that we will probably never support. The native threading path will probably handle such cases when it is ready with the next official release of Julia that has native threading.
----- Original Message -----
From: "Ranjan Anantharaman" notifications@github.com To: "IntelLabs/ParallelAccelerator.jl" ParallelAccelerator.jl@noreply.github.com Sent: Thursday, December 3, 2015 7:25:12 AM Subject: Re: [ParallelAccelerator.jl] Simple test breaks with error (#23)
It looks like the @time is causing the problem.
— Reply to this email directly or view it on GitHub .
I see. I also got a different error while using arrays of arrays:
@acc function test2()
a = Array(Vector{Int}, 10)
for i = 1:size(a,1)
a[i] = [1,2,3]
end
a .* 5
end
The message is:
ERROR: AssertionError: CGen: variables cannot have Any (unresolved) type
in from_lambda at /Users/ranjan/.julia/v0.4/ParallelAccelerator/src/cgen.jl:408
in from_expr at /Users/ranjan/.julia/v0.4/ParallelAccelerator/src/cgen.jl:1942
in from_root at /Users/ranjan/.julia/v0.4/ParallelAccelerator/src/cgen.jl:2296
in from_root at /Users/ranjan/.julia/v0.4/ParallelAccelerator/src/cgen.jl:2263
in toCGen at /Users/ranjan/.julia/v0.4/ParallelAccelerator/src/driver.jl:172
in processFuncCall at /Users/ranjan/.julia/v0.4/CompilerTools/src/OptFramework.jl:338
in test2 at /Users/ranjan/.julia/v0.4/CompilerTools/src/OptFramework.jl:400
Sorry for the delay. I was able to look into this today. Both of your examples come down to "we don't support that in CGen." At the moment we have only the C code generation path and that path comes with restrictions. In that path, we don't support printing (or IO in general) and everything has to have a known type (in other words, we don't support Any).
In your last example, in standard Julia, "a .* 5" results in something with type Array{Any,1}. It isn't Array{Vector{Int},1} * Int = Array{Vector{Int}, 1} like you might expect.
map(y -> y .* 5, a) produces the right type but we don't parallelize that. [x .* 5 for x in a] also produces Array{Any,1} but in this case ParallelAccelerator augments Julia's type inference and corrects this to the correct Array{Vector{Int},1}. So, I suggest trying the comprehension syntax.
It would be nice if we did a better job of indicating where the Any type is coming from. It manifests currently on some internal variable we introduce that isn't in the original source so it would be quite meaningless to the user. We'd probably have to do it with line numbers but we currently just throw line numbers away.
If you are satisfied then please close the ticket. Thanks.
Thanks Todd.
I wanted to conduct a simple test:
On all three declarations of
a
I get the following error message:I noticed that doing the same thing using anonymous functions work though.
However, suppose I run test() and get the error, and then I go back to the anonymous function:
I get the following error:
versioninfo:
Am i doing something incorrectly?