The Software Optimization Cookbook: High-Performance Recipes for IA-32 Platforms, Second Edition

Chapter 8: Memory

Overview

No single issue effects software performance more globally than the speed of memory. From a modern processor's point of view, memory is ridiculously slow. So slow, in fact, that nearly every application is limited by its performance. Slow memory hurts performance by forcing the processor to wait for instruction operands to be fetched from memory before executing an instruction. Waiting instructions take up space in the instruction pool, which can fill up, leaving the processor with nothing to execute. Writing to memory also hurts performance because buffers that are used to store data in memory can get backed up waiting to write to slow memory. The programmer sees these waits as higher instruction latencies, meaning that instructions appear to take longer than expected to execute. For example, the following code sums an array.

total=0;for (i=0; i<1000; i++)   total += array[i];

The processor executes the loop using the following five steps:

  1. Load array[i]

  2. Execute total = total + array[i]

  3. Increment loop counter i

  4. Compare loop counter < 1000

  5. Branch to step 1 if loop counter < 1000

Considering only the data dependencies, those five steps can be executed in three clocks because the load of the array in step one and the incrementing of the loop counter in step three can be executed at the same time as can steps two and four. But this loop is going to take much longer to execute than 3 * 1000 clocks because of the memory load latency. Before executing...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Microprocessor Chips (MPU)
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.