Suppose we have a Vector{MyStruct}
with the following definition:
mutable struct MyStruct
x::Float64
end
Obviously, this is a vastly simplified example.
Now, we have a function that manipulates our struct in-place, e.g.:
function manipulate!(myStruct::MyStruct)
myStruct.x += 1
end
Another function to manipulate the full list:
function manipulate_list!(list::AbstractVector{MyStruct})
for s in list # loop to be parallelized
manipulate!(s)
end
deleteat!(list, 7)
push!(list, MyStruct(1.))
end
The goal is to parallelize the mutation loop over multiple processes (nodes).
(Of course, one could write everything in some array, but this would be way more complicated and therefore, I would like to use the structs approach.)
The vector is not very large (~1…10k structs), so there is no need to distribute the list for memory reasons. However, the mutations on the structs must be performed in parallel due to the heavy calculations involved, including external program calls with I/O.
As an additional caveat, the length of the vector is not constant, i.e. new structs can be added and removed like shown in the manipulate_list
function above.
I would appreciate it if anyone could point me in the right direction. I have gone through several tutorials, but they seem to focus more on “simple”, but much larger, fixed-size numerical arrays.