# How to parallerize dual coordinet descent mehods on GPU using CUDA.jl?

**URL:** <https://discourse.julialang.org/t/how-to-parallerize-dual-coordinet-descent-mehods-on-gpu-using-cuda-jl/40344>\
**Category:** GPU\
**Tags:** question, cuda\
**Created:** [May 28, 2020, 3:15pm UTC](https://discourse.julialang.org/t/how-to-parallerize-dual-coordinet-descent-mehods-on-gpu-using-cuda-jl/40344 "2020-05-28T15:15:19Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![msekino](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/msekino/32/12889_2.png) [@msekino](https://discourse.julialang.org/u/msekino)\
**Post date:** [May 31, 2020, 3:53pm UTC](https://discourse.julialang.org/t/how-to-parallerize-dual-coordinet-descent-mehods-on-gpu-using-cuda-jl/40344/8 "2020-05-31T15:53:56Z")

</div>

@maleadt I’m sorry, I’ve too early to select the answer as the solution, but I’m stuck again…

I implemented the code for my own model (i.e. `Δαᵢ = 0.1 * xᵢ⊤d # dummy` is replaced with an update equation). When the code executed on CPU, the result was fine. On the other hand, when the code executed on GPU with `blocks=Int(floor(numsample/32)) threads=32` instead of `threads=numsample`, the numerical result went to extremely large values…

Now I want to ask the followings.

- Can `d::CuVector` be shared by all blocks and threads?
  - I expected that the reading `d` (at `xᵢ⊤d += Xᵢⱼ * d[j]`) is an atomic read. Therefore while one thread reading `d[j]`, all other blocks and threads cannot alter or corrupt the value `d[j]` which the other threads are reading.
  - I expected that the atomic updating `d` is reflected on all blocks and threads immediately after the update.

- Or, `d::CuVector` is just a host representation, therefore `d` is no longer shared after copied to GPU memory. If so, are there any way to realize my expectations?

---

_[View the full topic](https://discourse.julialang.org/t/how-to-parallerize-dual-coordinet-descent-mehods-on-gpu-using-cuda-jl/40344)._
