# How should I approach GPU programming?

**URL:** <https://discourse.julialang.org/t/how-should-i-approach-gpu-programming/37666>\
**Category:** GPU\
**Created:** [April 15, 2020, 9:20pm UTC](https://discourse.julialang.org/t/how-should-i-approach-gpu-programming/37666 "2020-04-15T21:20:00Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [April 16, 2020, 1:05pm UTC](https://discourse.julialang.org/t/how-should-i-approach-gpu-programming/37666/13 "2020-04-16T13:05:58Z")

</div>

One more thing, which may be useful (but it wouldn’t give much since it’s O(n) and your bottleneck is O(n^2)), you can remove

```julia
    @inbounds for i = 1:nCoords
        u[i] = u_tmp[i];
        pg[i] = pg_tmp[i];
    end

```

and instead do binding outside of `PackStep` function, something like this:

```julia
for _ in 1:number_of_steps
  PackStep(pg, pg_tmp, u, u_tmp, nCoords, nTot)
  pg, pg_tmp = pg_tmp, pg
  u, u_tmp = u_tmp, u
end

```

In this case it will be binding, not copying, so you can squeeze few additional nanoseconds.

P.S.: for nearest neighbours may be this thread will be relevant [Cell list algorithm is slower than double for loop](https://discourse.julialang.org/t/cell-list-algorithm-is-slower-than-double-for-loop/36621)

---

_[View the full topic](https://discourse.julialang.org/t/how-should-i-approach-gpu-programming/37666)._
