diff --git a/openmp/libomptarget/plugins-nextgen/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/CMakeLists.txt index 966f51621c322..a27dd0a4ca918 100644 --- a/openmp/libomptarget/plugins-nextgen/CMakeLists.txt +++ b/openmp/libomptarget/plugins-nextgen/CMakeLists.txt @@ -47,7 +47,6 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$") LINK_LIBS PRIVATE - MemoryManager PluginInterface ${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES} ${OPENMP_PTHREAD_LIB} diff --git a/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt index 94a0084db6077..af967bc386f67 100644 --- a/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt +++ b/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt @@ -80,7 +80,6 @@ add_llvm_library(omptarget.rtl.amdgpu SHARED LINK_LIBS PRIVATE - MemoryManager PluginInterface ${LIBOMPTARGET_DEP_LIBRARIES} ${OPENMP_PTHREAD_LIB} diff --git a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt index 3d1f2634e6bc4..f0645d0d17538 100644 --- a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt +++ b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt @@ -12,4 +12,3 @@ add_subdirectory(OMPT) add_subdirectory(PluginInterface) -add_subdirectory(MemoryManager) diff --git a/openmp/libomptarget/plugins-nextgen/common/MemoryManager/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/MemoryManager/CMakeLists.txt deleted file mode 100644 index 7f2e7c7c8d39f..0000000000000 --- a/openmp/libomptarget/plugins-nextgen/common/MemoryManager/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -##===----------------------------------------------------------------------===## -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -##===----------------------------------------------------------------------===## - -add_library(MemoryManager INTERFACE) - -target_include_directories(MemoryManager INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/openmp/libomptarget/plugins-nextgen/common/OMPT/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/OMPT/CMakeLists.txt index db79c6d3e550e..be4c743665b3e 100644 --- a/openmp/libomptarget/plugins-nextgen/common/OMPT/CMakeLists.txt +++ b/openmp/libomptarget/plugins-nextgen/common/OMPT/CMakeLists.txt @@ -52,7 +52,6 @@ endif() target_link_libraries(OMPT PUBLIC ${llvm_libs} - MemoryManager ) # Define the TARGET_NAME and DEBUG_PREFIX. diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt index 4ff4dee3c0875..84a7dc8ea72dd 100644 --- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt +++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt @@ -63,7 +63,6 @@ endif() target_link_libraries(PluginInterface PUBLIC ${llvm_libs} - MemoryManager ) # Include the RPC server from the `libc` project if availible. diff --git a/openmp/libomptarget/plugins-nextgen/common/MemoryManager/MemoryManager.h b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/MemoryManager.h similarity index 95% rename from openmp/libomptarget/plugins-nextgen/common/MemoryManager/MemoryManager.h rename to openmp/libomptarget/plugins-nextgen/common/PluginInterface/MemoryManager.h index 37ef80a1af3ae..2d23d959f6c0b 100644 --- a/openmp/libomptarget/plugins-nextgen/common/MemoryManager/MemoryManager.h +++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/MemoryManager.h @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_OPENMP_LIBOMPTARGET_PLUGINS_COMMON_MEMORYMANAGER_MEMORYMANAGER_H -#define LLVM_OPENMP_LIBOMPTARGET_PLUGINS_COMMON_MEMORYMANAGER_MEMORYMANAGER_H +#ifndef LLVM_OPENMP_LIBOMPTARGET_PLUGINS_COMMON_MEMORYMANAGER_H +#define LLVM_OPENMP_LIBOMPTARGET_PLUGINS_COMMON_MEMORYMANAGER_H #include #include @@ -22,6 +22,8 @@ #include #include "Debug.h" +#include "Utilities.h" +#include "omptarget.h" /// Base class of per-device allocator. class DeviceAllocatorTy { @@ -322,16 +324,15 @@ class MemoryManagerTy { /// manager explicitly by setting the var to 0. If user doesn't specify /// anything, returns <0, true>. static std::pair getSizeThresholdFromEnv() { - size_t Threshold = 0; - - if (const char *Env = - std::getenv("LIBOMPTARGET_MEMORY_MANAGER_THRESHOLD")) { - Threshold = std::stoul(Env); - if (Threshold == 0) { - DP("Disabled memory manager as user set " - "LIBOMPTARGET_MEMORY_MANAGER_THRESHOLD=0.\n"); - return std::make_pair(0, false); - } + static llvm::omp::target::UInt32Envar MemoryManagerThreshold( + "LIBOMPTARGET_MEMORY_MANAGER_THRESHOLD", 0); + + size_t Threshold = MemoryManagerThreshold.get(); + + if (MemoryManagerThreshold.isPresent() && Threshold == 0) { + DP("Disabled memory manager as user set " + "LIBOMPTARGET_MEMORY_MANAGER_THRESHOLD=0.\n"); + return std::make_pair(0, false); } return std::make_pair(Threshold, true); @@ -343,4 +344,4 @@ class MemoryManagerTy { constexpr const size_t MemoryManagerTy::BucketSize[]; constexpr const int MemoryManagerTy::NumBuckets; -#endif // LLVM_OPENMP_LIBOMPTARGET_PLUGINS_COMMON_MEMORYMANAGER_MEMORYMANAGER_H +#endif // LLVM_OPENMP_LIBOMPTARGET_PLUGINS_COMMON_MEMORYMANAGER_H diff --git a/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt index d0e6b26888d55..3e1d11ac365df 100644 --- a/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt +++ b/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt @@ -34,7 +34,6 @@ add_llvm_library(omptarget.rtl.cuda SHARED Object LINK_LIBS PRIVATE - MemoryManager PluginInterface ${OPENMP_PTHREAD_LIB}