I am trying to use a shared array and use that array inside of a function of a function. The issue is that the function that I am using the shared array in cannot have any additional parameters passed to it due to the fact that I will be using the function with a package in Julia that can only have one function input. Thus I cannot pass the shared array to the function that needs it and the shared array is not in the functions scope. My current solution is that I generate the function inside the function itself, but this is inefficient since this function is called many times. I was wondering if a more efficient solution existed?
An example of the type of problem I am working on is shown below.
using Distributed
if nprocs()==1
addprocs(2)
end
@everywhere using SharedArrays
#@everywhere include("BFGS.jl")
S =zeros(5,4) #in real script am using csvRead to read data in from file
szeSpring=size(S)
springDat = SharedArray{Float64, 2}((szeSpring[1], szeSpring[2]))
springDat = S .* 1.0
works=workers()
@everywhere function eig_sum(A,springDat)
Middle(A)
end
@everywhere function Middle(x)
for i=1:x
x=x .+ 1.0
vals = Inner(x)
end
end
@everywhere function Inner(y)
springDat =zeros(5,4) #in real script am using csvRead to read data in from file
vals = springDat .+ y
end
remote_do(eig_sum, works[1], 1,springDat)
In this example I need to use springDat inside of the Inner function, but cannot modify the inner function to accept the springDat array as an input to the function.