The easiest way to simulate maximum processor load?

I need to test the embedded computer for the most extreme conditions of heat and current generated, and for this I want to write a program that actually uses the CPU resource as a quad-core processor (one thread per core). Can you suggest something that would be a very greedy processor?

I have to do this for Linux on ARMv7, and the language is C or C ++, the other examples I found are either for Windows or not for C / C ++.

I am trying to do something like this on my Windows computer and it seems to work, since it occupies 12% of the total processor power (this is i7 quad core 2 threads per core):

float x = 1.5f; while (1) { x *= sin(x) / atan(x) * tanh(x) * sqrt(x); } 

I do not know how to do this multithreaded.

+6
source share
3 answers

Your code is serial. You have eight available threads (4 cores * 2 threads per core = 8 shared threads), and your current code uses one of them for 1 thread / 8 available = 12.5% your CPU. If you need to write your own code (and not use the existing intensive code, as others have already suggested), I would recommend putting #pragma omp parallel above your while and compiling with the -fopenmp flag (if you use MinGW, if not, then the exact option may vary) to use all available streams instead.

+4
source

It depends a little on what you mean by "maximum CPU utilization."

Regarding CPU usage, basically everything will work. Just keep in mind that you will need as many threads (or as many instances of the executable) as your processor has kernels.

However, you need to keep in mind that CPU utilization is not universal and final for energy use in SoC. Other aspects you need to consider:

  • Access to memory. The application you are currently using does not concern memory at all.

  • Other peripherals such as flash controllers, SPI / I2C / UART drivers, etc.

  • GPU if your SoC includes one. (This will easily overshadow the energy use of everything that I mentioned so far!)

  • Off-die peripherals: flash, memory, display, chargers, everything else on your device.

+2
source

Does it need to be your own program? You can always just take some existing code that burns many cycles, such as raytracer or bitcoin, and run a few of them.

0
source

Source: https://habr.com/ru/post/980444/


All Articles