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

DArray macro fails on 1.5 #223

Closed
raminammour opened this issue Aug 13, 2020 · 6 comments
Closed

DArray macro fails on 1.5 #223

raminammour opened this issue Aug 13, 2020 · 6 comments

Comments

@raminammour
Copy link
Contributor

Hello,

on the official binary:

julia> using DistributedArrays
[ Info: Precompiling DistributedArrays [aaf54ef3-cdf8-58ed-94cc-d582ad619b94]

julia> @DArray [1 for i in 1:2]
ERROR: syntax: malformed expression
Stacktrace:
 [1] top-level scope at REPL[3]:1

julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl

Is this easy to fix? The error is not very helpful...

Cheers!

@bjarthur
Copy link

i can confirm. even on master. the example straight out of the docs fails too, with the same error message. @DArray [i+j for i = 1:5, j = 1:5]

@andreasnoack
Copy link
Member

I'm not sure what is going on here. If I print the final expression from the macro then I can eval that without problems but the macro fails. Let's ask @JeffBezanson if he knows what is going on here.

@raminammour
Copy link
Contributor Author

It is the assertion ::Tuple{Vararg{UnitRange{Int}}} that it does not seem to like.

This works:

@eval DistributedArrays macro mDArray(ex0::Expr)
           if ex0.head !== :comprehension
               throw(ArgumentError("invalid @DArray syntax"))
           end
           ex = ex0.args[1]
           if ex.head !== :generator
               throw(ArgumentError("invalid @DArray syntax"))
           end
           ex.args[1] = esc(ex.args[1])
           ndim = length(ex.args) - 1
           ranges = map(r->esc(r.args[2]), ex.args[2:end])
           for d = 1:ndim
               var = ex.args[d+1].args[1]
               ex.args[d+1] = :( $(esc(var)) = ($(ranges[d]))[I[$d]] )
           end
            
           return :( DArray((I)->($ex0),
tuple($(map(r->:(length($r)), ranges)...))) )
       end

DistributedArrays.@mDArray [1 for i in 1:2]
2-element DArray{Int64,1,Array{Int64,1}}:
 1
 1

Whether the assertion is really needed, or how to meta-program an assertion is beyond me at this point ;)

Cheers!

@raminammour
Copy link
Contributor Author

This appears to be a julia issue, filed.

raminammour added a commit to raminammour/DistributedArrays.jl that referenced this issue Aug 20, 2020
This should fix JuliaParallel#223, so maybe a a new version can be tagged waiting for an upstream fix if it is really a bug. I tried to preserve the assertion, let's see if any of the tests break.
@raminammour
Copy link
Contributor Author

Update: the issue was solved on the julia side, and should make it into 1.5.2, so feel free to close the issue and the related PR if you see fit. Unless you want a version that works for 1.5.0/1.5.1.

@raminammour
Copy link
Contributor Author

Since 1.5.2 was released, containing the fix on the Julia side, I am closing this issue and the workaround PR. Cheers!

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

Successfully merging a pull request may close this issue.

3 participants