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
This commit is contained in:
Tao Sang authored and Tao Sang committed 2020-07-21 14:58:56 -04:00
1 parent a9ffa384e8
commit 214827defa
2 files changed
+14 -1

No files matched your search

+7 -1
View File
@@ -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;
}