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; }