uint8_t and sys/types.h


Im new to CUDA and a few days away from being able to access a usable card but I’m wondering if its possible to compile GPU code that includes sys/types. I need 8bit integers.

Also, is there any penalty with working with lots of 8bit ints instead of full 32?


You can use char or unsigned char types as 8-bit integers.
Performance penalties can be encountered during memory access.
Have a look at the CUDA Programming Guide for details on the correct accsses patterns for the different memory types.
A good stategy might be to “bundle” your char types into larger types (i.e. (u)int ) for memory access.

Having local signed/unsigned chars is OK, though the compiler will likely schedule individual 32-bit register for it, so it won’t be a register-saving optimization. Accessing bytes in shared memory is also OK, just watch out for high-degree bank coflicts, which affect performance to a certain degree. BUT accessing bytes and shorts in global(DRAM) memory is always extremely inefficient (never coalesced) on current hardware, though the situation will improve with next hardware revision.