Use GfxPartition for GPU address range allocations

[4/n] - Remove allocator32Bit

Related-To: NEO-2877

Change-Id: I0772a7fe1fda19daa12699c546587bd3cdd84f2c
Signed-off-by: Venevtsev, Igor <igor.venevtsev@intel.com>
This commit is contained in:
Venevtsev, Igor
2019-07-04 12:40:58 +02:00
committed by sys_ocldev
parent 09e87879db
commit 4403796f58
33 changed files with 13 additions and 451 deletions

2
Jenkinsfile vendored
View File

@@ -1,5 +1,5 @@
#!groovy
dependenciesRevision='a4ef754827742dffa3fbf749545909878d65f0a1-1267'
strategy='EQUAL'
allowedCD=268
allowedCD=266
allowedF=5

View File

@@ -71,10 +71,7 @@ void Device::initializeCaps() {
deviceExtensions.clear();
deviceExtensions.append(deviceExtensionsList);
// Add our graphics family name to the device name
auto addressing32bitAllowed = is32BitOsAllocatorAvailable;
if (is32bit) {
addressing32bitAllowed = false;
}
auto addressing32bitAllowed = is64bit;
driverVersion = TOSTR(NEO_DRIVER_VERSION);

View File

@@ -12,12 +12,8 @@
namespace NEO {
size_t getSizeToMap() {
return static_cast<size_t>(alignUp(4 * GB - 8096, 4096));
}
size_t getSizeToReserve() {
return maxNBitValue<47> / 4;
return (maxNBitValue<47> + 1) / 4;
}
} // namespace NEO

View File

@@ -34,7 +34,7 @@
namespace NEO {
MemoryManager::MemoryManager(ExecutionEnvironment &executionEnvironment) : executionEnvironment(executionEnvironment), hostPtrManager(std::make_unique<HostPtrManager>()),
multiContextResourceDestructor(std::make_unique<DeferredDeleter>()), allocator32Bit(nullptr) {
multiContextResourceDestructor(std::make_unique<DeferredDeleter>()) {
auto hwInfo = executionEnvironment.getHardwareInfo();
this->localMemorySupported = HwHelper::get(hwInfo->platform.eRenderCoreFamily).getEnableLocalMemory(*hwInfo);
this->enable64kbpages = OSInterface::osEnabled64kbPages && hwInfo->capabilityTable.ftr64KBpages;
@@ -121,13 +121,6 @@ void MemoryManager::freeSystemMemory(void *ptr) {
::alignedFree(ptr);
}
void MemoryManager::setForce32BitAllocations(bool newValue) {
if (newValue && !this->allocator32Bit) {
this->allocator32Bit.reset(new Allocator32bit);
}
force32bitAllocations = newValue;
}
void MemoryManager::applyCommonCleanup() {
if (this->paddingAllocation) {
this->freeGraphicsMemory(this->paddingAllocation);

View File

@@ -16,7 +16,6 @@
#include "runtime/memory_manager/graphics_allocation.h"
#include "runtime/memory_manager/host_ptr_defines.h"
#include "runtime/memory_manager/local_memory_usage.h"
#include "runtime/os_interface/32bit_memory.h"
#include "engine_node.h"
@@ -105,17 +104,15 @@ class MemoryManager {
virtual uint64_t getSystemSharedMemory() = 0;
virtual uint64_t getMaxApplicationAddress() = 0;
virtual uint64_t getInternalHeapBaseAddress() = 0;
virtual uint64_t getExternalHeapBaseAddress() = 0;
uint64_t getMaxApplicationAddress() { return is64bit ? MemoryConstants::max64BitAppAddress : MemoryConstants::max32BitAppAddress; };
uint64_t getInternalHeapBaseAddress() { return gfxPartition.getHeapBase(internalHeapIndex); }
uint64_t getExternalHeapBaseAddress() { return gfxPartition.getHeapBase(HeapIndex::HEAP_EXTERNAL); }
bool isLimitedRange() { return gfxPartition.isLimitedRange(); }
bool peek64kbPagesEnabled() const { return enable64kbpages; }
bool peekForce32BitAllocations() const { return force32bitAllocations; }
virtual void setForce32BitAllocations(bool newValue);
void setForce32BitAllocations(bool newValue) { force32bitAllocations = newValue; }
bool peekVirtualPaddingSupport() const { return virtualPaddingAvailable; }
void setVirtualPaddingSupport(bool virtualPaddingSupport) { virtualPaddingAvailable = virtualPaddingSupport; }
@@ -224,7 +221,6 @@ class MemoryManager {
uint32_t latestContextId = std::numeric_limits<uint32_t>::max();
uint32_t defaultEngineIndex = 0;
std::unique_ptr<DeferredDeleter> multiContextResourceDestructor;
std::unique_ptr<Allocator32bit> allocator32Bit;
GfxPartition gfxPartition;
std::unique_ptr<LocalMemoryUsageBankSelector> localMemoryUsageBankSelector;
};

View File

@@ -226,22 +226,6 @@ uint64_t OsAgnosticMemoryManager::getSystemSharedMemory() {
return 16 * GB;
}
uint64_t OsAgnosticMemoryManager::getMaxApplicationAddress() {
return is64bit ? MemoryConstants::max64BitAppAddress : MemoryConstants::max32BitAppAddress;
}
uint64_t OsAgnosticMemoryManager::getInternalHeapBaseAddress() {
return gfxPartition.getHeapBase(internalHeapIndex);
}
uint64_t OsAgnosticMemoryManager::getExternalHeapBaseAddress() {
return gfxPartition.getHeapBase(HeapIndex::HEAP_EXTERNAL);
}
void OsAgnosticMemoryManager::setForce32BitAllocations(bool newValue) {
force32bitAllocations = newValue;
}
GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) {
auto allocation = createMemoryAllocation(allocationData.type, nullptr, const_cast<void *>(allocationData.hostPtr),
reinterpret_cast<uint64_t>(allocationData.hostPtr), allocationData.size, counter++,

View File

@@ -60,10 +60,6 @@ class OsAgnosticMemoryManager : public MemoryManager {
void cleanOsHandles(OsHandleStorage &handleStorage) override;
uint64_t getSystemSharedMemory() override;
uint64_t getMaxApplicationAddress() override;
uint64_t getInternalHeapBaseAddress() override;
uint64_t getExternalHeapBaseAddress() override;
void setForce32BitAllocations(bool newValue) override;
void turnOnFakingBigAllocations();

View File

@@ -1,37 +0,0 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/utilities/heap_allocator.h"
#include <memory>
#include <stdint.h>
namespace NEO {
const uintptr_t max32BitAddress = 0xffffffff;
extern bool is32BitOsAllocatorAvailable;
class Allocator32bit {
protected:
class OsInternals;
public:
Allocator32bit(uint64_t base, uint64_t size);
Allocator32bit(Allocator32bit::OsInternals *osInternals);
Allocator32bit();
MOCKABLE_VIRTUAL ~Allocator32bit();
uint64_t allocate(size_t &size);
uintptr_t getBase() const;
int free(uint64_t ptr, size_t size);
protected:
std::unique_ptr<OsInternals> osInternals;
std::unique_ptr<HeapAllocator> heapAllocator;
uint64_t base = 0;
uint64_t size = 0;
};
} // namespace NEO

View File

@@ -6,7 +6,6 @@
set(RUNTIME_SRCS_OS_INTERFACE_BASE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/32bit_memory.h
${CMAKE_CURRENT_SOURCE_DIR}/debug_variables_base.inl
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/debug_variables.inl
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/translate_debug_settings.cpp

View File

@@ -13,7 +13,6 @@ set(RUNTIME_SRCS_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream.inl
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver_info.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_32bit_memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_allocation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_allocation.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_buffer_object.cpp

View File

@@ -9,6 +9,5 @@
#include <cstddef>
namespace NEO {
size_t getSizeToMap();
size_t getSizeToReserve();
} // namespace NEO

View File

@@ -1,84 +0,0 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "core/helpers/basic_math.h"
#include "core/helpers/ptr_math.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/os_interface/32bit_memory.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/os_interface/linux/allocator_helper.h"
#include <memory>
#include <sys/mman.h>
using namespace NEO;
class Allocator32bit::OsInternals {
public:
decltype(&mmap) mmapFunction = mmap;
decltype(&munmap) munmapFunction = munmap;
void *heapBasePtr = nullptr;
size_t heapSize = 0;
};
bool NEO::is32BitOsAllocatorAvailable = true;
Allocator32bit::Allocator32bit(uint64_t base, uint64_t size) : base(base), size(size) {
heapAllocator = std::make_unique<HeapAllocator>(base, size);
}
NEO::Allocator32bit::Allocator32bit() : Allocator32bit(new OsInternals) {
}
NEO::Allocator32bit::Allocator32bit(Allocator32bit::OsInternals *osInternalsIn) : osInternals(osInternalsIn) {
size_t sizeToMap = getSizeToMap();
void *ptr = this->osInternals->mmapFunction(nullptr, sizeToMap, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
if (ptr == MAP_FAILED) {
sizeToMap -= sizeToMap / 4;
ptr = this->osInternals->mmapFunction(nullptr, sizeToMap, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
DebugManager.log(DebugManager.flags.PrintDebugMessages.get(), __FUNCTION__, " Allocator RETRY ptr == ", ptr);
if (ptr == MAP_FAILED) {
ptr = nullptr;
sizeToMap = 0;
}
}
DebugManager.log(DebugManager.flags.PrintDebugMessages.get(), __FUNCTION__, "Allocator ptr == ", ptr);
osInternals->heapBasePtr = ptr;
osInternals->heapSize = sizeToMap;
base = reinterpret_cast<uint64_t>(ptr);
size = sizeToMap;
heapAllocator = std::unique_ptr<HeapAllocator>(new HeapAllocator(base, sizeToMap));
}
NEO::Allocator32bit::~Allocator32bit() {
if (this->osInternals.get() != nullptr) {
if (this->osInternals->heapBasePtr != nullptr)
this->osInternals->munmapFunction(this->osInternals->heapBasePtr, this->osInternals->heapSize);
}
}
uint64_t NEO::Allocator32bit::allocate(size_t &size) {
return this->heapAllocator->allocate(size);
}
int Allocator32bit::free(uint64_t ptr, size_t size) {
if (ptr == reinterpret_cast<uint64_t>(MAP_FAILED))
return 0;
this->heapAllocator->free(ptr, size);
return 0;
}
uintptr_t Allocator32bit::getBase() const {
return (uintptr_t)base;
}

View File

@@ -573,18 +573,6 @@ uint64_t DrmMemoryManager::getSystemSharedMemory() {
return std::min(hostMemorySize, gpuMemorySize);
}
uint64_t DrmMemoryManager::getMaxApplicationAddress() {
return is64bit ? MemoryConstants::max64BitAppAddress : MemoryConstants::max32BitAppAddress;
}
uint64_t DrmMemoryManager::getInternalHeapBaseAddress() {
return gfxPartition.getHeapBase(internalHeapIndex);
}
uint64_t DrmMemoryManager::getExternalHeapBaseAddress() {
return gfxPartition.getHeapBase(HeapIndex::HEAP_EXTERNAL);
}
MemoryManager::AllocationStatus DrmMemoryManager::populateOsHandles(OsHandleStorage &handleStorage) {
BufferObject *allocatedBos[maxFragmentsCount];
uint32_t numberOfBosAllocated = 0;

View File

@@ -38,9 +38,6 @@ class DrmMemoryManager : public MemoryManager {
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle) override { return nullptr; }
uint64_t getSystemSharedMemory() override;
uint64_t getMaxApplicationAddress() override;
uint64_t getInternalHeapBaseAddress() override;
uint64_t getExternalHeapBaseAddress() override;
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage) override;
void cleanOsHandles(OsHandleStorage &handleStorage) override;

View File

@@ -48,7 +48,6 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/registry_reader.h
${CMAKE_CURRENT_SOURCE_DIR}/sys_calls.h
${CMAKE_CURRENT_SOURCE_DIR}/thk_wrapper.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_32bit_memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_allocation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_allocation.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_additional_context_flags.cpp

View File

@@ -1,51 +0,0 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/helpers/aligned_memory.h"
#include "runtime/os_interface/32bit_memory.h"
using namespace NEO;
bool NEO::is32BitOsAllocatorAvailable = is64bit;
class Allocator32bit::OsInternals {
public:
void *allocatedRange;
};
Allocator32bit::Allocator32bit(uint64_t base, uint64_t size) : base(base), size(size) {
heapAllocator = std::make_unique<HeapAllocator>(base, size);
}
NEO::Allocator32bit::Allocator32bit() {
size_t sizeToMap = 100 * 4096;
this->base = (uint64_t)alignedMalloc(sizeToMap, 4096);
osInternals = std::make_unique<OsInternals>();
osInternals->allocatedRange = (void *)((uintptr_t)this->base);
heapAllocator = std::make_unique<HeapAllocator>(this->base, sizeToMap);
}
NEO::Allocator32bit::~Allocator32bit() {
if (this->osInternals.get() != nullptr) {
alignedFree(this->osInternals->allocatedRange);
}
}
uint64_t Allocator32bit::allocate(size_t &size) {
if (size >= 0xfffff000)
return 0llu;
return this->heapAllocator->allocate(size);
}
int Allocator32bit::free(uint64_t ptr, size_t size) {
this->heapAllocator->free(ptr, size);
return 0;
}
uintptr_t Allocator32bit::getBase() const {
return (uintptr_t)base;
}

View File

@@ -474,22 +474,6 @@ uint64_t WddmMemoryManager::getSystemSharedMemory() {
return wddm->getSystemSharedMemory();
}
uint64_t WddmMemoryManager::getMaxApplicationAddress() {
return wddm->getMaxApplicationAddress();
}
uint64_t WddmMemoryManager::getInternalHeapBaseAddress() {
return gfxPartition.getHeapBase(internalHeapIndex);
}
uint64_t WddmMemoryManager::getExternalHeapBaseAddress() {
return gfxPartition.getHeapBase(HeapIndex::HEAP_EXTERNAL);
}
void WddmMemoryManager::setForce32BitAllocations(bool newValue) {
force32bitAllocations = newValue;
}
bool WddmMemoryManager::mapAuxGpuVA(GraphicsAllocation *graphicsAllocation) {
return wddm->updateAuxTable(graphicsAllocation->getGpuAddress(), graphicsAllocation->getDefaultGmm(), true);
}

View File

@@ -48,13 +48,6 @@ class WddmMemoryManager : public MemoryManager {
void obtainGpuAddressFromFragments(WddmAllocation *allocation, OsHandleStorage &handleStorage);
uint64_t getSystemSharedMemory() override;
uint64_t getMaxApplicationAddress() override;
uint64_t getInternalHeapBaseAddress() override;
uint64_t getExternalHeapBaseAddress() override;
void setForce32BitAllocations(bool newValue) override;
bool tryDeferDeletions(const D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle);

View File

@@ -11,7 +11,6 @@
#include "runtime/helpers/hw_info.h"
#include "runtime/helpers/options.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/os_interface/32bit_memory.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/source_level_debugger/source_level_debugger.h"
@@ -176,7 +175,7 @@ TEST(Device_GetCaps, validate) {
EXPECT_EQ(16384u, caps.image2DMaxWidth);
EXPECT_EQ(16384u, caps.image2DMaxHeight);
EXPECT_EQ(2048u, caps.imageMaxArraySize);
if (device->getHardwareInfo().capabilityTable.clVersionSupport == 12 && is32BitOsAllocatorAvailable) {
if (device->getHardwareInfo().capabilityTable.clVersionSupport == 12 && is64bit) {
EXPECT_TRUE(caps.force32BitAddressess);
} else {
//EXPECT_FALSE(caps.force32BitAddressess);

View File

@@ -9,7 +9,6 @@
#include "runtime/helpers/hw_info.h"
#include "runtime/helpers/options.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/os_interface/32bit_memory.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"

View File

@@ -29,7 +29,7 @@ BXTTEST_F(BxtDeviceCaps, BxtClVersionSupport) {
EXPECT_STREQ("OpenCL C 1.2 ", caps.clCVersion);
auto memoryManager = pDevice->getMemoryManager();
if (is32BitOsAllocatorAvailable) {
if (is64bit) {
EXPECT_TRUE(memoryManager->peekForce32BitAllocations());
EXPECT_TRUE(caps.force32BitAddressess);
} else {

View File

@@ -30,7 +30,7 @@ GLKTEST_F(Gen9DeviceCaps, GlkClVersionSupport) {
GLKTEST_F(Gen9DeviceCaps, GlkIs32BitOsAllocatorAvailable) {
const auto &caps = pDevice->getDeviceInfo();
auto memoryManager = pDevice->getMemoryManager();
if (is32BitOsAllocatorAvailable) {
if (is64bit) {
EXPECT_TRUE(memoryManager->peekForce32BitAllocations());
EXPECT_TRUE(caps.force32BitAddressess);
} else {

View File

@@ -357,12 +357,8 @@ TEST_F(DrmTests, failOnInvalidDeviceName) {
EXPECT_EQ(drm, nullptr);
}
TEST(AllocatorHelper, givenExpectedSizeToMapWhenGetSizetoMapCalledThenExpectedValueReturned) {
EXPECT_EQ((alignUp(4 * GB - 8096, 4096)), NEO::getSizeToMap());
}
TEST(AllocatorHelper, givenExpectedSizeToReserveWhenGetSizeToReserveCalledThenExpectedValueReturned) {
EXPECT_EQ(maxNBitValue<47> / 4, NEO::getSizeToReserve());
EXPECT_EQ((maxNBitValue<47> + 1) / 4, NEO::getSizeToReserve());
}
TEST(DrmMemoryManagerCreate, whenCallCreateMemoryManagerThenDrmMemoryManagerIsCreated) {

View File

@@ -6,7 +6,6 @@
set(IGDRCL_SRCS_tests_mocks
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/mock_32bitAllocator.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_allocation_properties.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_async_event_handler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_async_event_handler.h

View File

@@ -48,7 +48,6 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
using DrmMemoryManager::allocateGraphicsMemoryWithAlignment;
using DrmMemoryManager::allocateGraphicsMemoryWithHostPtr;
using DrmMemoryManager::AllocationData;
using DrmMemoryManager::allocator32Bit;
using DrmMemoryManager::allocUserptr;
using DrmMemoryManager::createGraphicsAllocation;
using DrmMemoryManager::gfxPartition;

View File

@@ -1,81 +0,0 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/helpers/aligned_memory.h"
#include "runtime/os_interface/32bit_memory.h"
#include "runtime/os_interface/linux/drm_32bit_memory.cpp"
#include <limits>
namespace NEO {
constexpr uintptr_t startOf32MmapRegion = 0x40000000;
static bool failMmap = false;
static size_t maxMmapLength = std::numeric_limits<size_t>::max();
static uintptr_t offsetIn32BitRange = 0;
static uint32_t mmapCallCount = 0u;
static uint32_t unmapCallCount = 0u;
static uint32_t mmapFailCount = 0u;
void *MockMmap(void *addr, size_t length, int prot, int flags,
int fd, off_t offset) noexcept {
mmapCallCount++;
UNRECOVERABLE_IF(addr);
if (failMmap || length > maxMmapLength) {
return MAP_FAILED;
}
if (mmapFailCount > 0) {
mmapFailCount--;
return MAP_FAILED;
}
uintptr_t ptrToReturn = startOf32MmapRegion + offsetIn32BitRange;
offsetIn32BitRange += alignUp(length, MemoryConstants::pageSize);
return reinterpret_cast<void *>(ptrToReturn);
}
int MockMunmap(void *addr, size_t length) noexcept {
unmapCallCount++;
return 0;
}
class MockAllocator32Bit : public Allocator32bit {
public:
class OsInternalsPublic : public Allocator32bit::OsInternals {
};
MockAllocator32Bit(Allocator32bit::OsInternals *osInternalsIn) : Allocator32bit(osInternalsIn) {
}
MockAllocator32Bit() {
this->osInternals->mmapFunction = MockMmap;
this->osInternals->munmapFunction = MockMunmap;
resetState();
}
~MockAllocator32Bit() {
resetState();
}
static void resetState() {
failMmap = false;
maxMmapLength = std::numeric_limits<size_t>::max();
offsetIn32BitRange = 0u;
mmapCallCount = 0u;
unmapCallCount = 0u;
mmapFailCount = 0u;
}
static OsInternalsPublic *createOsInternals() {
return new OsInternalsPublic;
}
OsInternals *getOsInternals() const { return this->osInternals.get(); }
};
} // namespace NEO

View File

@@ -33,7 +33,6 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
using MemoryManager::allocateGraphicsMemoryInPreferredPool;
using MemoryManager::allocateGraphicsMemoryWithProperties;
using MemoryManager::AllocationData;
using MemoryManager::allocator32Bit;
using MemoryManager::createGraphicsAllocation;
using MemoryManager::createStorageInfoFromProperties;
using MemoryManager::getAllocationData;
@@ -193,10 +192,6 @@ class FailMemoryManager : public MockMemoryManager {
return 0;
};
uint64_t getMaxApplicationAddress() override {
return MemoryConstants::max32BitAppAddress;
};
GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) override {
return nullptr;
};

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/helpers/aligned_memory.h"
#include "runtime/os_interface/32bit_memory.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(Memory32Bit, Given32bitAllocatorWhenAskedForAllocationThen32BitPointerIsReturned) {
size_t size = 100u;
Allocator32bit allocator32bit;
auto ptr = allocator32bit.allocate(size);
uintptr_t address64bit = (uintptr_t)ptr - allocator32bit.getBase();
if (is32BitOsAllocatorAvailable) {
EXPECT_LT(address64bit, max32BitAddress);
}
EXPECT_LT(0u, address64bit);
auto ret = allocator32bit.free(ptr, size);
EXPECT_EQ(0, ret);
}
TEST(Memory32Bit, Given32bitAllocatorWhenAskedForAllocationThenPageAlignedPointerIsReturnedWithSizeAlignedToPage) {
size_t size = 100u;
Allocator32bit allocator32bit;
auto ptr = allocator32bit.allocate(size);
EXPECT_EQ(ptr, alignDown(ptr, MemoryConstants::pageSize));
auto ret = allocator32bit.free(ptr, size);
EXPECT_EQ(0, ret);
}
TEST(Memory32Bit, Given32bitAllocatorWithBaseAndSizeWhenAskedForBaseThenCorrectBaseIsReturned) {
uint64_t size = 100u;
uint64_t base = 0x23000;
Allocator32bit allocator32bit(base, size);
EXPECT_EQ(base, allocator32bit.getBase());
}

View File

@@ -6,7 +6,6 @@
set(IGDRCL_SRCS_tests_os_interface_base
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/32bit_memory_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debug_settings_manager_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/debug_settings_manager_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests.cpp

View File

@@ -11,10 +11,6 @@
namespace NEO {
size_t getSizeToMap() {
return static_cast<size_t>(1 * 1024 * 1024u);
}
size_t getSizeToReserve() {
// 4 x sizeof(Heap32) + 2 x sizeof(Standard/Standard64k)
return (4 * 4 + 2 * 4) * GB;

View File

@@ -10,10 +10,6 @@
#include "gtest/gtest.h"
TEST(AllocatorHelper, givenExpectedSizeToMapWhenGetSizetoMapCalledThenExpectedValueReturned) {
EXPECT_EQ(1 * 1024 * 1024u, NEO::getSizeToMap());
}
TEST(AllocatorHelper, givenExpectedSizeToReserveWhenGetSizeToReserveCalledThenExpectedValueReturned) {
EXPECT_EQ((4 * 4 + 2 * 4) * GB, NEO::getSizeToReserve());
}

View File

@@ -19,7 +19,6 @@
#include "runtime/mem_obj/image.h"
#include "runtime/memory_manager/host_ptr_manager.h"
#include "runtime/memory_manager/memory_constants.h"
#include "runtime/os_interface/32bit_memory.h"
#include "runtime/os_interface/linux/allocator_helper.h"
#include "runtime/os_interface/linux/drm_allocation.h"
#include "runtime/os_interface/linux/drm_buffer_object.h"
@@ -32,7 +31,6 @@
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/memory_management.h"
#include "unit_tests/mocks/linux/mock_drm_command_stream_receiver.h"
#include "unit_tests/mocks/mock_32bitAllocator.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_gmm.h"
@@ -1140,7 +1138,7 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenInternalHeapIs
memoryManager->setForce32BitAllocations(true);
std::unique_ptr<Device> pDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
size_t size = getSizeToMap();
size_t size = MemoryConstants::pageSize64k;
auto alloc = memoryManager->gfxPartition.heapAllocate(internalHeapIndex, size);
EXPECT_NE(0llu, alloc);
@@ -2393,41 +2391,6 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDefaultDrmMemoryManage
EXPECT_EQ(nullptr, memoryManager->getAlignedMallocRestrictions());
}
TEST(Allocator32BitUsingHeapAllocator, given32BitAllocatorWhenMMapFailsThenNullptrIsReturned) {
MockAllocator32Bit::resetState();
failMmap = true;
MockAllocator32Bit::OsInternalsPublic *osInternals = MockAllocator32Bit::createOsInternals();
osInternals->mmapFunction = MockMmap;
osInternals->munmapFunction = MockMunmap;
MockAllocator32Bit mock32BitAllocator{osInternals};
size_t size = 100u;
auto ptr = mock32BitAllocator.allocate(size);
EXPECT_EQ(0llu, ptr);
EXPECT_EQ(2u, mmapCallCount);
}
TEST(Allocator32BitUsingHeapAllocator, given32BitAllocatorWhenFirstMMapFailsThenSecondIsCalledWithSmallerSize) {
MockAllocator32Bit::resetState();
maxMmapLength = getSizeToMap() - 1;
MockAllocator32Bit::OsInternalsPublic *osInternals = MockAllocator32Bit::createOsInternals();
osInternals->mmapFunction = MockMmap;
osInternals->munmapFunction = MockMunmap;
MockAllocator32Bit mock32BitAllocator{osInternals};
size_t size = 100u;
auto ptr = mock32BitAllocator.allocate(size);
EXPECT_NE(0llu, ptr);
EXPECT_EQ(2u, mmapCallCount);
EXPECT_NE(nullptr, osInternals->heapBasePtr);
EXPECT_NE(0u, osInternals->heapSize);
}
TEST(Allocator32BitUsingHeapAllocator, given32bitAllocatorWhenFreeIsCalledWithMapFailedThenZeroIsReturned) {
MockAllocator32Bit::OsInternalsPublic *osInternals = MockAllocator32Bit::createOsInternals();
MockAllocator32Bit mock32BitAllocator{osInternals};
EXPECT_EQ(0, mock32BitAllocator.free(castToUint64(MAP_FAILED), 4096u));
}
#include <chrono>
#include <iostream>

View File

@@ -8,7 +8,6 @@
#include "runtime/helpers/string.h"
#include "runtime/memory_manager/allocations_list.h"
#include "runtime/memory_manager/graphics_allocation.h"
#include "runtime/os_interface/32bit_memory.h"
#include "runtime/platform/platform.h"
#include "runtime/program/program.h"
#include "test.h"