Game Development Reference
In-Depth Information
Gigahertz, as it is applied to CPUs, measure the clock speed of the CPU. The clock
speed is the basic measure of how fast things happen anything from loading a bit of
memory into a register to doing a mathematical operation like addition. Different
instructions take different cycles, or ticks, of the clock. Different types of processors,
such as GPUs, are highly optimized for certain kinds of operations, such as floating-
point division, and can perform multiple operations in a single tick of the system
clock.
In the Georgia Tech experiment, they were able to get a transistor to switch at
500GHz, but that does not mean you could pile those transistors onto a super-cooled
chip and have a CPU run at that speed. Sorry to throw cold water on the party, but
the transistors in a chip have to carefully coordinated. Think of it like this
just
because I can create a vehicle capable of rocketing across a dry lake bed faster than
the speed of sound doesn ' t mean I can take millions of those same vehicles and try to
do the same on a regular-surface street.
Many processors are capable of executing instructions in parallel in a single core if
they use different parts of the processor. With the advent of multicore processors, it
is even possible to perform more than one instruction in a single cycle. Most new
computers now have two or even four cores. Some processors are even capable of
out-of-order execution, where the processor executes instructions in an order governed
by availability of input data rather than the order set by the programmer or compiler.
As fast as CPUs are and the tricks they pull to keep busy, they spend most of their
time waiting around. Take a look at Figure 20.1, a snapshot of the CPU load running
Teapot Wars, which you
'
ll see in Chapter 21,
A Game of Teapot Wars.
The figure shows a few spikes, but there
s going
on? Is Teapot Wars written so efficiently? Hardly. The CPU, or CPUs in this case,
spends most of its time waiting for the video hardware to draw the scene. This is a
pretty common thing in computer game software, since preparing the scene and
communicating to the video card take so much time.
It turns out there is a solution for this problem, and it involves multithreading.
Instead of creating a monolithic program that runs one instruction after another,
the programmer splits the program into multiple, independent pieces. Each piece is
launched independently and can run on its own. If one piece, or thread, becomes
stuck waiting for something, like the optical media drive to spin up so a file can be
read, the processor can switch over to another thread and process whatever instruc-
tions it has.
If you think this is similar to what happens when you run 50 different applications
on your desktop machine, you are very close to being right. Each application exists
'
s still plenty of headroom. So what
'
Search WWH ::




Custom Search