# Understanding parallelization of composite types

**URL:** <https://discourse.julialang.org/t/understanding-parallelization-of-composite-types/115077>\
**Category:** Julia at Scale\
**Tags:** hpc, parallel, struct\
**Created:** [June 2, 2024, 11:46am UTC](https://discourse.julialang.org/t/understanding-parallelization-of-composite-types/115077 "2024-06-02T11:46:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael2](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@michael2](https://discourse.julialang.org/u/michael2)\
**Post date:** [June 2, 2024, 11:46am UTC](https://discourse.julialang.org/t/understanding-parallelization-of-composite-types/115077/1 "2024-06-02T11:46:35Z")

</div>

Suppose we have a `Vector{MyStruct}` with the following definition:

```julia
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.:

```julia
function manipulate!(myStruct::MyStruct)
    myStruct.x += 1
end

```

Another function to manipulate the full list:

```julia
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.
