# Distributed Arrays

**URL:** <https://discourse.julialang.org/t/distributed-arrays/43402>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [July 20, 2020, 9:00pm UTC](https://discourse.julialang.org/t/distributed-arrays/43402 "2020-07-20T21:00:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyacykcharel](https://avatars.discourse-cdn.com/v4/letter/h/58956e/32.png) [@hyacykcharel](https://discourse.julialang.org/u/hyacykcharel)\
**Post date:** [July 20, 2020, 9:00pm UTC](https://discourse.julialang.org/t/distributed-arrays/43402/1 "2020-07-20T21:00:25Z")

</div>

hello how can I divide DistributedArrays  
A=drand(5,5)  
B=drand(5,1)  
C=A\B  
Im doing this but still getting Error

---

<div class="post-metadata">

**Author:** ![a.fas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/a.fas/32/8381_2.png) [@a.fas](https://discourse.julialang.org/u/a.fas)\
**Post date:** [July 21, 2020, 12:59am UTC](https://discourse.julialang.org/t/distributed-arrays/43402/2 "2020-07-21T00:59:30Z")

</div>

Played around with the DArray struct a bit, what you want is probably the following:

C = A.localpart\B.localpart

Not sure this would be any faster than using Arrays, though.

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [July 21, 2020, 1:46am UTC](https://discourse.julialang.org/t/distributed-arrays/43402/3 "2020-07-21T01:46:14Z")

</div>

The backslash division operator `\(A, B)` farms out to one of several matrix factorizations depending on the properties of its inputs. Unfortunately, distributed matrix factorization is fundamentally difficult due to the many-to-many nature of those factorizations, which imposes a huge network I/O overhead that effectively kills any gains you might achieve from using multiple machines; the processors will spend most of their time just waiting for data from the network. Solving only the local parts won’t work, since it ignores the many-to-many reality of factorizing.

If you’re only using a single machine, the linear algebra library will use a shared-memory routine dispatched across as many threads as you’ve made available with `BLAS.set_num_threads`, and there’s nothing to be gained by using DistributedArrays:

```julia
julia> A = rand(8000, 8000); B = rand(8000);

julia> BLAS.set_num_threads(1)

julia> @time A\B;
  9.291382 seconds (7 allocations: 488.404 MiB)

julia> BLAS.set_num_threads(4)

julia> @time A\B;
  4.121306 seconds (7 allocations: 488.404 MiB, 1.08% gc time)

```

There may be some iterative solvers that can be effectively parallelized across machines for your problem, but the domain specificity of those requires more information about what you’re actually trying to solve.

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [July 21, 2020, 8:14am UTC](https://discourse.julialang.org/t/distributed-arrays/43402/4 "2020-07-21T08:14:42Z")

</div>

I am not claimign expertise, however @stillyslalom highlights a good point about parallel programming. Look at how long it takes to set up and move the data for a parallel operation. If this is comparable to the time taken by that step then it is not helpful to parallelise it.  
Or maybe to put this better - if you are distributing across separate servers, go for the low hanging fruit of coarse parallelisation.
