# Saving values from GPU during Euler stepping in ODE

**URL:** <https://discourse.julialang.org/t/saving-values-from-gpu-during-euler-stepping-in-ode/7406>\
**Category:** Performance\
**Tags:** arrayfire, gpu, gpuarrays\
**Created:** [November 30, 2017, 7:58am UTC](https://discourse.julialang.org/t/saving-values-from-gpu-during-euler-stepping-in-ode/7406 "2017-11-30T07:58:21Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [December 4, 2017, 8:26pm UTC](https://discourse.julialang.org/t/saving-values-from-gpu-during-euler-stepping-in-ode/7406/21 "2017-12-04T20:26:56Z")

</div>

it is probably easier to port the CL version that I post instead of @sdanisch one at the cost of performance.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [December 4, 2017, 8:36pm UTC](https://discourse.julialang.org/t/saving-values-from-gpu-during-euler-stepping-in-ode/7406/22 "2017-12-04T20:36:21Z")

</div>

> [@sdwfrost](#):
>
> I thought it would be straightforward to port this example to CuArrays from CLArrays, but I’m getting some errors that a GPU newbie like myself can’t easily resolve. Is there a guide to go between the two?

Right now CUArrays is rough to install because it needs Julia to be built from source in order to do its codegen. That’ll change with Julia’s v0.7/1.0 release though. I still haven’t gotten it to work on v0.6 at all so YMMV.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [December 4, 2017, 8:54pm UTC](https://discourse.julialang.org/t/saving-values-from-gpu-during-euler-stepping-in-ode/7406/23 "2017-12-04T20:54:59Z")

</div>

In theory, you just need to prefix all math intrinsics with CUDAnative.  
E.g.: log, sqrt, max.  
stuff like `@linearidx` & `gpu_call`, `gpu_rand!` comes from GPUArrays and should work for CuArrays & CLArrays!

So basically anything, that doesn’t come from GPUArrays and is not pure Julia.

Have a look at: [https://github.com/JuliaGPU/CUDAnative.jl/blob/master/src/device/libdevice.jl](https://github.com/JuliaGPU/CUDAnative.jl/blob/master/src/device/libdevice.jl) for a more exhaustive list of what functions you need to replace!

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [June 27, 2018, 4:53pm UTC](https://discourse.julialang.org/t/saving-values-from-gpu-during-euler-stepping-in-ode/7406/24 "2018-06-27T16:53:40Z")

</div>

Hi,

I want to come back here for the `gpu_call`. It is here called with the default `configuration = length(A)`. Is it the best way to set up the number of threads? How can this be optimised?

Tahnk you

Bests

[Previous page](https://discourse.julialang.org/t/saving-values-from-gpu-during-euler-stepping-in-ode/7406.md?page=1)
