Skip to content
Snippets Groups Projects
Commit 2933b705 authored by Conor Finn's avatar Conor Finn
Browse files

RE #27582 Make config threads compiler dependent

Windows devices have been running into issues in places where calling
the functions created to fix an issue on Unix machines in parallel
regions was causing error messages to  appear.

This is due to changes in implementation of omp_set_num_threads between
OpenMP v2 and v2.5+. As MSVC uses the older version of OpenMP I have
added a check that does not bother with the changes from the previous
fix if compiled with MSVC, as the original issue only appeared on non
MSVC compiled versions anyway.
parent d2228c62
No related branches found
No related tags found
No related merge requests found
...@@ -85,8 +85,12 @@ void AtomicOp(std::atomic<T> &f, T d, BinaryOp op) { ...@@ -85,8 +85,12 @@ void AtomicOp(std::atomic<T> &f, T d, BinaryOp op) {
// GCC // GCC
#ifdef _MSC_VER #ifdef _MSC_VER
#define PRAGMA __pragma #define PRAGMA __pragma
#define PARALLEL_SET_CONFIG_THREADS
#else //_MSC_VER #else //_MSC_VER
#define PRAGMA(x) _Pragma(#x) #define PRAGMA(x) _Pragma(#x)
#define PARALLEL_SET_CONFIG_THREADS \
setMaxCoresToConfig(); \
PARALLEL_SET_DYNAMIC(false);
#endif //_MSC_VER #endif //_MSC_VER
/** Begins a block to skip processing is the algorithm has been interupted /** Begins a block to skip processing is the algorithm has been interupted
...@@ -136,8 +140,7 @@ void AtomicOp(std::atomic<T> &f, T d, BinaryOp op) { ...@@ -136,8 +140,7 @@ void AtomicOp(std::atomic<T> &f, T d, BinaryOp op) {
* code to be executed in parallel * code to be executed in parallel
*/ */
#define PARALLEL_FOR_IF(condition) \ #define PARALLEL_FOR_IF(condition) \
setMaxCoresToConfig(); \ PARALLEL_SET_CONFIG_THREADS \
PARALLEL_SET_DYNAMIC(false); \
PRAGMA(omp parallel for if (condition) ) PRAGMA(omp parallel for if (condition) )
/** Includes code to add OpenMP commands to run the next for loop in parallel. /** Includes code to add OpenMP commands to run the next for loop in parallel.
...@@ -145,8 +148,7 @@ void AtomicOp(std::atomic<T> &f, T d, BinaryOp op) { ...@@ -145,8 +148,7 @@ void AtomicOp(std::atomic<T> &f, T d, BinaryOp op) {
* and therefore should not be used in any loops that access workspaces. * and therefore should not be used in any loops that access workspaces.
*/ */
#define PARALLEL_FOR_NO_WSP_CHECK() \ #define PARALLEL_FOR_NO_WSP_CHECK() \
setMaxCoresToConfig(); \ PARALLEL_SET_CONFIG_THREADS \
PARALLEL_SET_DYNAMIC(false); \
PRAGMA(omp parallel for) PRAGMA(omp parallel for)
/** Includes code to add OpenMP commands to run the next for loop in parallel. /** Includes code to add OpenMP commands to run the next for loop in parallel.
...@@ -155,13 +157,11 @@ void AtomicOp(std::atomic<T> &f, T d, BinaryOp op) { ...@@ -155,13 +157,11 @@ void AtomicOp(std::atomic<T> &f, T d, BinaryOp op) {
* and therefore should not be used in any loops that access workspace. * and therefore should not be used in any loops that access workspace.
*/ */
#define PARALLEL_FOR_NOWS_CHECK_FIRSTPRIVATE(variable) \ #define PARALLEL_FOR_NOWS_CHECK_FIRSTPRIVATE(variable) \
setMaxCoresToConfig(); \ PARALLEL_SET_CONFIG_THREADS \
PARALLEL_SET_DYNAMIC(false); \
PRAGMA(omp parallel for firstprivate(variable) ) PRAGMA(omp parallel for firstprivate(variable) )
#define PARALLEL_FOR_NO_WSP_CHECK_FIRSTPRIVATE2(variable1, variable2) \ #define PARALLEL_FOR_NO_WSP_CHECK_FIRSTPRIVATE2(variable1, variable2) \
setMaxCoresToConfig(); \ PARALLEL_SET_CONFIG_THREADS \
PARALLEL_SET_DYNAMIC(false); \
PRAGMA(omp parallel for firstprivate(variable1, variable2) ) PRAGMA(omp parallel for firstprivate(variable1, variable2) )
/** Ensures that the next execution line or block is only executed if /** Ensures that the next execution line or block is only executed if
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment