From 10f1bfc76530e140ac8e4ee4a0f16bc9a7207be2 Mon Sep 17 00:00:00 2001 From: Tao Sang Date: Fri, 10 Jul 2020 17:48:53 -0400 Subject: [PATCH] Add numa lib detection in cmake If numa lib is in building system, define ROCCLR_NUMA_SUPPORT to support numa; otherwise, don't support numa. Change-Id: I3848d7fdec5a3813ff1edad9b71ff04372dc0b9a [ROCm/clr commit: 214827defa429a417d840f60e5cd8f97ae745ad0] --- projects/clr/rocclr/CMakeLists.txt | 7 +++++++ projects/clr/rocclr/device/rocm/rocdevice.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/clr/rocclr/CMakeLists.txt b/projects/clr/rocclr/CMakeLists.txt index 756f29aa91..5bd27a3d17 100644 --- a/projects/clr/rocclr/CMakeLists.txt +++ b/projects/clr/rocclr/CMakeLists.txt @@ -224,6 +224,13 @@ if (UNIX) if (LIBRT) target_link_libraries(amdrocclr_static PUBLIC ${LIBRT}) endif() + + find_library(LIBNUMA numa) + if (LIBNUMA) + target_compile_definitions(amdrocclr_static PUBLIC ROCCLR_SUPPORT_NUMA_POLICY) + target_link_libraries(amdrocclr_static PUBLIC ${LIBNUMA}) + message(STATUS "Found: ${LIBNUMA}") + endif() endif() #comment out as it's not available in cmake 3.5 #if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) diff --git a/projects/clr/rocclr/device/rocm/rocdevice.cpp b/projects/clr/rocclr/device/rocm/rocdevice.cpp index c5e990d1a4..d3c405da57 100755 --- a/projects/clr/rocclr/device/rocm/rocdevice.cpp +++ b/projects/clr/rocclr/device/rocm/rocdevice.cpp @@ -49,8 +49,10 @@ #include #include #include +#ifdef ROCCLR_SUPPORT_NUMA_POLICY #include -#endif // WITHOUT_HSA_BACKEND +#endif // ROCCLR_SUPPORT_NUMA_POLICY +#endif // WITHOUT_HSA_BaCKEND #define OPENCL_VERSION_STR XSTR(OPENCL_MAJOR) "." XSTR(OPENCL_MINOR) #define OPENCL_C_VERSION_STR XSTR(OPENCL_C_MAJOR) "." XSTR(OPENCL_C_MINOR) @@ -1732,6 +1734,9 @@ void* Device::hostAgentAlloc(size_t size, const AgentInfo& agentInfo, bool atomi void* Device::hostNumaAlloc(size_t size, size_t alignment, bool atomics) const { void* ptr = nullptr; +#ifndef ROCCLR_SUPPORT_NUMA_POLICY + ptr = hostAlloc(size, alignment, atomics); +#else int mode = MPOL_DEFAULT; unsigned long nodeMask = 0; auto cpuCount = cpu_agents_.size(); @@ -1762,6 +1767,7 @@ void* Device::hostNumaAlloc(size_t size, size_t alignment, bool atomics) const { // All other modes fall back to default mode ptr = hostAlloc(size, alignment, atomics); } +#endif // ROCCLR_SUPPORT_NUMA_POLICY return ptr; }