Closed ehsantn closed 7 years ago
The accesses should be getindex
, because we can't be sure sample[i]
is safe. We don't automatically convert getindex
to unsafe_arrayref
, since we don't infer the range of indices. The array size equivalence is only used for the purpose of fusion. The same is true for cartesianarray
.
That being said, we are currently translating getindex
directly to ARRAYELEM
in CGen, the same as unsafe_arrayref
. So in the end it doesn't matter. I personally think this is sloppy since original J2C did it the right way, but on the other hand, one can argue that @acc
should assume all indexing are inbound.
I don't know much about the read/write sets. Maybe @DrTodd13 can take a look here.
ParallelIR RWS callback wasn't converting getindex so that it looked like an arrayref to RWS. I have added this and had to change RWS itself to process the callback first rather than a last ditch effort to account for this case where a comprehensible call needs to be transformed to a different call in RWS to get the right effect. This should fix the RWS issue I hope.
However, with this particular example, I see the following. Anybody else can confirm?
ERROR: LoadError: UndefVarError: ret not defined in score2() at /home/taanders/.julia/v0.5/CompilerTools/src/OptFramework.jl:598 in include_from_node1(::String) at ./loading.jl:488 in process_options(::Base.JLOptions) at ./client.jl:262 in _start() at ./client.jl:318 while loading /tmp/t1.jl, in expression starting on line 20
exps
needs a type. Can we have a meaningful error thrown when a type for an escaping variable is necessary?
Indeed. Adding a type to exps outside the @par fixes the problem. I think we should close this issue and open another one.
The RWS issue is resolved (I just double-checked).
Parallel array accesses in
@par
(cartesianmapreduce
) are translated togetindex()
but they should beunsafe_arrayref()
. Also, they are not in read/write set of parfors.Comprehensions (
cartesianarray
) has the correct behavior.