2

How does gcc determine the best number of threads if one sets omp_set_dynamic(1)? OpenMP leaves it implementation defined, but I would love to know how gcc implements it.

Thanks!

1 Answer 1

4

GCC implements OpenMP using the libgomp runtime library. It's part of the compiler and its source code is freely available under the same GPL license as used by GCC. You can either download some point release of GCC and examine the libgomp folder or you can browse the source code online. This links is for the latest stable version of GCC 4.8.3. Starting with GCC 4.9, libgomp implements OpenMP 4.0 features and that makes the source code harder to understand.

The logic for implementing dynamic number of threads is to be found in gomp_resolve_num_threads() in parallel.c. Basically it only supports dynamically setting the number of threads for the parallel sections combined construct and tries to set the number of threads in the team equal to the number of distinct sections inside the construct.

Sign up to request clarification or add additional context in comments.

Comments

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.