Skip to content

Commit a6bfe60

Browse files
committed
OmpSystem: cap ompMaxThreads to 4 in MinGW build
1 parent dc586db commit a6bfe60

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

src/engine/framework/OmpSystem.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,35 @@ void SetupThreads()
7272
}
7373
else
7474
{
75+
/* Only GCC and Clang on Linux and MinGW have been tested for performance yet,
76+
We currently not enable OpenMP in releases on other systems yet. */
77+
#if defined(__MINGW32__)
78+
/* On Windows with a MinGW build, using all available threads is known to
79+
work best with:
80+
81+
- 4 threads on low-end 4-cores (no SMP) Ryzen 3 3200G.
82+
83+
It has not been tested yet on a Windows system where ompMaxThreads > 4.
84+
85+
At least on Wine over Linux, using a few amount of threads is known to work
86+
best with:
87+
88+
- 4 threads on high-end 16-cores/32-threads Ryzen Threadripper PRO 3955WX.
89+
90+
Performance regression has been observed above 4 threads on Wine on Linux. */
91+
static constexpr int threadDivisor = 1;
92+
static constexpr int threadCap = 4;
93+
#else
94+
/* On Linux, using half threads than available is known to work best with:
95+
96+
- 2 threads on low-end 4-core (no SMP) Ryzen 3 3200G,
97+
- 16 threads on high-end 16-cores/32-threads Ryzen Threadripper PRO 3955WX.
98+
99+
It has not been tested yet on a system where ompMaxThreads / 2 > 16. */
100+
static constexpr int threadDivisor = 2;
101+
static constexpr int threadCap = 16;
102+
#endif
103+
75104
switch( ompMaxThreads )
76105
{
77106
case 1:
@@ -82,12 +111,7 @@ void SetupThreads()
82111
ompThreads = 2;
83112
break;
84113
default:
85-
/* Using half threads than available is known to work best with:
86-
- 2 threads on Low-end 4-cores (no SMP) Ryzen 3 3200G,
87-
- 16 threads on High-end 16-cores/32-threads Ryzen Threadripper PRO 3955WX
88-
89-
It has not been tested on a system where ompMaxThreads / 2 > 16. */
90-
ompThreads = std::min( ompMaxThreads / 2, 16 );
114+
ompThreads = std::min( ompMaxThreads / threadDivisor, threadCap );
91115
}
92116
}
93117
#endif

0 commit comments

Comments
 (0)