Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do caches have the endianness of their CPU?

In other words, do L1, L2, L3, etc. caches always reflect the endianness of their CPU?

Or does it make more sense to always store data in caches in some specific endianness?

Is there a general design decision?

like image 348
Lmn Avatar asked Nov 05 '15 10:11

Lmn


People also ask

What is endianness of the CPU?

In computing, endianness is the order or sequence of bytes of a word of digital data in computer memory.

What determines the endianness?

Broadly speaking, the endianness in use is determined by the CPU. Because there are a number of options, it is unsurprising that different semiconductor vendors have chosen different endianness for their CPUs.

What is CPU cache made of?

A memory cache, also called a "CPU cache," is a memory bank that bridges main memory and the processor. Comprising faster static RAM (SRAM) chips than the dynamic RAM (DRAM) used for main memory, the cache allows instructions to be executed and data to be read and written at higher speed.

Are most CPUs little endian?

Big-endian and Little-endian Intel x86 processor is little-endian, so most personal computers are little-endian.


1 Answers

Most modern caches do not store data as a sequential chunk of bytes, but rather use banking and interleaving techniques due to floorplan or timing considerations. In addition, most caches employ error correction techniques so additional bits may be interleaved with the data.

As a result, there's no real sense in discussing endianness of a cache, since the internal order is usually mangled by design considerations. On top of that, in most cases caches provide the data in full line granularity, so there's also no point in asking what offset you start reading from.

Finally, endianness is a matter of architecture, it's how you interpret data you get from the CPU. It exists to describe the possible options you can interpret data in. Caches are micro architectural, so by definition your CPU functional behavior should be oblivious to them, and they're free to implement whatever internal structure they want. The question may still be meaningful if you have some means to peek internally into the cache, and would like to translate that into a value, in which case the above consideration apply, and each processor may differ.

like image 111
Leeor Avatar answered Oct 11 '22 23:10

Leeor