Skip to content

Commit 9c7578f

Browse files
fix: change numa_library to read default policy
Changed NumaLibrary to read default policy instead of using the address-based policy, and remove unnecessary argument. Removed numaif.h from the repo as it is no longer required. Related-To: NEO-8276 Signed-off-by: Yoon, Young Jin <[email protected]>
1 parent f1f426c commit 9c7578f

File tree

12 files changed

+43
-602
lines changed

12 files changed

+43
-602
lines changed

CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,6 @@ if(NOT DISABLE_LIBVA)
428428
endif()
429429
endif()
430430

431-
if(UNIX)
432-
if(NOT DEFINED NUMA_HEADERS_DIR)
433-
get_filename_component(NUMA_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/numa" ABSOLUTE)
434-
message(STATUS "NUMA config headers dir: ${NUMA_HEADERS_DIR}")
435-
include_directories("${NUMA_HEADERS_DIR}")
436-
endif()
437-
endif()
438-
439431
add_subdirectory_unique(third_party/gtest)
440432

441433
message(STATUS "AUB_STREAM_DIR = ${AUB_STREAM_DIR}")

shared/source/os_interface/linux/drm_memory_manager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,9 +1886,9 @@ BufferObject *DrmMemoryManager::createBufferObjectInMemoryRegion(uint32_t rootDe
18861886

18871887
auto banks = std::bitset<4>(memoryBanks);
18881888
if (banks.count() > 1) {
1889-
ret = memoryInfo->createGemExtWithMultipleRegions(memoryBanks, size, handle, patIndex, isUsmHostAllocation, reinterpret_cast<void *>(gpuAddress));
1889+
ret = memoryInfo->createGemExtWithMultipleRegions(memoryBanks, size, handle, patIndex, isUsmHostAllocation);
18901890
} else {
1891-
ret = memoryInfo->createGemExtWithSingleRegion(memoryBanks, size, handle, patIndex, pairHandle, isUsmHostAllocation, reinterpret_cast<void *>(gpuAddress));
1891+
ret = memoryInfo->createGemExtWithSingleRegion(memoryBanks, size, handle, patIndex, pairHandle, isUsmHostAllocation);
18921892
}
18931893

18941894
if (ret != 0) {
@@ -1951,7 +1951,7 @@ bool DrmMemoryManager::createDrmChunkedAllocation(Drm *drm, DrmAllocation *alloc
19511951

19521952
auto gmm = allocation->getGmm(0u);
19531953
auto patIndex = drm->getPatIndex(gmm, allocation->getAllocationType(), CacheRegion::defaultRegion, CachePolicy::writeBack, false, !allocation->isAllocatedInLocalMemoryPool());
1954-
int ret = memoryInfo->createGemExtWithMultipleRegions(memoryBanks, boSize, handle, patIndex, -1, true, numOfChunks, allocation->isUsmHostAllocation(), reinterpret_cast<void *>(boAddress));
1954+
int ret = memoryInfo->createGemExtWithMultipleRegions(memoryBanks, boSize, handle, patIndex, -1, true, numOfChunks, allocation->isUsmHostAllocation());
19551955
if (ret != 0) {
19561956
return false;
19571957
}
@@ -2357,7 +2357,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
23572357

23582358
auto patIndex = drm.getPatIndex(nullptr, allocationData.type, CacheRegion::defaultRegion, CachePolicy::writeBack, false, MemoryPoolHelper::isSystemMemoryPool(memoryPool));
23592359

2360-
int ret = memoryInfo->createGemExt(memRegions, currentSize, handle, patIndex, {}, -1, useChunking, numOfChunks, allocationData.flags.isUSMHostAllocation, reinterpret_cast<void *>(preferredAddress));
2360+
int ret = memoryInfo->createGemExt(memRegions, currentSize, handle, patIndex, {}, -1, useChunking, numOfChunks, allocationData.flags.isUSMHostAllocation);
23612361

23622362
if (ret) {
23632363
this->munmapFunction(cpuPointer, totalSizeToAlloc);

shared/source/os_interface/linux/memory_info.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ void MemoryInfo::assignRegionsFromDistances(const std::vector<DistanceInfo> &dis
6060
}
6161
}
6262

63-
int MemoryInfo::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation, void *addr) {
63+
int MemoryInfo::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation) {
6464
std::vector<unsigned long> memPolicyNodeMask;
6565
int mode = -1;
6666
if (memPolicySupported &&
6767
isUSMHostAllocation &&
68-
Linux::NumaLibrary::getMemPolicy(&mode, memPolicyNodeMask, addr)) {
68+
Linux::NumaLibrary::getMemPolicy(&mode, memPolicyNodeMask)) {
6969
if (memPolicyMode != -1) {
7070
mode = memPolicyMode;
7171
}
@@ -124,7 +124,7 @@ void MemoryInfo::printRegionSizes() {
124124
}
125125
}
126126

127-
int MemoryInfo::createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isUSMHostAllocation, void *addr) {
127+
int MemoryInfo::createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isUSMHostAllocation) {
128128
auto pHwInfo = this->drm.getRootDeviceEnvironment().getHardwareInfo();
129129
auto regionClassAndInstance = getMemoryRegionClassAndInstance(memoryBanks, *pHwInfo);
130130
MemRegionsVec region = {regionClassAndInstance};
@@ -136,11 +136,11 @@ int MemoryInfo::createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocS
136136
}
137137
}
138138
uint32_t numOfChunks = 0;
139-
auto ret = createGemExt(region, allocSize, handle, patIndex, vmId, pairHandle, false, numOfChunks, isUSMHostAllocation, addr);
139+
auto ret = createGemExt(region, allocSize, handle, patIndex, vmId, pairHandle, false, numOfChunks, isUSMHostAllocation);
140140
return ret;
141141
}
142142

143-
int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, bool isUSMHostAllocation, void *addr) {
143+
int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, bool isUSMHostAllocation) {
144144
auto pHwInfo = this->drm.getRootDeviceEnvironment().getHardwareInfo();
145145
auto banks = std::bitset<4>(memoryBanks);
146146
MemRegionsVec memRegions{};
@@ -155,11 +155,11 @@ int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t all
155155
currentBank++;
156156
}
157157
uint32_t numOfChunks = 0;
158-
auto ret = createGemExt(memRegions, allocSize, handle, patIndex, {}, -1, false, numOfChunks, isUSMHostAllocation, addr);
158+
auto ret = createGemExt(memRegions, allocSize, handle, patIndex, {}, -1, false, numOfChunks, isUSMHostAllocation);
159159
return ret;
160160
}
161161

162-
int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation, void *addr) {
162+
int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation) {
163163
auto pHwInfo = this->drm.getRootDeviceEnvironment().getHardwareInfo();
164164
auto banks = std::bitset<4>(memoryBanks);
165165
MemRegionsVec memRegions{};
@@ -173,7 +173,7 @@ int MemoryInfo::createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t all
173173
}
174174
currentBank++;
175175
}
176-
auto ret = createGemExt(memRegions, allocSize, handle, patIndex, {}, pairHandle, isChunked, numOfChunks, isUSMHostAllocation, addr);
176+
auto ret = createGemExt(memRegions, allocSize, handle, patIndex, {}, pairHandle, isChunked, numOfChunks, isUSMHostAllocation);
177177
return ret;
178178
}
179179

shared/source/os_interface/linux/memory_info.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MemoryInfo {
2626

2727
void assignRegionsFromDistances(const std::vector<DistanceInfo> &distances);
2828

29-
MOCKABLE_VIRTUAL int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation, void *addr);
29+
MOCKABLE_VIRTUAL int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation);
3030

3131
MemoryClassInstance getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo);
3232

@@ -38,9 +38,9 @@ class MemoryInfo {
3838

3939
uint32_t getTileIndex(uint32_t memoryBank);
4040

41-
MOCKABLE_VIRTUAL int createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isUSMHostAllocation, void *addr);
42-
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, bool isUSMHostAllocation, void *addr);
43-
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation, void *addr);
41+
MOCKABLE_VIRTUAL int createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isUSMHostAllocation);
42+
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, bool isUSMHostAllocation);
43+
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation);
4444

4545
const RegionContainer &getDrmRegionInfos() const { return drmQueryRegions; }
4646
bool isMemPolicySupported() const { return memPolicySupported; }

shared/source/os_interface/linux/numa_library.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include <cerrno>
1313
#include <iostream>
14-
#include <numaif.h>
1514

1615
namespace NEO {
1716
namespace Linux {
@@ -45,11 +44,11 @@ bool NumaLibrary::init() {
4544
return numaLoaded;
4645
}
4746

48-
bool NumaLibrary::getMemPolicy(int *mode, std::vector<unsigned long> &nodeMask, void *addr) {
47+
bool NumaLibrary::getMemPolicy(int *mode, std::vector<unsigned long> &nodeMask) {
4948
if (numaLoaded) {
5049
// re-initialize vector with size maxNode;
5150
std::vector<unsigned long>(maxNode + 1, 0).swap(nodeMask);
52-
return (*getMemPolicyFunction)(mode, nodeMask.data(), maxNode + 1, addr, MPOL_F_MEMS_ALLOWED) != -1;
51+
return (*getMemPolicyFunction)(mode, nodeMask.data(), maxNode + 1, nullptr, 0) != -1;
5352
}
5453
return false;
5554
}

shared/source/os_interface/linux/numa_library.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class NumaLibrary {
2020
public:
2121
static bool init();
2222
static bool isLoaded() { return numaLoaded; }
23-
static bool getMemPolicy(int *mode, std::vector<unsigned long> &nodeMask, void *addr);
23+
static bool getMemPolicy(int *mode, std::vector<unsigned long> &nodeMask);
2424

2525
protected:
2626
static constexpr const char *numaLibNameStr = "libnuma.so.1";

shared/test/common/os_interface/linux/drm_memory_manager_fixture.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,30 @@ struct MockedMemoryInfo : public NEO::MemoryInfo {
6969
size_t getMemoryRegionSize(uint32_t memoryBank) override {
7070
return 1024u;
7171
}
72-
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation, void *addr) override {
72+
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation) override {
7373
if (allocSize == 0) {
7474
return EINVAL;
7575
}
7676
handle = 1u;
7777
return 0;
7878
}
79-
int createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isUSMHostAllocation, void *addr) override {
79+
int createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isUSMHostAllocation) override {
8080
if (allocSize == 0) {
8181
return EINVAL;
8282
}
8383
handle = 1u;
8484
pairHandlePassed = pairHandle;
8585
return 0;
8686
}
87-
int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, bool isUSMHostAllocation, void *addr) override {
87+
int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, bool isUSMHostAllocation) override {
8888
if (allocSize == 0) {
8989
return EINVAL;
9090
}
9191
handle = 1u;
9292
banks = memoryBanks;
9393
return 0;
9494
}
95-
int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation, void *addr) override {
95+
int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation) override {
9696
if (allocSize == 0) {
9797
return EINVAL;
9898
}

0 commit comments

Comments
 (0)