• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2017 The TensorFlow 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 
16 #include "tensorflow/compiler/xla/service/cpu/orc_jit_memory_mapper.h"
17 #include "tensorflow/core/platform/logging.h"
18 #include "tensorflow/core/platform/mutex.h"
19 
20 namespace xla {
21 namespace cpu {
22 namespace orc_jit_memory_mapper {
23 
24 static tensorflow::mutex mapper_instance_mutex(tensorflow::LINKER_INITIALIZED);
25 static llvm::SectionMemoryManager::MemoryMapper* mapper_instance
26     GUARDED_BY(mapper_instance_mutex) = nullptr;
27 
GetInstance()28 llvm::SectionMemoryManager::MemoryMapper* GetInstance() {
29   tensorflow::mutex_lock lock(mapper_instance_mutex);
30   return mapper_instance;
31 }
32 
Registrar(std::unique_ptr<llvm::SectionMemoryManager::MemoryMapper> mapper)33 Registrar::Registrar(
34     std::unique_ptr<llvm::SectionMemoryManager::MemoryMapper> mapper) {
35   tensorflow::mutex_lock lock(mapper_instance_mutex);
36   mapper_instance = mapper.release();
37 }
38 }  // namespace orc_jit_memory_mapper
39 }  // namespace cpu
40 }  // namespace xla
41