Mon, 17 Apr 2000 Dipl.-Ing. O.Petzold wrote:
> > typedef unsigned char Bool;
> > ....
>
> Yes, this is one way. (I guess the best way at moment). I included the
> stdbool.h inside the c-program and assumed that this have the same size as it
> used inside C++ program. Both are Gnu C/C++, but it seems there are
> strange difference between bool on GNU C++/C:
Enums generate different basic data types on different compilers. Some use the
smallest type that can fit the range of enum values, while others never use
anything smaller than the standard int. IIRC, there is such a difference
between gcc and egcs, and some distros nowadays automatically use gcc for C
(for compatibility, for compiling the kernel among other things) and egcs for
C++ (for the latest improvements, more complete standards support etc)...
> So the best way is the way how did you suggested. Anyway is there a performance
> factor to use unsigned char versus unsigned int ? I believe to remember that
> one should use basic types (int and double) on performance programs ? Any
> experience? I compiled the kernel program (written in C) with -align-double etc.
This depends a bit on the CPU (*), but on most modern CPUs, it's a bandwidth vs.
cache/alignment optimization issue.
If you have arrays of bools and there is a high amount of non-cachable
dataflow in your system, you may benefit from physically smaller datatypes (ie
byte bools), as this saves the bus.
The same effect applies to some extent to the L2 (big, "slow") vs. L1 (small,
extremely fast) cache, but you'll only see that if you're doing almost no
processing on the data you shuffle - the L2 cache keeps up pretty well in normal
cases, at least if the code is properly optimized.
As for the occasional random access, any word size equal to or smaller than
the bus width will result in about the same performance. Basically, this is the
case for any CPU bound processing (as opposed to memory bound processing), as
long as you don't have a CPU that lacks decent support for the data type and
the operations you want to use.
David Olofson
Programmer
Reologica Instruments AB
Scheelev�gen 30
S-223 63 LUND
+46 (0)46 - 12 77 60
(*) For some (older workstation, some DSP and RISC...) machines with very
small caches and simple N bit-only busses, anything but N bit aligned N bit
writes meant read-modify-write... Reads are all the same, of course, except
for unaligned reads crossing memory word boundaries. (BTW, the Amiga 3000 had
some weird memory addressing cirquitry that allowed both 16 bit [DMA] and 32 bit
[CPU] access to the same memory banks. Cool, fast and simple, but that was
before the SIMM/DIMM days...)
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/