IB COMPUTER SCIENCE | A1.1.2 Role of a GPU

Lesson objective

Describe how GPU architecture supports suitable parallel workloads and explain its role in graphics rendering, artificial intelligence and large simulations.

Learn

A1.1.2 | ROLE OF A GPU

01 | WHY A COMPUTER NEEDS GRAPHICS PROCESSING

Imagine turning a corner in a 3D game. The view changes, objects move, light falls on new surfaces and a fresh image must appear on screen. That image is a frame. Producing many new frames every second involves an enormous amount of repeated calculation.

A graphics processing unit, or GPU, is a processor designed to carry out large amounts of suitable work in parallel. It is widely used to produce images, but its processing architecture also makes it useful for tasks such as machine learning and scientific simulation.

The key idea is not simply that a GPU is “a faster CPU”. Its strength is completing many similar calculations across large amounts of data. Whether a GPU helps depends on the structure of the work and the software using it.

By the end of this lesson, you should be able to describe what a GPU does, connect its architecture to parallel work and explain its role in graphics, AI and large simulations.

02 | START WITH PIXELS AND FRAMES

A pixel is an individual picture element in a digital image. Its stored values describe colour or brightness. A frame is one complete image in a sequence, such as the next view of a game world.

A 1920 × 1080 image contains 2,073,600 pixels. At 60 frames per second, the output contains 124,416,000 pixel positions each second. This calculation illustrates the amount of image data involved; it is not a count of GPU instructions. Producing one pixel can require many operations.

Rendering means generating an image from a description of a scene or other image information. In a 3D game, the description includes objects, their positions, a camera view, textures and lights. A texture is image data used to give a surface detail.

The GPU does not simply copy a complete ready-made picture from a game file. It can help calculate how the scene should look from the current viewpoint, then contribute to producing the frame that will be displayed.

03 | SIMILAR WORK ON MANY DIFFERENT VALUES

Suppose you brighten a grayscale photograph. A simple rule could add 40 to each pixel value, limiting the result to 255. A pixel with value 70 becomes 110; a pixel with value 240 becomes 255. Each output uses its own original pixel.

The rule is the same for every pixel, but the input value changes. Many pixels can therefore be processed at the same time. This is data parallelism: applying similar processing to different pieces of data concurrently.

Compare that with an algorithm in which each step needs the result of the previous step. You cannot simply assign all those dependent steps to separate workers and expect them to finish together. Useful parallelism requires suitable work and a correct way to divide it.

Graphics contains many opportunities for parallel work, although real rendering also includes dependencies and coordination. “Many pixels” is a helpful introduction, not a claim that every graphics operation is independent.

04 | THE ARCHITECTURE BEHIND THE ROLE

A GPU contains many arithmetic processing resources organised into groups. Groups of lightweight execution tasks, called threads, carry out calculations using those resources. A thread describes a sequence of execution; it is not a physical component by itself.

In common GPU designs, groups of threads are issued instructions together and operate on different data values. This arrangement suits repeated calculations, such as processing vertices or shading many image fragments. A vertex is a point used to describe geometry. Shading calculates a surface’s appearance.

You may see GPU arithmetic resources described as “cores”. Do not assume one advertised GPU core is equivalent to one complete general-purpose CPU core. GPU terminology and the grouping of resources depend on the manufacturer and architecture.

A GPU also needs registers, caches, scheduling and control resources, and access to memory. Memory bandwidth is the rate at which data can be transferred. Keeping many arithmetic resources busy requires enough data to reach them, not just a large core count.

HOW THE GPU FITS INTO AN APPLICATION

1 | CPU AND SOFTWARE

Prepare suitable work, supply data and issue commands.

2 | GPU

Schedule groups of tasks across many arithmetic resources.

LaneLaneLaneLaneLaneLaneLaneLane

Registers, caches and memory access support the calculations.

3 | RESULT

A rendered frame, processed image or numerical result becomes available to the application or display process.

