# How to make this piece of code faster? optimising it or using multiple threads?

**URL:** <https://discourse.julialang.org/t/how-to-make-this-piece-of-code-faster-optimising-it-or-using-multiple-threads/30590>\
**Category:** New to Julia\
**Created:** [November 1, 2019, 3:17pm UTC](https://discourse.julialang.org/t/how-to-make-this-piece-of-code-faster-optimising-it-or-using-multiple-threads/30590 "2019-11-01T15:17:44Z")\
**Posts on this page:** 1\
**Showing post:** 71

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [November 29, 2019, 5:36am UTC](https://discourse.julialang.org/t/how-to-make-this-piece-of-code-faster-optimising-it-or-using-multiple-threads/30590/71 "2019-11-29T05:36:39Z")

</div>

> [@ennvvy](#):
>
> update!(s,c,cu(A.cedg),cu(θₜ[A.t])) A.θ[h]=atan(sum(Array(s)),sum(Array(c)))

Sending data back and forth between cpu and gpu is costly. Why not perform the sum on the gpu?  
Also, if you’re going to run stuff on the gpu, I would guess you need to have the entire algorithm on the gpu to avoid excessive data transfer.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-make-this-piece-of-code-faster-optimising-it-or-using-multiple-threads/30590)._
