# Efficient CuArray shift/rotation

**URL:** <https://discourse.julialang.org/t/efficient-cuarray-shift-rotation/86845>\
**Category:** GPU\
**Created:** [September 6, 2022, 3:44pm UTC](https://discourse.julialang.org/t/efficient-cuarray-shift-rotation/86845 "2022-09-06T15:44:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 6, 2022, 4:59pm UTC](https://discourse.julialang.org/t/efficient-cuarray-shift-rotation/86845/2 "2022-09-06T16:59:28Z")

</div>

> [@swibe](#):
>
> I have a workload which regularly needs to perform operations on adjacent elements in an array and accumulate the result. I would sometimes like to be able to run this parallelised across the whole GPU, sometimes have many copies, each running sequentially within a single GPU thread, and sometimes run it sequentially on the CPU.

The most common way to do this in parallel computing is not by shifting the array, but rather by using “ghost cells” — make redundant copies of boundary data in a communication step, after which point the operations on each “chunk” of the array can occur in parallel. See e.g. _Principles of Parallel Programming_ by Lin and Snyder, quoted here: [Seemingly unnecessary allocation within for loop - #9 by ptoche](https://discourse.julialang.org/t/seemingly-unnecessary-allocation-within-for-loop/72556/9) and the [GitHub - fverdugo/PartitionedArrays.jl: Vectors and sparse matrices partitioned into pieces for parallel distributed-memory computations.](https://github.com/fverdugo/PartitionedArrays.jl) package (though this is not GPU-based).

---

_[View the full topic](https://discourse.julialang.org/t/efficient-cuarray-shift-rotation/86845)._
