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

pmap error with type-parametric closures #26979

Closed
EthanAnderes opened this issue May 4, 2018 · 0 comments
Closed

pmap error with type-parametric closures #26979

EthanAnderes opened this issue May 4, 2018 · 0 comments
Assignees
Labels
domain:parallelism Parallel or distributed computation kind:bug Indicates an unexpected problem or unintended behavior

Comments

@EthanAnderes
Copy link

I've been using closures to handle a complicated distributed project and ran into an error that seems like it could be a bug.

Here is a simple example which gives an error on both v0.6 and v0.7. Note: the parametric type T is what is causing the problem.

addprocs(2)

function gen_f(a::T) where T 
    f = x -> T(x)
    return f
end
f = gen_f(1f0)

map(f,  [1, 2]) # <--- works fine
pmap(f, [1, 2]) # <--- deserialization error

As was noted on discourse ref there is a workaround but results in a performance hit.

function gen_g(a)
    T = typeof(a)
    g = x -> T(x)
    return g
end
g = gen_g(1f0)

map(g,  [1, 2]) # <--- works fine
pmap(g, [1, 2]) # <--- works fine
julia> using BenchmarkTools

julia> @benchmark map($f,  $([1, 2]))
BenchmarkTools.Trial: 
  memory estimate:  112 bytes
  allocs estimate:  2
  --------------
  minimum time:     490.784 ns (0.00% GC)
  median time:      554.794 ns (0.00% GC)
  mean time:        574.588 ns (1.89% GC)
  maximum time:     13.989 μs (92.32% GC)
  --------------
  samples:          10000
  evals/sample:     194

julia> @benchmark map($g,  $([1, 2]))
BenchmarkTools.Trial: 
  memory estimate:  176 bytes
  allocs estimate:  5
  --------------
  minimum time:     1.392 μs (0.00% GC)
  median time:      1.575 μs (0.00% GC)
  mean time:        1.583 μs (0.00% GC)
  maximum time:     7.873 μs (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     10

@JeffBezanson JeffBezanson self-assigned this May 4, 2018
@JeffBezanson JeffBezanson added the domain:parallelism Parallel or distributed computation label May 4, 2018
@JeffBezanson JeffBezanson added the kind:bug Indicates an unexpected problem or unintended behavior label May 4, 2018
ScottPJones pushed a commit to ScottPJones/julia that referenced this issue May 5, 2018
@Keno Keno closed this as completed in 901b240 May 5, 2018
ararslan pushed a commit that referenced this issue May 7, 2018
ararslan pushed a commit that referenced this issue May 8, 2018
ararslan pushed a commit that referenced this issue May 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:parallelism Parallel or distributed computation kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants