2
votes

I'm porting a program which used to work in Julia 0.4 to Julia 0.5 and having trouble.

This is the program:

addprocs(3)
ref = @spawn factor(21883298135690819)
factors = fetch(ref)
@assert factors == Dict(234711901=>1,93234719=>1)

When running on Julia 0.5, I get the error

ERROR: On worker 2:
factor(21883298135690819,) has been moved to the package Primes.jl.
Run Pkg.add("Primes") to install Primes on Julia v0.5-

Fair enough. But even when I go into the interactive terminal, my code still won't work! Here is the transcript:

julia> Pkg.add("Primes")
INFO: Nothing to be done

julia> using Primes

julia> Primes.factor(21883298135690819)
Dict{Int64,Int64} with 2 entries:
  234711901 => 1
  93234719  => 1

julia> addprocs(3)
3-element Array{Int64,1}:
 2
 3
 4

julia> ref = @spawn factor(21883298135690819)
Future(2,1,5,Nullable{Any}())

julia> factors = fetch(ref)
ERROR: On worker 2:
factor(21883298135690819,) has been moved to the package Primes.jl.
Run Pkg.add("Primes") to install Primes on Julia v0.5-

Same problem!

I've read the documentation which seems to suggest that the using declaration makes the code available to all processes, but this is not the case.

What am I doing wrong?

1
put addprocs(3) before using Primes? - Gnimuc

1 Answers

4
votes

the documentation says "using DummyModule causes the module to be loaded on all processes when starting Julia with julia -p 2", which means, in REPL, one should run addprocs(2) firstly. so you should put addprocs(3) before using Primes.