You are not logged in.

#1 2010-08-12 15:53:06

Chiil
Member
Registered: 2009-07-27
Posts: 12

Strange behaviour OpenMP

Currently I am running an application that makes use of openmp. Strange enough, if I specify the program to use 4 threads the execution time is either approximately 30s or 1m. It seems therefore that even though the cores run all at 100%, only two are used. There is no indication what makes the run go fast or slow, and if I perform a series of 10 runs, approximately half of them go in 30 sec and half of them in 1 minute.

On other machines, but with the same compiler, I do not have a problem. Is there something that could be related to the scheduling of the threads on my Linux machine?

Offline

#2 2010-08-12 16:17:00

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: Strange behaviour OpenMP

One thing I'd check is if your CPU frequency has been scaled down during the slow runs, by cpufreq or what have you.  Other than that, it's hard to diagnose without a code sample.

Offline

#3 2010-08-12 16:24:31

Chiil
Member
Registered: 2009-07-27
Posts: 12

Re: Strange behaviour OpenMP

The code is a CFD code solving the Navier-Stokes equations. It are basically only parallel for loops. But if it was a programming error, the code should be consistently slow, right?

Offline

#4 2010-08-12 16:26:41

olvar
Member
Registered: 2009-11-13
Posts: 97

Re: Strange behaviour OpenMP

Assuming the code doesn't do anything funny, like waiting for the other threads or such, nothing else is running in the background unnoticed and your app is not IO intensive: may be you are using cpufreq or other app for scaling your cpu frequency. For example, I use cpufreq with the ondemand governor, so normally my cpu runs half the top frequency. When on heavy use the governor makes the cpu go back to top, but it is not immediate, which could explain for some of the delay.

Offline

#5 2010-08-12 16:56:44

Chiil
Member
Registered: 2009-07-27
Posts: 12

Re: Strange behaviour OpenMP

I use it on a desktop pc where the scaling is always at performance. I checked it and the CPU is always at its maximum frequency.

Offline

#6 2010-08-12 17:35:38

olvar
Member
Registered: 2009-11-13
Posts: 97

Re: Strange behaviour OpenMP

Could you try with some other multithread app? If the problem is also present there, there could be something wrong with your cpu? maybe overheating, which is never the less unlikely, due to the short time your calculations takes. But I don't know what else could be.

Other things that may help, could be to print the time used per thread, to see if all of them are using the same time for the calculations. I guess you are always using the same initial conditions, but maybe you are running in a chaotic regime which due to rounding errors can converge to two different solutions?? If that's possible, I suggest trying an easier case, where such behaviour is not possible.

Edit: for the same reason try to avoid "picky" loop terminations and such.

Last edited by olvar (2010-08-12 17:37:09)

Offline

#7 2010-08-12 19:04:03

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: Strange behaviour OpenMP

Chiil wrote:

The code is a CFD code solving the Navier-Stokes equations. It are basically only parallel for loops. But if it was a programming error, the code should be consistently slow, right?

Well, I can write a programming error that does any number of things smile

Anyway, the first step is always to try it on another machine, to see if it's your computer or your code.  I'm offering mine because I know it's set up right.  Also I have a reasonable amount of experience with multithreaded algorithms, although not with OpenMP exactly.  But I'd need to see the code, or if its license prohibits that, a minimal example that reproduces the problem.

Regardless, let us know if you win the million bucks wink

Offline

Board footer

Powered by FluxBB