OpenMP® Forum

Discussion on the OpenMP specification run by the OpenMP ARB. OpenMP and the OpenMP logo are registered trademarks of the OpenMP Architecture Review Board in the United States and other countries. All rights reserved.

When I compile and run this on Linux, it behaves as expected. As I add threads, more cores on my multi-core machine are used. If I use "top" to look at cpu utilization, I'm at 100%, until the program runs its course. I then add a sleep inside the for loop to slow down the processing. I do this to simulate a period task that requires a lot of cpu, but only at some specified interval. Now the code looks like this:

If "DoSomethingCpuIntensive()" takes 20 msec to complete, and I then sleep for 20 msecs, I'd expect the cpu utilization to drop to about 50% since I'm only doing work about half the time. But, that is not the case. Cpu stays near 90%. If I run this same simple code on Windows, and look at the TaskManager - cpu does indeed track down as I would expect. Linux (Red hat enterprise 4) seems to be the odd man out. I should mention that I am using versio 10.1.017 (and compile specifying -openmp on the command line) of the Intel compiler for these simple tests. Also note that If I run this single threaded, it behaves as expected; i.e. adding sleeps reduces overall cpu utilization. Any insight to why this is happening?

Are the Linux and Windows machines using the same type of CPU? What is the refresh rate on top? I believe the default is on the order of tenths of a second - meaning that it might not be seeing the decrease in utilization.

I believe that the Intel implementation keeps the threads around after the parallel region so that it does not have to go through the process of getting them again for a new region. I would think that they would be "sleeping" while not in use, but it is possible that they are looking for more work. Maybe someone from Intel can address this.