Skip to content

Commit 13f01b3

Browse files
committed
engine: initialize Omp
1 parent 84382ea commit 13f01b3

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

src/engine/framework/Omp.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,20 @@ void SetupThreads()
8181
#endif
8282
}
8383

84-
void Init()
85-
{
86-
ReadMaxThreads();
87-
SetupThreads();
88-
}
89-
90-
void ApplyThreads()
84+
void EnlistThreads()
9185
{
9286
#if defined(_OPENMP)
9387
omp_set_num_threads( ompThreads );
9488
#endif
9589
}
9690

91+
void Init()
92+
{
93+
ReadMaxThreads();
94+
SetupThreads();
95+
EnlistThreads();
96+
}
97+
9798
int GetThreads()
9899
{
99100
return ompThreads;

src/engine/framework/Omp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333

3434
namespace Omp {
3535
void SetupThreads();
36+
void EnlistThreads();
3637
void Init();
37-
void ApplyThreads();
3838
int GetThreads();
3939

4040
template <typename T, typename S> void Tasker( const T& task, const S& amount )
@@ -46,7 +46,7 @@ template <typename T, typename S> void Tasker( const T& task, const S& amount )
4646
return;
4747
}
4848

49-
ApplyThreads();
49+
EnlistThreads();
5050

5151
#pragma omp parallel for
5252
for ( S i = 0; i < amount; i++ )

src/engine/framework/System.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3434
#include "ConsoleHistory.h"
3535
#include "CommandSystem.h"
3636
#include "LogSystem.h"
37+
#include "Omp.h"
3738
#include "System.h"
3839
#include "CrashDump.h"
3940
#include "CvarSystem.h"
@@ -829,6 +830,8 @@ static void SetCvarsWithInitFlag(cmdlineArgs_t& cmdlineArgs)
829830
// Initialize the engine
830831
static void Init(int argc, char** argv)
831832
{
833+
Omp::Init();
834+
832835
cmdlineArgs_t cmdlineArgs;
833836

834837
#ifdef _WIN32

src/engine/qcommon/common.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Maryland 20850 USA.
4747
#include "framework/CommandSystem.h"
4848
#include "framework/CvarSystem.h"
4949
#include "framework/LogSystem.h"
50+
#include "framework/Omp.h"
5051
#include "framework/System.h"
5152
#include "sys/sys_events.h"
5253
#include <common/FileSystem.h>
@@ -783,6 +784,8 @@ static Cvar::Cvar<bool> showTraceStats("common.showTraceStats", "are physics tra
783784

784785
void Com_Frame()
785786
{
787+
Omp::SetupThreads();
788+
786789
int msec, minMsec;
787790
static int lastTime = 0;
788791
//int key;

0 commit comments

Comments
 (0)