What is CPU / s for?
Some CPUs cannot directly access anything smaller than “something,” and the compiler must generate a sequence of “load, change, and mask” instructions to access individual bytes. Using int should win for this case.
Some processors can access bytes without problems. In this case (if enough data is involved, which is important), the problem is likely to be related to cache size and / or memory bandwidth; and (at least for 80x86), I expect char win simply because more data will be packed into each cache line.
For what algorithm / s?
If you can throw SIMD, char can win. For example, with a 128-bit SIMD, you can process 16 bytes per instruction or 4 (32-bit) integers for each command, and char can be 4 times faster because of this.
The best advice would be to use something like:
#ifdef USE_INT typedef int thingy #else typedef unsigned char thingy #endif
Then you can view it and change it whenever you want.
Brendan
source share