# Casting in Cuda kernel?

**URL:** <https://forums.developer.nvidia.com/t/casting-in-cuda-kernel/12298>\
**Category:** CUDA Programming and Performance\
**Created:** [September 21, 2009, 8:58pm UTC](https://forums.developer.nvidia.com/t/casting-in-cuda-kernel/12298 "2009-09-21T20:58:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LKeene](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@LKeene](https://forums.developer.nvidia.com/u/LKeene)\
**Post date:** [September 21, 2009, 8:58pm UTC](https://forums.developer.nvidia.com/t/casting-in-cuda-kernel/12298/1 "2009-09-21T20:58:45Z")

</div>

Hello all,

I’m trying to do some image processing using Cuda. I’ve read the articles regarding convolution in Cuda and am following most of the strategies. However, My images are not 4-bytes per pixel (like all the examples I’m seeing) but instead 8-bit per pixel grayscales. This seems like it should be beneficial as it will allow a greater number of pixels into each block’s shared memory. My strategy then is to copy the 8-bit pixels into shared memory and then cast them as floats as they are accessed and operated upon in the kernel. Is this okay, or is there a problem doing casts in Cuda? Thanks in advance.

-L

---

<div class="post-metadata">

**Author:** ![tmurray](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@tmurray](https://forums.developer.nvidia.com/u/tmurray)\
**Post date:** [September 21, 2009, 9:00pm UTC](https://forums.developer.nvidia.com/t/casting-in-cuda-kernel/12298/2 "2009-09-21T21:00:12Z")

</div>

nope, no problem with casting.

---

<div class="post-metadata">

**Author:** ![LKeene](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@LKeene](https://forums.developer.nvidia.com/u/LKeene)\
**Post date:** [September 22, 2009, 5:59pm UTC](https://forums.developer.nvidia.com/t/casting-in-cuda-kernel/12298/3 "2009-09-22T17:59:51Z")

</div>

> [@](#):
>
> nope, no problem with casting.

Thank you. Lastly, any problem using data type “unsigned char” in my device code?

---

<div class="post-metadata">

**Author:** ![tmurray](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@tmurray](https://forums.developer.nvidia.com/u/tmurray)\
**Post date:** [September 22, 2009, 6:06pm UTC](https://forums.developer.nvidia.com/t/casting-in-cuda-kernel/12298/4 "2009-09-22T18:06:46Z")

</div>

no, it should work fine.
