# \#sharedarrays

**URL:** https://discourse.julialang.org/tag/sharedarrays/508.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [I don't understand why it is slower with CuStaticSharedArray](https://discourse.julialang.org/t/i-dont-understand-why-it-is-slower-with-custaticsharedarray/126763)

<div class="topic-metadata">

**Author:** [@Ludovic\_Dumoulin](https://discourse.julialang.org/u/Ludovic_Dumoulin)\
**Replies:** 9\
**Last updated:** [March 17, 2025, 4:35pm UTC](https://discourse.julialang.org/t/i-dont-understand-why-it-is-slower-with-custaticsharedarray/126763 "2025-03-17T16:35:32Z")

</div>

Hello, I am new to Julia and I am trying to use an iterative scheme to solve a force balance equation, concretely the kernel without shared memory is quite simple: function kernel\_comp\_v\_noshmem!(vn, v, F) # Indexi…

---

## [Parallel computation to speed up for loops](https://discourse.julialang.org/t/parallel-computation-to-speed-up-for-loops/126006)

<div class="topic-metadata">

**Author:** [@AP9](https://discourse.julialang.org/u/AP9)\
**Replies:** 3\
**Last updated:** [February 18, 2025, 7:00pm UTC](https://discourse.julialang.org/t/parallel-computation-to-speed-up-for-loops/126006 "2025-02-18T19:00:02Z")

</div>

I am computing the Lyapunov exponents in 2D for the system below, by doing a for loop over two parameters (ωA, A) and it takes a really long time. using Parameters, ChaosTools, DifferentialEquations, Distributed, Shared…

---

## [Is it possible to use CuStaticSharedArray(T, n) with n const?](https://discourse.julialang.org/t/is-it-possible-to-use-custaticsharedarray-t-n-with-n-const/125756)

<div class="topic-metadata">

**Author:** [@Ludovic\_Dumoulin](https://discourse.julialang.org/u/Ludovic_Dumoulin)\
**Replies:** 2\
**Last updated:** [February 11, 2025, 8:59am UTC](https://discourse.julialang.org/t/is-it-possible-to-use-custaticsharedarray-t-n-with-n-const/125756 "2025-02-11T08:59:19Z")

</div>

Hello, I would like to compare the size of different block to see how the calculation speed-up or not. I use SharedArray of size CuStaticSharedArray(Float64, (B+2,B+2)) with B from 16 to 32, and now I am changing B by …

---

## [Help with shared arrays - code update](https://discourse.julialang.org/t/help-with-shared-arrays-code-update/125692)

<div class="topic-metadata">

**Author:** [@Fernando1](https://discourse.julialang.org/u/Fernando1)\
**Replies:** 2\
**Last updated:** [February 9, 2025, 6:13pm UTC](https://discourse.julialang.org/t/help-with-shared-arrays-code-update/125692 "2025-02-09T18:13:05Z")

</div>

Hi all, this is the same post as I had done before but with the code correctly added. I am trying to run a “Simulate” function living in a separate module and extract the states from it with a getStates function. The id…

---

## [SharedArray using DataFrames()](https://discourse.julialang.org/t/sharedarray-using-dataframes/116908)

<div class="topic-metadata">

**Author:** [@Gast](https://discourse.julialang.org/u/Gast)\
**Replies:** 0\
**Last updated:** [July 11, 2024, 12:54pm UTC](https://discourse.julialang.org/t/sharedarray-using-dataframes/116908 "2024-07-11T12:54:07Z")

</div>

Hi all I use the DataFrame.jl package to define and manipulate arrays across several nested functions. I plan to parallelize some of the tasks (e.g., for loops with data allocations) by using the Distributed.jl package…

---

## [Huge distributed overhead](https://discourse.julialang.org/t/huge-distributed-overhead/115815)

<div class="topic-metadata">

**Author:** [@greivin](https://discourse.julialang.org/u/greivin)\
**Replies:** 2\
**Last updated:** [June 19, 2024, 11:46am UTC](https://discourse.julialang.org/t/huge-distributed-overhead/115815 "2024-06-19T11:46:17Z")

</div>

My code looks something like this. First, I have a file where I define my functions #Functions.jl file #Here we import the relevant packages and define all the functions with @everywere @everywhere Solver(A, N) …

---

## [How to declare sharedarray in local scope](https://discourse.julialang.org/t/how-to-declare-sharedarray-in-local-scope/112683)

<div class="topic-metadata">

**Author:** [@TongTongYee](https://discourse.julialang.org/u/TongTongYee)\
**Replies:** 0\
**Last updated:** [April 8, 2024, 1:49pm UTC](https://discourse.julialang.org/t/how-to-declare-sharedarray-in-local-scope/112683 "2024-04-08T13:49:34Z")

</div>

Hi! I want to use sharedArray without data movement. So I write the following code. using Distributed addprocs(1) A = SharedArray{ComplexF64,1}(fill(1,(10))); @everywhere 2 A But this code makes the error, ERROR: On…

---

## [Distributed Arrays: Using multiprocessing increaes memory allocations by factor of 200 and slows down](https://discourse.julialang.org/t/distributed-arrays-using-multiprocessing-increaes-memory-allocations-by-factor-of-200-and-slows-down/109402)

<div class="topic-metadata">

**Author:** [@james](https://discourse.julialang.org/u/james)\
**Replies:** 0\
**Last updated:** [January 29, 2024, 2:45pm UTC](https://discourse.julialang.org/t/distributed-arrays-using-multiprocessing-increaes-memory-allocations-by-factor-of-200-and-slows-down/109402 "2024-01-29T14:45:49Z")

</div>

I have 4 processes, each working on a separate part of an array in parallel. Following a previous thread, I use the DistributedArrays package so that every process gets their own part of the array. In the MWE below, I r…

---

## [Way to make Shared-SparseArray?](https://discourse.julialang.org/t/way-to-make-shared-sparsearray/104016)

<div class="topic-metadata">

**Author:** [@Fluorite-Erbite](https://discourse.julialang.org/u/Fluorite-Erbite)\
**Replies:** 1\
**Last updated:** [September 19, 2023, 11:08am UTC](https://discourse.julialang.org/t/way-to-make-shared-sparsearray/104016 "2023-09-19T11:08:56Z")

</div>

I want to process sparse matrices in parallel. But, as far as I’ve tried, I cannot make Shared-SparseArray. Is it possible?

---

## [Shared data between processes](https://discourse.julialang.org/t/shared-data-between-processes/101350)

<div class="topic-metadata">

**Author:** [@pitsianis](https://discourse.julialang.org/u/pitsianis)\
**Replies:** 0\
**Last updated:** [July 8, 2023, 3:20pm UTC](https://discourse.julialang.org/t/shared-data-between-processes/101350 "2023-07-08T15:20:23Z")

</div>

I was surprised that SharedArrays.jl does not support SparseArrays. Is there any package that can place any data structure in a shared memory segment so that collaborating processes from Distributed.jl can access them w…

---

## [Transfer elements of an array to a shared array](https://discourse.julialang.org/t/transfer-elements-of-an-array-to-a-shared-array/87746)

<div class="topic-metadata">

**Author:** [@jisutich](https://discourse.julialang.org/u/jisutich)\
**Replies:** 7\
**Last updated:** [September 27, 2022, 7:35pm UTC](https://discourse.julialang.org/t/transfer-elements-of-an-array-to-a-shared-array/87746 "2022-09-27T19:35:05Z")

</div>

Hi, Suppose I have a SharedArray and now I have a normal vector which contains some values. I want to update the elements of my Shared Array by this vector. How to do it? Basically I have sample code using Distributed …

---

## [Unhandled Task Error](https://discourse.julialang.org/t/unhandled-task-error/87749)

<div class="topic-metadata">

**Author:** [@jisutich](https://discourse.julialang.org/u/jisutich)\
**Replies:** 2\
**Last updated:** [September 24, 2022, 11:13pm UTC](https://discourse.julialang.org/t/unhandled-task-error/87749 "2022-09-24T23:13:34Z")

</div>

Hi, I am trying to use pmap to speed up my code. When I try to run a sample code with a for loop of just 10 cycles, I faced an unhandled task error. What does it mean? Personally I think the 10 cycles have finished …

---

## [Passing a SharedArray as a pmap argument](https://discourse.julialang.org/t/passing-a-sharedarray-as-a-pmap-argument/87721)

<div class="topic-metadata">

**Author:** [@jisutich](https://discourse.julialang.org/u/jisutich)\
**Replies:** 1\
**Last updated:** [September 24, 2022, 3:29am UTC](https://discourse.julialang.org/t/passing-a-sharedarray-as-a-pmap-argument/87721 "2022-09-24T03:29:32Z")

</div>

Hi I am thinking about using SharedArrays in the following problem. Suppose I have an index k which increases from 1 to 800 (for instance). And for each k, I have a pool p which has large size and many numbers stored in…

---

## [Parallelizing Monte Carlo - using buffers, avoiding global variables](https://discourse.julialang.org/t/parallelizing-monte-carlo-using-buffers-avoiding-global-variables/86364)

<div class="topic-metadata">

**Author:** [@psterzinger](https://discourse.julialang.org/u/psterzinger)\
**Replies:** 3\
**Last updated:** [August 26, 2022, 4:03pm UTC](https://discourse.julialang.org/t/parallelizing-monte-carlo-using-buffers-avoiding-global-variables/86364 "2022-08-26T16:03:24Z")

</div>

Hi, I am trying to parallelize a Monte Carlo simulation using Distributed and SharedArrays, where I essentially want to assign workers independent iterations of my simulation. My simulation setup boils down to a simple …

---

## [Difference between SharedArrays and DistributedArrays](https://discourse.julialang.org/t/difference-between-sharedarrays-and-distributedarrays/60258)

<div class="topic-metadata">

**Author:** [@shce](https://discourse.julialang.org/u/shce)\
**Replies:** 7\
**Last updated:** [February 14, 2022, 2:42am UTC](https://discourse.julialang.org/t/difference-between-sharedarrays-and-distributedarrays/60258 "2022-02-14T02:42:23Z")

</div>

Hello, I am struggling with understanding the difference between SharedArrays and DistributedArrays. I do not understand (I am pretty new to parallelism) what is meant by (from the documentation) Shared Arrays use sy…

---

## [Why is advection\_shared! much faster than advection\_parallel!?](https://discourse.julialang.org/t/why-is-advection-shared-much-faster-than-advection-parallel/71231)

<div class="topic-metadata">

**Author:** [@DerongXu](https://discourse.julialang.org/u/DerongXu)\
**Replies:** 0\
**Last updated:** [November 9, 2021, 11:10pm UTC](https://discourse.julialang.org/t/why-is-advection-shared-much-faster-than-advection-parallel/71231 "2021-11-09T23:10:50Z")

</div>

Hi all, I am learning the parallel computing in Julia through the manual Multi-processing and Distributed Computing · The Julia Language In this page, why is advection\_shared! much faster than advection\_parallel! ? Bot…

---

## [How to pre-allocate an Array of UnitRange (specifically a SharedArray of Tuple of UnitRange)?](https://discourse.julialang.org/t/how-to-pre-allocate-an-array-of-unitrange-specifically-a-sharedarray-of-tuple-of-unitrange/66506)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 1\
**Last updated:** [August 16, 2021, 7:33pm UTC](https://discourse.julialang.org/t/how-to-pre-allocate-an-array-of-unitrange-specifically-a-sharedarray-of-tuple-of-unitrange/66506 "2021-08-16T19:33:39Z")

</div>

Question Is there a shorter or better way to pre-allocate indsTup and inds as shown below? : indsTup = \[(1:2,1:2)\] for i in 1:10 push!(indsTup,(1:2,1:2)) end indsTup = SharedArray(indsTup) inds = \[1:2\] for i in 1:10 …

---

## [Occasional SharedArray errors on slurm](https://discourse.julialang.org/t/occasional-sharedarray-errors-on-slurm/61385)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 1\
**Last updated:** [May 18, 2021, 9:42pm UTC](https://discourse.julialang.org/t/occasional-sharedarray-errors-on-slurm/61385 "2021-05-18T21:42:52Z")

</div>

I’m having trouble \[minimally\] reproducing this locally. It happens for maybe 0.1-5% of array tasks which execute initShared() from unregistered package pqADMM and causes the slurm error shown below for that respective …

---

## [SharedArrays and process affinity](https://discourse.julialang.org/t/sharedarrays-and-process-affinity/55684)

<div class="topic-metadata">

**Author:** [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Replies:** 3\
**Last updated:** [February 24, 2021, 10:50pm UTC](https://discourse.julialang.org/t/sharedarrays-and-process-affinity/55684 "2021-02-24T22:50:57Z")

</div>

I am trying to pin my julia workers to specific CPU cores with ClusterManagers.jl. However, it seems LocalAffinityManager does not work well with SharedArrays. using Distributed, SharedArrays, ClusterManagers addprocs(…

---

## [Explicit distribution of chunks in SharedArray?](https://discourse.julialang.org/t/explicit-distribution-of-chunks-in-sharedarray/53249)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 2\
**Last updated:** [January 12, 2021, 8:23pm UTC](https://discourse.julialang.org/t/explicit-distribution-of-chunks-in-sharedarray/53249 "2021-01-12T20:23:24Z")

</div>

How can I construct a SharedArray with a specific chunk distribution across workers? For instance: julia -p 2 using SharedArrays,Distributed,Test @everywhere using SharedArrays a = SharedArray{Float64,2}((3,5),init = …

---

## [All workers not have access to a sharedarray](https://discourse.julialang.org/t/all-workers-not-have-access-to-a-sharedarray/50834)

<div class="topic-metadata">

**Author:** [@ankit13](https://discourse.julialang.org/u/ankit13)\
**Replies:** 3\
**Last updated:** [November 26, 2020, 10:24pm UTC](https://discourse.julialang.org/t/all-workers-not-have-access-to-a-sharedarray/50834 "2020-11-26T22:24:26Z")

</div>

Hi, I get an error that x is not defined on worker 2/others when I run this. using Distributed addprocs(4) @everywhere using SharedArrays x = zero( SharedArray{Float64}( 10 ) ); @everywhere println( x\[2\] ) What is …

---

## [How to GC a SharedArray](https://discourse.julialang.org/t/how-to-gc-a-sharedarray/48699)

<div class="topic-metadata">

**Author:** [@ianshmean](https://discourse.julialang.org/u/ianshmean)\
**Replies:** 6\
**Last updated:** [October 28, 2020, 9:23am UTC](https://discourse.julialang.org/t/how-to-gc-a-sharedarray/48699 "2020-10-28T09:23:08Z")

</div>

What’s the right way to garbage collect a SharedArray? This doesn’t work. Julia consumes 8 GB memory indefinitely (Version 1.6.0-DEV.1237) using SharedArrays begin a = SharedArray{Float64}(10000000) @distributed…
