• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <stdint.h>
19 
20 #include "Reactor/Nucleus.hpp"
21 #include "marl/scheduler.h"
22 
23 namespace sw {
24 struct Configuration
25 {
26 	enum class AffinityPolicy : int
27 	{
28 		// A thread has affinity with any core in the affinity mask.
29 		AnyOf = 0,
30 		// A thread has affinity with a single core in the affinity mask.
31 		OneOf = 1,
32 	};
33 
34 	// -------- [Processor] --------
35 	// Number of threads used by the scheduler. A thread count of 0 is
36 	// interpreted as min(cpu_cores_available, 16).
37 	uint32_t threadCount = 0;
38 
39 	// Core affinity and affinity policy used by the scheduler.
40 	uint64_t affinityMask = 0xffffffffffffffff;
41 	AffinityPolicy affinityPolicy = AffinityPolicy::AnyOf;
42 
43 	// -------- [Debug] --------
44 	// Directory where ASM listings of JITted code will be emitted.
45 	std::string asmEmitDir = "";
46 
47 	// -------- [Profiler] --------
48 	// Whether SPIR-V profiling is enabled.
49 	bool enableSpirvProfiling = false;
50 	// Period controlling how often SPIR-V profiles are reported.
51 	uint64_t spvProfilingReportPeriodMs = 1000;
52 	// Directory where SPIR-V profile reports will be written.
53 	std::string spvProfilingReportDir = "";
54 };
55 
56 // Get the configuration as parsed from a configuration file.
57 const Configuration &getConfiguration();
58 
59 // Get the scheduler configuration given a configuration.
60 marl::Scheduler::Config getSchedulerConfiguration(const Configuration &config);
61 
62 // Get the debug configuration for Reactor given a configuration.
63 rr::DebugConfig getReactorDebugConfig(const Configuration &config);
64 }  // namespace sw
65 
66 #endif