# Status of math intrinsics

**URL:** https://discourse.julialang.org/t/status-of-math-intrinsics/63990
**Category:** GPU
**Created:** [July 3, 2021, 2:46pm UTC](https://discourse.julialang.org/t/status-of-math-intrinsics/63990 "2021-07-03T14:46:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![shiroghost](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@shiroghost](https://discourse.julialang.org/u/shiroghost)
#### Post date: [July 3, 2021, 2:46pm UTC](https://discourse.julialang.org/t/status-of-math-intrinsics/63990/1 "2021-07-03T14:46:52Z")

</div>

Hi all,

I would like to understand what is the status of math functions in CUDA.jl. In particular:

1. Is it neccesary to write CUDA.sin? It looks to me that this calls are converted automatically when code is executed on the GPU. If one needs to write CUDA.sin explicitly, what is the recommendation to write modules that can be used both on the GPU and on CPU?
2. I think that the documentation is outdated. It points to the file `src/device/cuda/libdevice.jl` that does not exist anymore. Instead it seems that this info is in `src/device/intrinsics/math.jl`
3. Is there a CUDA version of the intrinsic sincos?

Thanks!

A.

---

<div class="post-metadata">

### Author: ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)
#### Post date: [July 3, 2021, 3:35pm UTC](https://discourse.julialang.org/t/status-of-math-intrinsics/63990/2 "2021-07-03T15:35:29Z")

</div>

> [@shiroghost](#):
>
> Is it neccesary to write CUDA.sin? It looks to me that this calls are converted automatically when code is executed on the GPU. If one needs to write CUDA.sin explicitly, what is the recommendation to write modules that can be used both on the GPU and on CPU?

With CUDA.jl 3.x and Julia 1.6/1.7, no, you no longer need to write `CUDA.sin`; calls to `sin` and similar math functions are automatically replaced by the compiler as-needed.

> [@shiroghost](#):
>
> I think that the documentation is outdated. It points to the file `src/device/cuda/libdevice.jl` that does not exist anymore. Instead it seems that this info is in `src/device/intrinsics/math.jl`

Please feel free to send a PR to update the docs!

> [@shiroghost](#):
>
> Is there a CUDA version of the intrinsic sincos?

It doesn’t appear so; maybe it’s because it libdevice’s `sincos` stores the results into pointers, which would thus require two extra stack allocations?
