assemblycpu-speed

Difference between word size and clock speed?


I've no idea whether my question is relevant or not.But what i wanted to know is,how both of this affect the cpu performance??The only thing i know for CPU with same architecture,the higher the clock speed the faster the processing ability of the CPU,but how about word size??How will it affect the speed of CPU and which one really determine the speed of the CPU??Does it contradict each other??Thanks.


Solution

  • Theoretically, a bigger word size makes code a bit slower. The reason is that in a 64-bit architecture, pointers are 64-bit words, hence data structures which are full of pointers (lists, trees, hash tables...) tend to use more RAM than what equivalent code does on a 32-bit architecture. Common RAM is slow (it does not respond as quick as the CPU would like it), so the CPU embeds a small amount of fast RAM, called a cache, where the most frequently used data is stored. Cache size is limited (typically 32 kB on a modern x86 from Intel). The 64-bit pointers make it harder for the processor to store as many data elements, hence reduced performance.

    However...

    There are several caveats to the above, especially on x86 platforms:

    1. In many applications, the bulk of the data is not pointers. E.g. in a 3D-heavy application (a game), most data is pictures (textures) and object coordinates. Such data is not impacted by the default word size of the platform.

    2. 64-bit pointers allow the application to easily address more than 4 GB of RAM. For RAM-hungry applications (e.g. photography editing) on a machine which has more than 4 GB of RAM, 64-bit words allow the use of more RAM, which, while being slow, is still widely faster than a hard disk. A 32-bit application would have, in the same situation, to juggle with data blocks between RAM and hard disk.

    3. On the x86 processors (so this is what happens on all modern PC and Mac), for historical reasons, the 64-bit mode does not come only with 64-bit registers; it also offers twice as many registers to the application, and this helps performance by a fair bit. The 64-bit mode also comes with SSE2, which has a faster handling of floating-point data than what x86 processors previously used.

    Therefore, on a PC or Mac, if possible, prefer 64-bit OS and applications. The better performance of 64-bit code is not a consequence of the larger word size; it is a consequence of other features which, historically, have come along the 64-bit mode on these architectures.

    On other systems (e.g. PowerPC), when both 32-bit and 64-bit modes are available, 32-bit is usually preferred, except for memory-hungry applications (which want to access more than 4 GB of RAM, assuming that RAM size is available), and for a very few applications which want to perform computations over more-than-32-bits integers (for instance, this happens with some cryptographic algorithms).