1 /* Copyright 2020 Google LLC. 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 
16 #include "ruy/context.h"
17 
18 #include "ruy/ctx.h"
19 #include "ruy/ctx_impl.h"
20 #include "ruy/path.h"
21 #include "ruy/performance_advisory.h"
22 #include "ruy/prepacked_cache.h"
23 #include "ruy/thread_pool.h"
24 #include "ruy/tune.h"
25 
26 namespace ruy {
27 
Context()28 Context::Context() : impl_(new CtxImpl) {}
~Context()29 Context::~Context() { delete impl_; }
30 
ctx() const31 const Ctx& Context::ctx() const { return static_cast<const Ctx&>(*impl_); }
mutable_ctx()32 Ctx* Context::mutable_ctx() { return static_cast<Ctx*>(impl_); }
33 
last_used_path() const34 Path Context::last_used_path() const { return ctx().last_used_path(); }
explicit_tuning() const35 Tuning Context::explicit_tuning() const { return ctx().explicit_tuning(); }
set_explicit_tuning(Tuning value)36 void Context::set_explicit_tuning(Tuning value) {
37   mutable_ctx()->set_explicit_tuning(value);
38 }
thread_pool() const39 const ThreadPool& Context::thread_pool() const { return ctx().thread_pool(); }
mutable_thread_pool()40 ThreadPool* Context::mutable_thread_pool() {
41   return mutable_ctx()->mutable_thread_pool();
42 }
max_num_threads() const43 int Context::max_num_threads() const { return ctx().max_num_threads(); }
set_max_num_threads(int value)44 void Context::set_max_num_threads(int value) {
45   mutable_ctx()->set_max_num_threads(value);
46 }
47 
ClearPrepackedCache()48 void Context::ClearPrepackedCache() { mutable_ctx()->ClearPrepackedCache(); }
49 
performance_advisory(PerformanceAdvisory advisory) const50 bool Context::performance_advisory(PerformanceAdvisory advisory) const {
51   return ctx().performance_advisory(advisory);
52 }
53 
set_runtime_enabled_paths(Path paths)54 void Context::set_runtime_enabled_paths(Path paths) {
55   mutable_ctx()->SetRuntimeEnabledPaths(paths);
56 }
57 
58 }  // namespace ruy
59