Read the numbered stages in order. Commands and data move between processing resources and memory as needed. This is a functional diagram, not a chip layout.

05 | TRY A SMALL PARALLEL IMAGE TASK

This model uses an 8 × 8 grayscale image: 64 pixel calculations. Each completed pixel uses output = minimum(255, input + 40). The two panels calculate exactly the same results.

The first panel completes one pixel per model round. The second completes up to the selected number of pixels per round. Click Next round to see how batching changes the amount of completed work.

These are deliberately invented workers and equal-duration rounds. They do not represent real CPU or GPU clock cycles, core counts or measured performance. A CPU can also perform parallel work. This model isolates the idea of independent calculations, without real transfer costs or scheduling details.

ONE PIXEL PER ROUND

A BATCH PER ROUND

Numbers show completed output values. A dash means that pixel has not yet been processed. Changing the worker count resets both panels.

06 | FROM A 3D SCENE TO A SCREEN IMAGE

A game or design application first has information about a scene, rather than a photograph of its final appearance. Rendering turns that information into an image. The exact pipeline varies, but the following simplified stages show why there is so much mathematical work.

StageWhat is happeningWhy GPU processing helps
Prepare scene and commandsApplication software establishes objects, camera view and rendering work.The CPU and software arrange work for graphics processing.
Transform geometryCalculations position vertices relative to the camera and projection.Similar mathematical operations apply across many vertices.
Determine image coverageRasterisation identifies fragments associated with projected geometry.Large numbers of candidate fragments can be generated and processed.
Shade and combineUse surface properties, textures, lighting and visibility rules to determine image values.Similar calculations are repeated across many fragments.
Produce a frameCompleted image data is stored for the display process.The GPU contributes to generating the image; the display presents it.

A fragment is a candidate contribution to an image pixel. It may be rejected, for example because another surface is in front of it. A fragment and a final displayed pixel are therefore not always the same thing.

Some rendering techniques trace rays through a scene to calculate visibility and lighting. You do not need the detailed algorithms here. In both cases, connect the GPU’s role to large numbers of related calculations, rather than describing it as a device that simply “makes graphics better”.

07 | THE GPU AND CPU WORK TOGETHER

In a game, the CPU may coordinate input, program decisions and the work that must be submitted for rendering. The GPU performs suitable graphics calculations. After the necessary processing and coordination, a completed frame can be presented. The responsibilities depend on the engine and implementation.

The CPU supplies or arranges access to the relevant data and issues work through software interfaces and drivers. A driver is software that allows the operating system and applications to communicate with hardware. The application must also know when results are ready to use.

Delegating work can have a cost. Moving data, launching processing and waiting for results all take time. For a tiny task, the time saved doing arithmetic may be smaller than the coordination overhead.

A basic understanding of cooperation is useful at SL and HL. The detailed architectural comparison between CPU and GPU is the separate HL objective A1.1.3. Here, focus on describing the GPU’s role and why particular workloads suit it.

08 | GPU, GRAPHICS CARD AND MEMORY

The GPU is the processing component. A discrete graphics card is a larger hardware assembly that can include a GPU, dedicated graphics memory, power circuitry and cooling. The GPU and the whole card are related terms, but not identical.

An integrated GPU is built into the same chip or processor package as other processing resources and typically uses shared system memory. A discrete GPU is a separate processing device and commonly has dedicated graphics memory, often called VRAM. Exact arrangements vary.

Graphics memory holds data such as textures, geometry and image buffers. General-purpose GPU workloads can instead use memory for numerical arrays and model parameters. Capacity describes how much can be held; bandwidth describes the rate at which data can move.

More memory alone does not guarantee a faster GPU. The workload, arithmetic resources, memory access, software and available power all affect performance. You should not use one specification as a universal measure of capability.

09 | ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING

Machine learning systems use numerical models whose parameters are adjusted using data. Many important operations involve vectors and matrices. A matrix is a rectangular arrangement of numbers; matrix operations involve many related arithmetic calculations.

