# Registers occupation in \_\_device\_\_ functions

**URL:** <https://forums.developer.nvidia.com/t/registers-occupation-in-device-functions/2651>\
**Category:** CUDA Programming and Performance\
**Created:** [February 15, 2008, 11:13am UTC](https://forums.developer.nvidia.com/t/registers-occupation-in-device-functions/2651 "2008-02-15T11:13:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kubrick](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Kubrick](https://forums.developer.nvidia.com/u/Kubrick)\
**Post date:** [February 15, 2008, 11:13am UTC](https://forums.developer.nvidia.com/t/registers-occupation-in-device-functions/2651/1 "2008-02-15T11:13:04Z")

</div>

If my kernel invokes a **device** function to which it passes certain parameters, does this function need additional memory registers to store these parameters, or do they reside in the same registers as in the kernel.  
In other words, is code 1 equivalent to code 2 in terms of registers occupation?

Code 1:  
**global** void myKernel(int a, intb){  
int c;

```
c = a + b;

```

}

Code 2:  
**device** int sum(int s1, int s2){  
int result;

result = s1+s2;  
return(result);  
}

**global** void myKernel(int a, intb){  
int c;

```
c = sum(a, B);

```

}

---

<div class="post-metadata">

**Author:** ![quak](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@quak](https://forums.developer.nvidia.com/u/quak)\
**Post date:** [February 15, 2008, 12:41pm UTC](https://forums.developer.nvidia.com/t/registers-occupation-in-device-functions/2651/2 "2008-02-15T12:41:43Z")

</div>

So far every **device** function has been inlined by the compiler for me.  
Check your .ptx file, int sum() shouldn’t even show up there.

---

<div class="post-metadata">

**Author:** ![MisterAnderson42](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@MisterAnderson42](https://forums.developer.nvidia.com/u/MisterAnderson42)\
**Post date:** [February 17, 2008, 3:45pm UTC](https://forums.developer.nvidia.com/t/registers-occupation-in-device-functions/2651/3 "2008-02-17T15:45:25Z")

</div>

The compiler performs extremely aggressive register usage reductions. You shouldn’t see any increase in register usage by calling device functions. I have one unrolled loop that calls a device function 27 times, and the total register usage of the kernel is only 22.
