liveBook · Manning

CPU

As explained in Fast Python: High performance techniques for large datasets

A central processing unit (CPU) is a general-purpose processor that executes computer instructions and performs computational operations.

A CPU runs general-purpose computations with a relatively small number of fast computation units. Increasing CPU processing power now depends more on parallel units than on raw speed, making the way work is divided important to data-processing performance. section 1.2.1 section 9.4

Start with the workload, then profile it. Computing distances between every pair of NOAA stations is a CPU-intensive, quadratic task that also uses substantial memory. Python’s profiling tools help locate where its execution time goes before an optimization is chosen. section 2.2

A simplified execution comparison

To double 100 array elements, a single-core CPU model reads, doubles, and writes each value in sequence. With reads and writes priced at 90 time units each and doubling at 2, the total is 18,200 units. An idealized GPU model assigns one element to each of 100 concurrent threads and totals 240 units, despite slower computation per unit. These illustrative costs explain the advantage of parallel work; they are not benchmark results. section 9.1.1

Table 1.1 Memory hierarchy with sizes and access times for a hypothetical, but realistic modern desktop (view table figure)

Type

Size

Access time

CPU

L1 cache

256 KB

2 ns

L2 cache

1 MB

5 ns

L3 cache

6 MB

30 ns

RAM

DIMM

8 GB

100 ns

Secondary storage

SSD

256 GB

50 µs

HDD

2 TB

5 ms

Tertiary storage

NAS - Network Access Server

100 TB

Network dependent

Cloud proprietary

1 PB

Provider dependent

Compare cache, RAM, and storage access times to see why the location of data can matter alongside CPU computation. section 1.2.1

A GPU is not a faster CPU for every job: its many simpler units favor large numbers of similar, independent operations and use a different memory and execution model. Moving standard Python code to a GPU therefore calls for a suitable library or a redesign around parallel work, rather than a direct transfer of sequential code. section 1.2.1 section 9.4

How Fast Python: High performance techniques for large datasets covers it

How deep it goes
Works through an idealized operation-cost calculation and memory-access context, stopping short of a detailed CPU implementation.
Examples
Uses pairwise NOAA station distances and a 100-element array-doubling comparison.
What it assumes
Assumes familiarity with Python loops and arrays while introducing CPU–GPU execution differences through a simplified model.
What you can do after
Diagnose/debug CPU-bound Python workloads with profiling and evaluate whether their operations suit GPU parallelism.
How it connects
Connects CPUs to profiling, memory hierarchy, parallelism, and GPU computing.

Also explained in

Compare how 4 books explain CPU →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fast Python: High performance techniques for large datasets. The section links point to the parts of the book it draws on.