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: 214827defa]
Этот коммит содержится в:
@@ -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)
|
||||
|
||||
@@ -49,8 +49,10 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#ifdef ROCCLR_SUPPORT_NUMA_POLICY
|
||||
#include <numaif.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user