Two’s complement versus Ones’ complement. The term “two’s complement” arises from the fact that for nonnegative x we compute a w-bit representation of −x as 2^w-x (a single two). The term “ones’ complement” comes from the property that we can compute −x in this notation as [111 . . . 1] − x (multiple ones). (查看原文)
Unsigned arithmetic can be viewed as a form of modular arithmetic. Unsigned addition is equivalent to computing the sum modulo 2w. This value can be computed by simply discarding the high-order bit in the w+1-bit representation of x + y. (查看原文)
Given that integer multiplication is much more costly than shifting and adding, many C compilers try to remove many cases where an integer is being multiplied by a constant with combinations of shifting, adding, and subtracting. (查看原文)
Each DRAM chip is connected to some circuitry, known as the memory controller, that can transfer w bits at a time to and from each DRAM chip.
To read the contents of supercell (i, j ), the memory controller sends the row address i to the DRAM, followed by the column address j . The DRAM responds by sending the contents of supercell (i, j ) back to the controller.
The row address i is called a RAS (Row Access Strobe) request. The column address j is called a CAS (Column Access Strobe) request.
Notice that the RAS and CAS requests share the same DRAM address pins.
One reason circuit designers organize DRAMs as two-dimensional arrays instead of linear arrays is to reduce the number of address pins on the chip. For example, if our example 128-bit DRAM were organized as a linear array of 16 ... (查看原文)
In a program with good temporal locality, a memory location that is referenced once is likely to be referenced again multiple times in the near future.
In a program with good spatial locality, if a memory location is referenced once, then the program is likely to reference a nearby memory location in the near future (查看原文)
. Programs that repeatedly reference the same variables enjoy good temporal locality.
. For programs with stride-k reference patterns, the smaller the stride the better the spatial locality. Programs with stride-1 reference patterns have good spatial locality. Programs that hop around memory with large strides have poor spatial locality.
. Loops have good temporal and spatial locality with respect to instruction fetches. The smaller the loop body and the greater the number of loop iterations, the better the locality. (查看原文)