# How to pass a random array of 2^57 as an input to a function?

**URL:** <https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 4, 2021, 1:52am UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578 "2021-02-04T01:52:35Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![naviinkapoor](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@naviinkapoor](https://discourse.julialang.org/u/naviinkapoor)\
**Post date:** [February 4, 2021, 1:52am UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/1 "2021-02-04T01:52:35Z")

</div>

I am creating a function that needs a very large size of the array as an input. Please let me know how can I do that.

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [February 4, 2021, 3:30am UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/2 "2021-02-04T03:30:05Z")

</div>

Why would it be different from passing a smaller random array?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 4, 2021, 4:01am UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/3 "2021-02-04T04:01:39Z")

</div>

wait, how much RAM you have? an array of length 2^57 is like…:

```julia
julia> 2^57 / 1024^5
128

```

128 ~~EB~~ Pb at least, assuming it’s a bitarray

---

<div class="post-metadata">

**Author:** ![naviinkapoor](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@naviinkapoor](https://discourse.julialang.org/u/naviinkapoor)\
**Post date:** [February 4, 2021, 10:08am UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/4 "2021-02-04T10:08:15Z")

</div>

It is a part of parallel computing, and machines are huge

---

<div class="post-metadata">

**Author:** ![naviinkapoor](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@naviinkapoor](https://discourse.julialang.org/u/naviinkapoor)\
**Post date:** [February 4, 2021, 10:09am UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/5 "2021-02-04T10:09:11Z")

</div>

No difference, I am ok if anyone has an idea to pass an array like 2^3. And later for load testing I can change to 2^57

---

<div class="post-metadata">

**Author:** ![mschauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mschauer/32/13946_2.png) [@mschauer](https://discourse.julialang.org/u/mschauer)\
**Post date:** [February 4, 2021, 10:12am UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/6 "2021-02-04T10:12:30Z")

</div>

This reminds me of an earlier discussion. What do you mean with “random array”? In case you mean an array of random numbers: there is no need to pass that array, instead you can pass the random seed and generate the numbers anew inside the function.

---

<div class="post-metadata">

**Author:** ![naviinkapoor](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@naviinkapoor](https://discourse.julialang.org/u/naviinkapoor)\
**Post date:** [February 4, 2021, 10:20am UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/7 "2021-02-04T10:20:50Z")

</div>

Yes, I need to use Seed also, but I am using recursion in the function, so I have to use array as a parameter.

I am working on creating a sum reduction on large array with limited number of tasks , lets say 20, in parallel.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 4, 2021, 12:59pm UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/8 "2021-02-04T12:59:11Z")

</div>

I don’t think ~~the world~~ anyone has ~~128EB~~ 128Pb of RAM.

You just cannot have a 2^57 array “concretely exist” at any given moment

---

<div class="post-metadata">

**Author:** ![josuagrw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josuagrw/32/1015_2.png) [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Post date:** [February 4, 2021, 3:18pm UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/9 "2021-02-04T15:18:48Z")

</div>

This is fine. Passing an `Array` as an argument to a function does not copy the `Array` in memory. No special treatment is required.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [February 4, 2021, 4:34pm UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/10 "2021-02-04T16:34:25Z")

</div>

> [@jling](#):
>
> ```julia
> julia> 2^57 / 1024^5
> 128
> 
> ```
> 
> 128EB at least, assuming it’s a bitarray

You’re off on your prefixes. That’s 128 PiB.

For comparison the [world top supercomputer](https://www.top500.org/system/179807/) has 5 PiB of memory. Granted that it’s top ranked on flops and not memory I still think it’s safe to assume that nobody has access to any kind of hardware that can handle an array with 2^57 elements.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [February 4, 2021, 5:33pm UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/12 "2021-02-04T17:33:37Z")

</div>

Presumably the function does not need all of it in memory at once? So you can break it up into pieces.

---

<div class="post-metadata">

**Author:** ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Post date:** [February 4, 2021, 5:38pm UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/13 "2021-02-04T17:38:12Z")

</div>

If it is a random array, I would pass a seed of the random number generator and calculate elements only when I need them.

---

<div class="post-metadata">

**Author:** ![naviinkapoor](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@naviinkapoor](https://discourse.julialang.org/u/naviinkapoor)\
**Post date:** [February 6, 2021, 7:15pm UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/14 "2021-02-06T19:15:41Z")

</div>

Thanks

---

<div class="post-metadata">

**Author:** ![naviinkapoor](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@naviinkapoor](https://discourse.julialang.org/u/naviinkapoor)\
**Post date:** [February 6, 2021, 7:49pm UTC](https://discourse.julialang.org/t/how-to-pass-a-random-array-of-2-57-as-an-input-to-a-function/54578/15 "2021-02-06T19:49:01Z")

</div>

It is a part of sum reduction and every call will be run parallelly.
