# How do I make sure that GPU functions use the maximum potential config for performance?

**URL:** <https://discourse.julialang.org/t/how-do-i-make-sure-that-gpu-functions-use-the-maximum-potential-config-for-performance/92989>\
**Category:** GPU\
**Created:** [January 15, 2023, 9:41am UTC](https://discourse.julialang.org/t/how-do-i-make-sure-that-gpu-functions-use-the-maximum-potential-config-for-performance/92989 "2023-01-15T09:41:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [January 15, 2023, 9:41am UTC](https://discourse.julialang.org/t/how-do-i-make-sure-that-gpu-functions-use-the-maximum-potential-config-for-performance/92989/1 "2023-01-15T09:41:59Z")

</div>

Hello!

I am doing some programming on GPU using CUDA.

Instead of writing kernels I am doing the recommended approach of using commonly available functions for GPU programming in CUDA.jl such as “.”, “map” etc.

I noticed that when using custom kernels one would write something akin to:

```julia
@cuda threads=x blocks=y

```

So first question; how do I know what threads and blocks I should use?

Second question for the programming I do above using “default functions”, how do I ensure that it uses the maximum resources available?

Kind regards

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [January 15, 2023, 8:42pm UTC](https://discourse.julialang.org/t/how-do-i-make-sure-that-gpu-functions-use-the-maximum-potential-config-for-performance/92989/2 "2023-01-15T20:42:32Z")

</div>

Anyone who could point me to a good ressource? 😊

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [January 15, 2023, 9:57pm UTC](https://discourse.julialang.org/t/how-do-i-make-sure-that-gpu-functions-use-the-maximum-potential-config-for-performance/92989/3 "2023-01-15T21:57:08Z")

</div>

Have you seen the section with `launch_configuration` on [Introduction · CUDA.jl](https://cuda.juliagpu.org/stable/tutorials/introduction/#Writing-a-parallel-GPU-kernel)?

---

<div class="post-metadata">

**Author:** ![dora\_ho](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dora_ho/32/42582_2.png) [@dora\_ho](https://discourse.julialang.org/u/dora_ho)\
**Post date:** [January 16, 2023, 3:13pm UTC](https://discourse.julialang.org/t/how-do-i-make-sure-that-gpu-functions-use-the-maximum-potential-config-for-performance/92989/4 "2023-01-16T15:13:07Z")

</div>

check out This notebook from the developer of `CUDA.jl`  
[cscs\_gpu\_course/2-2-kernel\_analysis\_optimization.ipynb at main · maleadt/cscs\_gpu\_course (github.com)](https://github.com/maleadt/cscs_gpu_course/blob/main/2-2-kernel_analysis_optimization.ipynb)  
The occupancy API should be the stuff that you are looking for
