Groups 212 of 99+ julia-users › Problems understanding the usage of SharedArrays 3 posts by 3 authors Nils Gudat 1/9/15 Sorry for asking the umptiest question on parallelization, but I can't seem to get even the most basic calculations to run, so here's hoping someone can enlighten me. I'd like to make an interpolant created with Dierckx available on all my processors. I figured this would be possible using SharedArrays in the following way: addprocs(3) @everywhere using Dierckx xgrid = linspace(0.1, 100.0, 200) f_val = [xgrid[i]^(-0.25) for i in length(xgrid)] convert(SharedArray, xgrid) convert(SharedArray, f_val) @everywhere interpolant = Spline1D(xgrid, f_val) However, this attempt fails with two errors (or six, two for each core): Spline1D has not method matching Spline1D(::SharedArray{Float64, 1}, ::SharedArray{Float64, 1}) and xgrid_irr not defined I have a question on each: 1. How can I use SharedArrays in functions that don't have a method for them? 2. Why would xgrid not be defined on the other cores? My understanding from reading the SharedArray part of the documentation was that their whole purpose is to make an array available to all cores? Any hints or tips would be greatly appreciated! Tim Holy 1/9/15 1. You (or someone) needs to write those methods. Since the Spline1D function is defined in the Dierckx package, that's where the SharedArray version should go, too (if you don't just maintain it on your own). 2. After convert(SharedArray, xgrid) xgrid will still be an ordinary array. You've not captured the output of the convert function. --Tim On Friday, January 09, 2015 08:33:20 AM Nils Gudat wrote: > Sorry for asking the umptiest question on parallelization, but I can't seem > to get even the most basic calculations to run, so here's hoping someone > can enlighten me. > I'd like to make an interpolant created with Dierckx available on all my > processors. I figured this would be possible using SharedArrays in the > following way: > > addprocs(3) > > @everywhere using Dierckx > > xgrid = linspace(0.1, 100.0, 200) > > f_val = [xgrid[i]^(-0.25) for i in length(xgrid)] > > convert(SharedArray, xgrid) > convert(SharedArray, f_val) > > @everywhere interpolant = Spline1D(xgrid, f_val) > > > However, this attempt fails with two errors (or six, two for each core): > > Spline1D has not method matching Spline1D(::SharedArray{Float64, 1}, > > ::SharedArray{Float64, 1}) > > and > > xgrid_irr not defined > > I have a question on each: > 1. How can I use SharedArrays in functions that don't have a method for > them? > 2. Why would xgrid not be defined on the other cores? My understanding from > reading the SharedArray part > rays-experimental> of the documentation was that their whole purpose is to - show quoted text - Kyle Barbary 1/9/15 Hi Nils, We could add a SharedArray method to the Dierckx methods as Tim suggests, perhaps by changing the signatures from Vector{Float64} to Union(Vector{Float64}, SharedArray{Float64, 1}). I’ve never really used SharedArrays myself, but an easier option might be to use the sdata function. For example, the following works for me: xgrid = convert(SharedArray, linspace(0.1, 100., 200)) fval = convert(SharedArray, Float64[xgrid[i]^(-0.25) for i in 1:length(xgrid)]) spl = Spline1D(sdata(xgrid), sdata(fval)) Best, Kyle - show quoted text -