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 18 #include "absl/base/thread_annotations.h" 19 #include "tensorflow/core/platform/logging.h" 20 21 namespace xla { 22 namespace cpu { 23 namespace orc_jit_memory_mapper { 24 25 static absl::Mutex mapper_instance_mutex(absl::kConstInit); 26 static llvm::SectionMemoryManager::MemoryMapper* mapper_instance 27 ABSL_GUARDED_BY(mapper_instance_mutex) = nullptr; 28 GetInstance()29llvm::SectionMemoryManager::MemoryMapper* GetInstance() { 30 absl::MutexLock lock(&mapper_instance_mutex); 31 return mapper_instance; 32 } 33 Registrar(std::unique_ptr<llvm::SectionMemoryManager::MemoryMapper> mapper)34Registrar::Registrar( 35 std::unique_ptr<llvm::SectionMemoryManager::MemoryMapper> mapper) { 36 absl::MutexLock lock(&mapper_instance_mutex); 37 mapper_instance = mapper.release(); 38 } 39 } // namespace orc_jit_memory_mapper 40 } // namespace cpu 41 } // namespace xla 42