During training, software repeatedly calculates model outputs, evaluates error and updates parameters. GPUs can accelerate suitable parts of that numerical work by processing many related calculations concurrently. Some designs also include specialised units for particular matrix operations.

Inference means using a trained model to produce an output, such as classifying an image. A GPU can also accelerate suitable inference workloads. Training and inference are different activities, and their hardware requirements depend on the model, precision, batch size and application.

The GPU does not “understand” an image merely because it carries out calculations quickly. The model, training data and software determine how the numerical results are interpreted. Some AI workloads run effectively on CPUs or other accelerators instead.

10 | LARGE SIMULATIONS AND OTHER USES

A simulation represents how a system behaves using a model. A weather model may divide an area into a grid of cells and repeatedly update quantities such as temperature or air movement. Many cells need similar mathematical operations, creating opportunities for GPU acceleration.

The cells are not necessarily independent for the whole simulation. A new value may require neighbouring values from an earlier stage, so software must exchange data and coordinate updates correctly. Parallel processing accelerates suitable work while respecting those dependencies.

Other examples include molecular modelling, image filtering, engineering simulation and scientific visualisation. Rendering a simulation’s picture is a different operation from calculating its physical behaviour; a GPU may assist with either or both.

In robotics, a GPU might help process camera images or train a vision model. This does not mean every sensor reading or simple motor-control decision should be sent to it. Identify the repeated numerical work before deciding the GPU’s role.

11 | DECIDE WHEN THE WORKLOAD FITS

WorkloadWhat makes it suitable or less suitable?A clear description
Brighten a large imageSimilar per-pixel work with independently calculated outputsMany pixel values can be processed concurrently.
Train a large neural networkLarge quantities of suitable matrix arithmeticGPU processing can accelerate the model’s numerical operations.
Update a scientific gridRepeated arithmetic with defined data dependenciesParallel updates and data exchange must be coordinated.
Follow a short chain of dependent decisionsLater steps need earlier outcomes; little independent workThe GPU’s large parallel resources may have little useful work.
Run a very small calculationLaunch and transfer overhead can outweigh arithmetic savingsGPU acceleration is not automatically worthwhile.

A GPU’s throughput is the amount of work it completes in a period of time. GPU architecture aims for high throughput on suitable workloads. That does not imply that every individual operation finishes sooner than on a CPU.

When describing suitability, use a chain of reasoning: the workload contains many similar calculations, these can be organised into parallel work, and the GPU has processing resources designed to carry out that work efficiently. Add a limit where relevant.

12 | COMMON MISUNDERSTANDINGS

MisunderstandingMore accurate statement
A GPU is only for connecting a monitor.It performs graphics processing and can run suitable non-graphics computations.
A GPU is faster for everything.Its benefit depends on the workload, software and coordination costs.
One pixel always needs one instruction.Generating a pixel can involve many operations and candidate fragments.
Every pixel on the screen is always processed at exactly the same moment.Work is scheduled in groups and batches across available resources.
GPU cores and CPU cores are directly interchangeable.The processing resources and terminology describe different designs.
More VRAM always means higher speed.Capacity and processing performance are different properties.
Simulation graphics and simulation calculations are the same task.Drawing the result and calculating the model are distinct workloads.

13 | BUILD A STRONG DESCRIBE ANSWER

For describe the role of a GPU, provide a clear account of what it does and how its characteristics support that role. Naming gaming, AI and simulation is useful, but the applications need an explanation.

For example: “A GPU carries out large amounts of suitable processing in parallel. During graphics rendering, it performs repeated calculations on geometry and image fragments to help generate frames. Its many arithmetic resources also support numerical tasks such as matrix operations used in machine learning.”

For a specific application, connect the role to that context: “A weather model repeats related calculations across a spatial grid. GPU processing can accelerate suitable updates, while the software coordinates the data dependencies between stages.”

Try describing two applications that do not involve drawing a game. For each, identify the data, the repeated calculation and why useful parallel work exists.

14 | CHECK YOUR UNDERSTANDING

