Skip to content

Commit

Permalink
[OpenMP][NFC] Merge MemoryManager into PluginInterface (#73678)
Browse files Browse the repository at this point in the history
Similar to #73677, there is no benefit from keeping MemoryManager
seperate; it's tied into the current design. Except the move I also
replaced the getenv call with our Env handling.
  • Loading branch information
jdoerfert committed Nov 28, 2023
1 parent 43f783f commit 0783bf1
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 30 deletions.
1 change: 0 additions & 1 deletion openmp/libomptarget/plugins-nextgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")

LINK_LIBS
PRIVATE
MemoryManager
PluginInterface
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
${OPENMP_PTHREAD_LIB}
Expand Down
1 change: 0 additions & 1 deletion openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ add_llvm_library(omptarget.rtl.amdgpu SHARED

LINK_LIBS
PRIVATE
MemoryManager
PluginInterface
${LIBOMPTARGET_DEP_LIBRARIES}
${OPENMP_PTHREAD_LIB}
Expand Down
1 change: 0 additions & 1 deletion openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@

add_subdirectory(OMPT)
add_subdirectory(PluginInterface)
add_subdirectory(MemoryManager)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ endif()
target_link_libraries(OMPT
PUBLIC
${llvm_libs}
MemoryManager
)

# Define the TARGET_NAME and DEBUG_PREFIX.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ endif()
target_link_libraries(PluginInterface
PUBLIC
${llvm_libs}
MemoryManager
)

# Include the RPC server from the `libc` project if availible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cassert>
#include <functional>
Expand All @@ -22,6 +22,8 @@
#include <vector>

#include "Debug.h"
#include "Utilities.h"
#include "omptarget.h"

/// Base class of per-device allocator.
class DeviceAllocatorTy {
Expand Down Expand Up @@ -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<size_t, bool> 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);
Expand All @@ -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
1 change: 0 additions & 1 deletion openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ add_llvm_library(omptarget.rtl.cuda SHARED
Object

LINK_LIBS PRIVATE
MemoryManager
PluginInterface
${OPENMP_PTHREAD_LIB}

Expand Down

0 comments on commit 0783bf1

Please sign in to comment.