CPU vs GPU (What's the Difference) - Computerphile

The Digital World: Understanding Graphics Processors and Their Role in 3D Rendering

In today's digital world, everything is made up of ones and zeros, adding and subtracting. However, when it comes to processing three-dimensional images, things become more complex. A graphics processor is a specialist processor designed to make this process more efficient than other forms of processors.

A Graphics Processor: Efficiency Through Specialization

A graphics processor takes a very specialized workload and executes it much more efficiently than other processors. This is because the tasks involved in 3D rendering require a high degree of precision and speed, which is where the graphics processor comes into play. Unlike central processing units (CPUs), which are general-purpose processors that handle multiple tasks, graphics processors are specifically designed to handle 3D rendering.

The Fundamental Differences Between Central Processing Units and Graphics Processors

So, what are the fundamental differences between a central processing unit and a graphics processing unit? At their core, both CPUs and GPUs are executing commands to display pixels on screens. However, the nature of these commands is vastly different. A CPU executes commands that say "put this pixel at this location," whereas a GPU executes commands that say "put this pixel here" with specific color information.

A 3D Model: Breaking Down Complexities

When it comes to rendering 3D models, things can get quite complex. Imagine a scene with multiple objects, each with its own set of coordinates and attributes. The geometry of the scene is usually broken up into triangles because triangles are simple and easy to work with. Triangles have three points, always, and never appear as non-flat surfaces. By dividing complex surfaces into triangles, we can simplify the rendering process.

Adding Color Information: Textures

Once we have our triangle-based model, we add color information in the form of textures. These textures provide the necessary details to make each object look like its intended self. The more detailed the texture, the more accurate the rendering will be. By combining geometry and color, we're one step closer to creating a realistic 3D image.

Lights and Shadows: The Next Step

With our model and colors in place, it's time to introduce lights into the scene. Lights shed light in specific directions, which means that certain areas of the model will receive more or less illumination than others. By taking this into account, we can create a more realistic representation of the world.

The Camera: Focusing on the Scene

Now that we have our lights and model set up, it's time to introduce a camera into the scene. The camera is used to view the rendered image from a specific perspective, which means that only certain parts of the scene are visible. By using 3D geometry, we can determine what parts of the scene will be visible to the viewer.

Projecting onto a 2D Screen

Once we've calculated the visible parts of the scene, it's time to project them onto a 2D screen. This is where floating-point numbers come into play, as they're used to represent the precise position and color of each pixel. By using these calculations, we can create a detailed and accurate image that represents our 3D model.

Matrix Arithmetic: The Math Behind It All

The math involved in rendering 3D images involves a lot of matrix arithmetic. This is because we need to solve equations that determine which parts of the scene will be visible from a specific viewpoint. Matrix solving is crucial here, as it allows us to break down complex problems into manageable parts.

Parallel Processing: Efficiency Through Parallelism

One of the key differences between graphics processors and CPUs lies in their approach to parallel processing. While CPUs execute tasks sequentially, graphics processors can handle multiple tasks simultaneously due to their specialized design. This means that a graphics processor can perform many calculations at once, which is essential for rendering complex 3D images.

In conclusion, the world of digital graphics is all about 3D rendering. A graphics processor plays a critical role in this process by executing highly specialized commands that require precision and speed. By breaking down complex scenes into triangles, adding color information, introducing lights and shadows, using cameras to view the scene, projecting onto a 2D screen, and performing matrix arithmetic, we can create highly detailed and accurate images that represent our digital world.

"WEBVTTKind: captionsLanguage: enAnd a graphics processor is a specialist processorthat is designed to make processing of three-dimensional imagesmore efficient than other forms of processor.It is a digital world. It's all 1s and 0s, adds and minuses.And if you do lots of adds, you can turn it into a multiply.But actually, a graphics processor takes a very specialist workloadand does it much more efficiently.What are the fundamental differences between a central processing unitand a graphics processing unit?Well, fundamentally, we're here to put pixels on screens.So, at the end of the day, we are here to execute some commands whose purpose isto say that pixel on that screen is that color.And usually that's presented to us as: Here's some data.So, usually there's a three-dimensional model.So, in front of us is a table. There's a circle which is a few feet off the groundand it's X thickness and it's got some legs and it's at this position.There's some chairs in the room. There's me, there's the walls all around.There's a three-dimensional model. So, first of all, you get given a bunch of coordinatesand say the following things are at the following places.And then you say give them some more data, which is the chair's a lilacand the table's a sort of sludgy grey, and so it's fine.And so you get given some color information, which is what we call textures.The geometry of the scene is usually broken up into trianglesbecause triangles is nice and simple. We're very simple people. We can't cope with complicated stuff.A triangle, three points, always has to be flat. You've never seen a triangle that isn't flat.And so you divide complex surfaces up into triangles and then you have some informationabout what colors those triangles are.So you say, right, okay, I've got the geometry. I've got the color.What do we do next? Well, you put some lights in the scene.So there's some lights in the ceiling which are shedding some light in certain directions.And then you need a camera. So you say the camera is here.So now you have to do some three-dimensional geometry to saywell, what does it look like in the camera? And the first thing you observe iswell, about half the room, you can't see. Phew, that's good.So, I don't have to calculate everything that's behind you.The only thing that I have to calculate are the bits you can see.And you project it so that it goes into the two-dimensional screenAnd this it what it looks like.And then you move the camera around, usually, to get sort of a real impressionof moving through the scene. So, there's a lot of different types of calculationinvolved in that. First is loads and loads and loads of three-dimensional matrix arithmetic.You know, XYZ coordinates, sometimes four-dimensional arrays withXYZ and transparency information. And lots and lots of RGB, red, green, blue, color.So, a device that's really, really good at matrix arithmetic is a good start.Floating point, because the position of all of these things are usually expressed as floating point.And then finally, you've got this unit in the back which says, oh well, I've got lots and lots of pixelsto deal with, so we need to run through that and get them all into a buffer in memory.So, some of that's really quite different from a CPU. A lot of three-dimensional plane equations have to be solved.So, for example, here's the table, here's the floor. Well, which bits of the floor and which bits of the tablecan I see? So you have to do a lot of matrix solving to work that one out.And that's the difference in the problem that gets given to us, right?The difference in the design is: We say, well actually, I can do loads of this in parallelActually, I can do a lot of these quick calculations in parallel because they don't depend on each other.So, every time you hear the phrase, \"For every vertex in the geometry, do blah.\"\"For every pixel in the screen, do foo.\" You can actually say, well actually, that's a million pixels.I can actually calculate them in batches of 256 or something like that.So, we extract the parallelism out of the algorithm, and we design a processor thatis actually very good at parallel processing. So the difference between a CPU and a GPUpredominately is, yes, there's some really, really fixed function blocks which we do very, very efficientlycompared to a CPU, which does everything itself. But also, we are very, very good at extracting parallelism.So, if I want to multiply three floating point numbers together, I'll do it more slowly than a CPU.But if you ask me to multiply a million three floating point numbers together,then the length of time it takes me to do a million will be a lot shorter than the time it takes a CPU to do a million.So, we don't care so much about how long anything individually takes.What we work on is the bulk throughput, and it's a different end to the problem.And of course, there are blurred areas, and some people are now sayingWell, actually there's some sort of computing I could do that would do better on a GPUthan on a CPU. And so you get this whole thing called GPU computing coming alongwhere people are not actually doing graphics, but they're doing throughput computing.And actually, that's been quite interesting hearing.I think one of the ones that somebody suggested was people doing Bitcoin mining with GPUsbecause it's just lots and lots of maths.Yes. But also, image processing. So, in modern devices, you tend to have quite a poor lens,or a poor sensor, and you're trying to take pictures that are as good as that camera you're holdingin your hand that costs thousands. And actually, that takes an awful lot of image cleanupSo, there's an awful lot of computing that's taking place on those digital images.And it turns out that actually a lot of those go quite well when executed on GPUs,not executed on CPUs.Can it fix my bad focusing as well?That is coming, that is coming.\n"