تفاوت CPU با GPU؛ هر آنچه باید بدانید


If we want to express the difference between CPU and GPU in simple terms, we should say that CPU or Central Processing Unit is considered the central processor of a device and GPU or Graphics processing unit is a graphics processor for graphics processing. Difference between CPU and GPU CPU manages all the processing operations of a device. Simply put, the CPU acts as the brain of the computer. GPU is everything you see on your device’s screen; processes The CPU in all devices is designed as a separate processor and works independently; But the GPU is a separate processor in some devices, and in some other devices it is integrated into the CPU and is considered a part of it; Of course, the processing power of the graphics processor integrated in the CPU is much less than the processing power of the separate processor. Therefore, if you want to run graphics-heavy games with your computer or use some graphics-heavy software such as 3D modeling software, you should use a separate GPU. It should be noted that there is also a processor called GPU accelerator, which is actually a processor to enhance GPU performance and processes visual data. The structure of CPU and GPU is completely different in desktop devices and mobile devices. CPUs used in mobile devices are very small and low-power hardware; But in some supercomputers, there is a wide network of several CPUs that are capable of performing very complex and heavy computing activities that require very high processing power, and if they are done with mobile CPUs, they will explode in just a few minutes. they destroy Discrete GPUs are usually found only in powerful consoles and computers and laptops designed for heavy graphics work (such as 3D rendering and professional video editing) and heavy gaming. It should be noted that discrete graphics processors are also used for mining digital currencies and applications related to machine learning. The main differences between CPU and GPU are as follows: CPU has task parallelism and GPU has data parallelism. In other words, CPU can perform many processing activities by its processor units at the same time. GPU can also execute the same instruction repeatedly and simultaneously at high speed for different data. CPU has a small number of cores with high processing power; But the GPU is a large number of cores, which are much smaller compared to the CPU cores, and when the processing activities related to the task are divided among them, they perform those distributed processing activities together at high speed. The CPU memory has a large capacity; But the GPU memory has a high bandwidth and can read the entered information at a high speed. In the CPU, a large number of instruction sets are created and distributed among the different processing units of this hardware; But on the GPU, fewer instruction sets are created and instead they are heavily optimized. Comparison of how CPU and GPU work Undoubtedly, the main difference between CPU and GPU is how they work. A CPU performs processing activities sequentially and serially. This hardware has different processor units, each of which is designed to perform specific processing operations, and the CPU divides the processing tasks between them to achieve the best possible performance. At the same time, modern CPUs consist of several cores, each of which undertakes a part of the processing activities being performed by the CPU. Most CPUs have 4 to 8 cores. When the CPU is working, each of its cores performs a processing activity separately. In fact, the tasks or tasks that you see in the task management or task manager section of your computer are either being performed by the CPU cores or are in the queue to be performed by these cores. In simple words, the CPU distributes the total processing power of its cores to perform different processing activities and switches between different processing activities at a high speed; Of course, the CPU does not have the necessary processing power to perform heavy graphics processing such as processing operations related to 3D graphics, and to do this, the GPU must be used. The processing method used by GPU is different. When a task is assigned to this processor to be processed, the processor divides it into thousands of very small tasks and processes them all at the same time. For example, imagine that what you see in a game is basically an area made up of a number of polygons. Naturally, to create the game environment and its different parts, these polygons must be filled with items and graphic elements. Each of these polygons is filled by the GPU separately and simultaneously. Considering that there may be thousands of polygons in a game environment and all of them must be processed and filled at the same time in a very short time, the GPU must be very fast to do this. If this processor is not able to process polygons in a suitable time, the result of this problem will be revealed on the screen and unprocessed textures and polygons will appear in the game environment, which is not a pleasant experience for gamers. Difference between CPU and GPU architecture The difference between CPU and GPU is clearly evident in the architecture of these two hardwares. As we said, the CPU processes data and tasks received for processing sequentially and at a very high speed. The high clock speed of the cores allows them to perform high-speed processing. The CPU is highly optimized in terms of reducing latency in performing activities and therefore can switch between ongoing processing activities at a very high speed. This CPU structure has made it quite successful in the field of processing and parallel computing, even though this hardware is basically created to perform one processing activity at a time. GPU has many cores which are much more than CPU cores. The instructions intended for these cores are optimized to perform dimensional matrix related calculations as well as floating point calculations. GPU memory also has a wide interface, which by creating a point-to-point connection increases memory bandwidth and increases its speed in performing processing activities. At the same time, the memory of this hardware is also designed for fast manipulation of large parts of data. If you want to get to know the architecture and anatomy of CPU and GPU in a more specialized way, we recommend reading the two articles “CPU Anatomy” and “Graphic Card Anatomy” by Digiato; Of course, it should be noted that a graphics card is different from a graphics processor, and a graphics processor or GPU is actually a part of a graphics card. Comparison of CPU and GPU limitations Another thing that makes the difference between CPU and GPU is the limitations of these two hardwares. First of all, we must say that CPU and GPU limitations have made CPU suitable for some processing activities in some cases, and in other cases, the use of a graphics processor can better meet our needs. The modern trend in processor design is to push heavy instructions into the CPU, but this trend is not without flaws. The CPU sometimes switches rapidly between hundreds of clock cycles to perform heavy instructions. Although Intel has reduced this limitation by using instruction pipeline technology and has been able to design its processors so that none of the instruction processing sections remain idle and at the same time as an instruction is processed in one of the five instruction processing sections, the instruction the other is being processed in one of the other departments; But again, the simultaneous processing of heavy and complex instructions causes a drop in CPU performance. Delay in the switch refers to the delay in the switch (switch latency or context switch latency), in fact, it is the time required for the CPU core to switch between threads. Switching between threads is a very slow process; Because the CPU must save the registers and state variables, empty the cache and perform other cleanup activities to do this. Although in the design of modern CPUs, efforts have been made to solve this problem by dividing the state of the task being processed, and to reduce the amount of delay when performing several tasks, but the amount of delay is still not acceptable. Moore’s Law Moore’s Law, which states that the number of transistors per square inch of integrated circuit surface doubles every two years, is being forgotten. There is definitely a limit to increasing the number of transistors on a piece of silicon and the laws of physics cannot be denied! Of course, hardware design engineers try to increase the computing power and efficiency of processors with the help of distributed computing method. Also, these people are testing and investigating the capabilities of quantum computers and are even looking to find an alternative to silicon for making CPUs. Limitations of GPU having less number of powerful cores compared to CPU Although the number of GPU cores is more than CPU cores, but their power in terms of clock speed is less than CPU cores. Meanwhile, GPU cores process a smaller variety of instructions and are designed to process more specific instructions; Of course, this feature is not inherently a bad feature; Because GPUs are very efficient for processing a small set of tasks. Comparing the number of CPU cores with GPU cores having less memory The memory capacity designed for GPUs is limited. Although GPUs perform better than CPUs in terms of moving to a larger volume of information at a given moment; But the delay in accessing its memory is much higher than the delay in accessing CPU memory. Having a limited application programming interface (API) Open CL and Cuda are the most well-known GPU application programming interfaces, whose bugs are hard to fix, and these two APIs are famous for having this big flaw. Although OpenCL is open source; But it runs very slow on Nvidia hardware; Of course, at the same time, it is Nvidia’s exclusive API and is optimized for this company’s graphics processors. Advantages of using GPU over CPU Overall GPU has more processing power compared to CPU and is more efficient hardware. In addition to being necessary for doing heavy graphics work and running heavy graphics games, the use of GPU is also much better compared to the use of CPU in areas such as mining digital currency and benefiting from artificial intelligence capabilities. Graphics processors, which are part of graphics cards, are much better than CPUs for mining digital currencies due to having a series of processor units called Arithmetic logic units, which are specially designed to perform mathematical calculations. The use of graphics card for digital currency mining has increased so much that it has caused its shortage. The use of GPU is also necessary for applications related to machine learning technology, also known as deep learning; Because when using machine learning technology, a large amount of data must be processed, which requires a large amount of processing activities to be performed at the same time, and the efficiency of the graphics processor in this field is very high. Using a graphics card for activities related to benefiting from artificial intelligence capabilities, compared to using a CPU for this work, also has a much better result. Among these activities, we can mention opinion mining (obtaining information about people’s opinions and attitudes on various issues in order to make better decisions), financial forecasts, and image processing. Advantages of using CPU over GPU Although using GPU has many advantages over using CPU; But it is not possible to use the GPU as a central processor; Because, as we said, this processor performs processing activities simultaneously, and if such a processor is used in computers, we will not see good performance from them. For example, if the GPU is used as the central processor in computers, it will be difficult to divide some processing activities such as the processing related to writing an article on the computer and running the browser. In contrast, the CPU has the ability to process tasks sequentially and one after the other, which makes this processor a suitable central processor. In addition, although it is possible to divide the processing power of the CPU between only a few tasks; But on the other hand, it processes and performs several tasks at a high speed. Frequently asked questions about the difference between CPU and GPU What is the difference between CPU and GPU? The main difference between CPU and GPU is that the CPU is considered the central processor and performs various processing activities related to various tasks; But the GPU is dedicated to graphics processing. Can CPU be used as GPU? If the CPU has a built-in integrated GPU, it can be used to do some simple and not too heavy graphics processing. How is information processed in CPU and GPU? CPU performs processing activities sequentially and sequentially, but GPU performs a large number of processing activities simultaneously with its multiple cores after dividing them into smaller parts.

دیدگاهتان را بنویسید