Draw a simple three-stage diagram: application and CPU, GPU processing, then results. Annotate it for a game and again for a machine learning model. Which parts of the data and output change?

Use the image model to predict the round counts with one, four and eight workers. Then explain why those invented results are not evidence that a real GPU is exactly eight times faster than a CPU.

You are ready to move on when you can explain the connection between architecture and workload, rather than relying on “the GPU handles graphics”. Use the Questions tab to practise describing that connection in complete sentences.

Further reading: NVIDIA’s GPU programming guide · Simulation and modelling examples

MATCH THE GPU TERM TO ITS MEANING

Terminology

Terminology

GPU

A graphics processing unit designed for high-throughput parallel processing of suitable workloads.

Pixel

An individual picture element whose values describe colour or brightness.

Frame

One complete image in a sequence, such as a game’s next screen image.

Rendering

Generating an image from scene information or other image data.

Parallel processing

Carrying out suitable work simultaneously using multiple processing resources.

Data parallelism

Applying similar operations to different data items concurrently.

Thread

A sequence of execution scheduled as part of a processing workload.

Throughput

The amount of work completed per unit of time.

Vertex

A point used to define geometry in a scene.

Texture

Image data used to give a surface detail or appearance.

Shading

Calculating appearance using inputs such as surface properties and lighting.

Fragment

A candidate contribution to an image pixel during rendering.

Rasterisation

Determining image fragments associated with projected geometry.

Graphics card

A hardware assembly that can contain a GPU, memory, power circuitry and cooling.

Integrated GPU

Graphics processing resources integrated into a chip or processor package, typically sharing system memory.

Discrete GPU

A separate graphics processing device, commonly with dedicated memory.

VRAM

Graphics memory used to hold data for GPU work.

Memory bandwidth

The rate at which data can be transferred through a memory interface.

Matrix

A rectangular arrangement of numbers used in many numerical calculations.

Training

Adjusting a machine learning model’s parameters using data and an optimisation process.

Inference

Using a trained model to generate an output from new input.

Simulation

A computational representation of a system’s behaviour.

Driver

Software supporting communication with a hardware device.

Overhead

Extra work or time for activities such as arranging, transferring and coordinating processing.

Questions

Questions

CHECK YOUR UNDERSTANDING

Select all correct choices. Each exact set earns one point.

1. Which describes the GPU’s main strength?
2. Why can the brightness rule be parallelised?
3. Which statements about rendering are correct?
4. Which are suitable GPU uses when supported by software?
5. Which statements about GPU architecture are accurate?
6. What does memory bandwidth describe?
7. Which distinctions are correct?
8. Which statements about machine learning are correct?
9. Why might a tiny task fail to benefit from a GPU?
10. Which is the strongest description of a GPU’s role in a weather model?

EXPLAIN AND COMPARE

Write your answers before revealing each sample.

1. Describe the role of a GPU.

2. Describe how GPU architecture supports repeated image calculations.

3. Describe the GPU’s role in rendering a 3D game.

4. Describe how the CPU and GPU cooperate at a basic level.

5. Describe a use of GPU processing in machine learning.

6. Describe why a scientific simulation can suit GPU processing.

7. Distinguish a GPU from a graphics card.

8. Explain why a GPU is not automatically faster for every task.

9. Describe the difference between simulation calculation and visualisation.

10. Explain why the image model cannot establish a real CPU-to-GPU speed ratio.

APPLY IT | A ROBOT VISION SYSTEM

A robotics team wants to classify large batches of camera images using a trained model. Describe the GPU’s possible role, identify the repeated numerical work and give one condition that could limit its benefit. Keep model inference separate from training and simple motor-control decisions.

Flashcards

Flashcards

Click to flip. Select the ideas you need to revisit.

0 cards selected for revision.

    Selections are kept while this page is open.

    Workbook

    Workbook

    COMING SOON

    The workbook for A1.1.2 Role of a GPU is coming soon. Complete the matching task and written questions in your exercise book.