Author Topic: CPU FAQ  (Read 3292 times)

2017-07-04, 17:30:36

Ryuu

  • Corona Team
  • Active Users
  • ****
  • Posts: 542
  • Michal
    • View Profile
What is a thread?
In the context of computing, a thread is a piece of executable code with its own state. Apart from maintaining its own state (private data), each thread can also access global data shared by all threads belonging to the same application (process).
 
For example in Corona we launch as many threads as you have CPU cores and instruct the OS to run each thread on a different CPU core. This way all the threads run in parallel at once. The private data of the thread is the ray this thread is currently tracing, while the shared data is the scene, textures, etc.
 
What exactly does 100% usage in Windows task manager mean?
This number only says that some threads are scheduled by Windows to be executed on all CPU cores 100% of the time. It does not tell you how much of the physical execution resources on the CPU are actually utilized.
 
How is it possible that there is code being executed 100% of the time and the CPU is not fully utilized?
Modern CPUs have many execution units specialized for different tasks. Most applications are able to utilize only some portion of these units at any given time. For example MS Word doesn't need to do much floating point calculations, so the floating point execution units just sit idle when the CPU is running Word.
 
Even if the application was able to keep all the execution units fully utilized, it may not be able to feed them with data fast enough. Modern CPUs are a few orders of magnitude faster than modern RAM, so when the CPU is able to process the data faster than the memory is able to supply it, the CPU will end up waiting for the data most of the time.
 
Is there any way to run a different piece of code on the idle execution units?
Yes, this technology is called SMT (Symmetric MultiThreading). Intel calls their implementation of this technology HyperThreading. With this technology, a single physical CPU core executes two or more threads at once.
 
Unfortunately, unless the simultaneously running threads have vastly different computation requirements, they’ll end up competing for the same execution units most of the time. In normal circumstances, running two threads on a single physical CPU core gives 10%-20% performance boost over running just a single thread.
 
Why is my CPU temperature higher/fan louder during the denoising compared to the rendering?
The memory access pattern of the rendering code is very random - for example, each ray may hit a completely different object. This makes it very hard for the CPU to predict which parts of the memory will be accessed next, and in the end the CPU ends up waiting for data to be fetched from memory most of the time.
 
When the image is denoised, it is accessed sequentially one pixel at a time. Also the processing of each pixel takes long enough so that the CPU is able to read the next pixel from memory before it is needed. This is a best case scenario for the CPU - it does not have to wait for memory, and the execution units are (almost) fully utilized.
 
When the execution units sit idle waiting for memory, the CPU is able to optimize its energy consumption (and therefore heat generation), but when the denoising kicks in, the CPU units are kept busy all the time and so the temperature goes up.

2017-07-04, 17:31:51
Reply #1

Ryuu

  • Corona Team
  • Active Users
  • ****
  • Posts: 542
  • Michal
    • View Profile
Since we kept answering the same questions all over again, here's a simple FAQ. Let us know if something isn't clear enough, anything that needs more/less detail, etc.

2017-07-05, 14:08:16
Reply #2

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 8539
  • Marcin
    • View Profile