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
Cette révision appartient à :
Tao Sang
2020-07-10 17:48:53 -04:00
révisé par Tao Sang
Parent a9ffa384e8
révision 214827defa
2 fichiers modifiés avec 14 ajouts et 1 suppressions
+7
Voir le fichier
@@ -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)
+7 -1
Voir le fichier
@@ -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;
}