0

I am using Ubuntu 14.04 x64 on a machine with Intel Xeon CPU. and I am experiencing an strange behaviour. I have a Fortran code and a lengthy part of the calculation is parallel with OpenMP. With a smaller data set (say less than 4000) everything works fine. However, when I test a data set with 90K elements, in the middle the calculation the number of threads used suddenly drops to 1 which obviously slows down the computation.

I did these checks already: Using OMP_GET_NUM_THREADS() I monitor the number of threads during the process and it ramains the same even after system uses 1 thread.

I use a LAPACK routine for eigen value calculation inside the loop. I compiled the Lapack again on my system to make sure the libraries on my system do not do anything.

Can it be that the System changes the number of used threads from outside? If so why? Thank you.

4
  • Do you call omp_set_num_threads anywhere? Commented Nov 24, 2014 at 7:42
  • 1
    Tt looks like a load balancing problem. Try with a dynamic scheduling : `!$OMP PARALLEL SCHEDULE(DYNAMIC) Commented Nov 24, 2014 at 8:28
  • @Anthony, Thank you. This fixed it. I think the nature of my input data made this happen. Commented Nov 24, 2014 at 13:26
  • OK, great! so I put it as an answer then. Commented Nov 24, 2014 at 17:20

1 Answer 1

2

It looks like a load balancing problem. Try with a dynamic scheduling :

   !$OMP PARALLEL SCHEDULE(DYNAMIC)
Sign up to request clarification or add additional context in comments.

1 Comment

You could elaborate on why this is solving the problem. E.g. mention that if the processing time of the input data (as mentioned in the Q comments) is not uniform, then threads will not finish at the same time and in particularly bad cases, one thread may persist much longer than the others. Dynamic scheduling allows threads to be better scheduled to handle uneven loads.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.