1 | // Copyright 2022 The SwiftShader Authors. All Rights Reserved. |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | #ifndef sw_SwiftConfig_hpp |
16 | #define sw_SwiftConfig_hpp |
17 | |
18 | #include "Reactor/Nucleus.hpp" |
19 | #include "marl/scheduler.h" |
20 | |
21 | #include <stdint.h> |
22 | |
23 | namespace sw { |
24 | |
25 | struct Configuration |
26 | { |
27 | enum class AffinityPolicy : int |
28 | { |
29 | // A thread has affinity with any core in the affinity mask. |
30 | AnyOf = 0, |
31 | // A thread has affinity with a single core in the affinity mask. |
32 | OneOf = 1, |
33 | }; |
34 | |
35 | // -------- [Processor] -------- |
36 | // Number of threads used by the scheduler. A thread count of 0 is |
37 | // interpreted as min(cpu_cores_available, 16). |
38 | uint32_t threadCount = 0; |
39 | |
40 | // Core affinity and affinity policy used by the scheduler. |
41 | uint64_t affinityMask = 0xFFFFFFFFFFFFFFFFu; |
42 | AffinityPolicy affinityPolicy = AffinityPolicy::AnyOf; |
43 | |
44 | // -------- [Profiler] -------- |
45 | // Whether SPIR-V profiling is enabled. |
46 | bool enableSpirvProfiling = false; |
47 | // Period controlling how often SPIR-V profiles are reported. |
48 | uint64_t spvProfilingReportPeriodMs = 1000; |
49 | // Directory where SPIR-V profile reports will be written. |
50 | std::string spvProfilingReportDir = "" ; |
51 | }; |
52 | |
53 | // Get the configuration as parsed from a configuration file. |
54 | const Configuration &getConfiguration(); |
55 | |
56 | // Get the scheduler configuration given a configuration. |
57 | marl::Scheduler::Config getSchedulerConfiguration(const Configuration &config); |
58 | |
59 | } // namespace sw |
60 | |
61 | #endif |
62 | |