blob: b039a8db19b7b0d6d1d424f3331ab3bf9db47ecd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#include "taskschedulerppl.h"
namespace embree
{
static bool g_ppl_threads_initialized = false;
void TaskScheduler::create(size_t numThreads, bool set_affinity, bool start_threads)
{
assert(numThreads);
/* first terminate threads in case we configured them */
if (g_ppl_threads_initialized) {
g_ppl_threads_initialized = false;
}
/* now either keep default settings or configure number of threads */
if (numThreads == std::numeric_limits<size_t>::max())
{
g_ppl_threads_initialized = false;
numThreads = threadCount();
}
else
{
g_ppl_threads_initialized = true;
try {
concurrency::Scheduler::SetDefaultSchedulerPolicy(concurrency::SchedulerPolicy(2, concurrency::MinConcurrency, numThreads, concurrency::MaxConcurrency, numThreads));
}
catch(concurrency::default_scheduler_exists &) {
}
}
}
void TaskScheduler::destroy()
{
if (g_ppl_threads_initialized) {
g_ppl_threads_initialized = false;
}
}
}
|