mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
Enable 64kb pages when its allowed by platform
Change-Id: I10f02bd83beabeff929e16c7293324b81bfed054
This commit is contained in:
@@ -139,7 +139,7 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) {
|
|||||||
outDevice.executionEnvironment->commandStreamReceiver.reset(commandStreamReceiver);
|
outDevice.executionEnvironment->commandStreamReceiver.reset(commandStreamReceiver);
|
||||||
|
|
||||||
if (!outDevice.executionEnvironment->memoryManager) {
|
if (!outDevice.executionEnvironment->memoryManager) {
|
||||||
outDevice.executionEnvironment->memoryManager.reset(commandStreamReceiver->createMemoryManager(outDevice.deviceInfo.enabled64kbPages));
|
outDevice.executionEnvironment->memoryManager.reset(commandStreamReceiver->createMemoryManager(outDevice.getEnabled64kbPages()));
|
||||||
} else {
|
} else {
|
||||||
commandStreamReceiver->setMemoryManager(outDevice.executionEnvironment->memoryManager.get());
|
commandStreamReceiver->setMemoryManager(outDevice.executionEnvironment->memoryManager.get());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,7 +351,6 @@ void Device::initializeCaps() {
|
|||||||
deviceInfo.platformHostTimerResolution = getPlatformHostTimerResolution();
|
deviceInfo.platformHostTimerResolution = getPlatformHostTimerResolution();
|
||||||
|
|
||||||
deviceInfo.internalDriverVersion = CL_DEVICE_DRIVER_VERSION_INTEL_NEO1;
|
deviceInfo.internalDriverVersion = CL_DEVICE_DRIVER_VERSION_INTEL_NEO1;
|
||||||
deviceInfo.enabled64kbPages = getEnabled64kbPages();
|
|
||||||
|
|
||||||
deviceInfo.preferredGlobalAtomicAlignment = MemoryConstants::cacheLineSize;
|
deviceInfo.preferredGlobalAtomicAlignment = MemoryConstants::cacheLineSize;
|
||||||
deviceInfo.preferredLocalAtomicAlignment = MemoryConstants::cacheLineSize;
|
deviceInfo.preferredLocalAtomicAlignment = MemoryConstants::cacheLineSize;
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ struct DeviceInfo {
|
|||||||
bool cpuCopyAllowed;
|
bool cpuCopyAllowed;
|
||||||
bool packedYuvExtension;
|
bool packedYuvExtension;
|
||||||
cl_uint internalDriverVersion;
|
cl_uint internalDriverVersion;
|
||||||
bool enabled64kbPages;
|
|
||||||
bool sourceLevelDebuggerActive;
|
bool sourceLevelDebuggerActive;
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ void *MemoryManager::allocateSystemMemory(size_t size, size_t alignment) {
|
|||||||
|
|
||||||
GraphicsAllocation *MemoryManager::allocateGraphicsMemoryForSVM(size_t size, bool coherent) {
|
GraphicsAllocation *MemoryManager::allocateGraphicsMemoryForSVM(size_t size, bool coherent) {
|
||||||
GraphicsAllocation *graphicsAllocation = nullptr;
|
GraphicsAllocation *graphicsAllocation = nullptr;
|
||||||
if (enable64kbpages) {
|
if (peek64kbPagesEnabled()) {
|
||||||
graphicsAllocation = allocateGraphicsMemory64kb(size, MemoryConstants::pageSize64k, false);
|
graphicsAllocation = allocateGraphicsMemory64kb(size, MemoryConstants::pageSize64k, false);
|
||||||
} else {
|
} else {
|
||||||
graphicsAllocation = allocateGraphicsMemory(size);
|
graphicsAllocation = allocateGraphicsMemory(size);
|
||||||
@@ -424,7 +424,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &
|
|||||||
if (allocationData.hostPtr) {
|
if (allocationData.hostPtr) {
|
||||||
return allocateGraphicsMemory(allocationData.size, allocationData.hostPtr, allocationData.flags.forcePin);
|
return allocateGraphicsMemory(allocationData.size, allocationData.hostPtr, allocationData.flags.forcePin);
|
||||||
}
|
}
|
||||||
if (enable64kbpages && allocationData.flags.allow64kbPages) {
|
if (peek64kbPagesEnabled() && allocationData.flags.allow64kbPages) {
|
||||||
return allocateGraphicsMemory64kb(allocationData.size, MemoryConstants::pageSize64k, allocationData.flags.forcePin);
|
return allocateGraphicsMemory64kb(allocationData.size, MemoryConstants::pageSize64k, allocationData.flags.forcePin);
|
||||||
}
|
}
|
||||||
return allocateGraphicsMemory(allocationData.size, MemoryConstants::pageSize, allocationData.flags.forcePin, allocationData.flags.uncacheable);
|
return allocateGraphicsMemory(allocationData.size, MemoryConstants::pageSize, allocationData.flags.forcePin, allocationData.flags.uncacheable);
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ class MemoryManager {
|
|||||||
|
|
||||||
virtual GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) = 0;
|
virtual GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) = 0;
|
||||||
|
|
||||||
|
bool peek64kbPagesEnabled() const { return enable64kbpages; }
|
||||||
bool peekForce32BitAllocations() { return force32bitAllocations; }
|
bool peekForce32BitAllocations() { return force32bitAllocations; }
|
||||||
void setForce32BitAllocations(bool newValue);
|
void setForce32BitAllocations(bool newValue);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "unit_tests/mocks/mock_context.h"
|
#include "unit_tests/mocks/mock_context.h"
|
||||||
#include "runtime/command_queue/command_queue.h"
|
#include "runtime/command_queue/command_queue.h"
|
||||||
#include "runtime/device/device.h"
|
#include "runtime/device/device.h"
|
||||||
|
#include "runtime/memory_manager/svm_memory_manager.h"
|
||||||
|
|
||||||
using namespace OCLRT;
|
using namespace OCLRT;
|
||||||
|
|
||||||
@@ -108,8 +109,12 @@ TEST_F(clEnqueueSVMMigrateMemTests, invalidValue_NonZeroSizeIsNotContainedWithin
|
|||||||
void *ptrSvm = clSVMAlloc(pContext, CL_MEM_READ_WRITE, 256, 4);
|
void *ptrSvm = clSVMAlloc(pContext, CL_MEM_READ_WRITE, 256, 4);
|
||||||
ASSERT_NE(nullptr, ptrSvm);
|
ASSERT_NE(nullptr, ptrSvm);
|
||||||
|
|
||||||
|
auto svmAlloc = pContext->getSVMAllocsManager()->getSVMAlloc(ptrSvm);
|
||||||
|
EXPECT_NE(nullptr, svmAlloc);
|
||||||
|
size_t allocSize = svmAlloc->getUnderlyingBufferSize();
|
||||||
|
|
||||||
const void *svmPtrs[] = {ptrSvm};
|
const void *svmPtrs[] = {ptrSvm};
|
||||||
const size_t sizes[] = {256 + 1};
|
const size_t sizes[] = {allocSize + 1};
|
||||||
auto retVal = clEnqueueSVMMigrateMem(
|
auto retVal = clEnqueueSVMMigrateMem(
|
||||||
pCommandQueue, // cl_command_queue command_queue
|
pCommandQueue, // cl_command_queue command_queue
|
||||||
1, // cl_uint num_svm_pointers
|
1, // cl_uint num_svm_pointers
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "runtime/memory_manager/svm_memory_manager.h"
|
||||||
#include "cl_api_tests.h"
|
#include "cl_api_tests.h"
|
||||||
#include "unit_tests/fixtures/device_fixture.h"
|
#include "unit_tests/fixtures/device_fixture.h"
|
||||||
#include "unit_tests/mocks/mock_kernel.h"
|
#include "unit_tests/mocks/mock_kernel.h"
|
||||||
@@ -193,8 +194,10 @@ TEST_F(clSetKernelArgSVMPointer_, SetKernelArgSVMPointerWithOffset_invalidArgVal
|
|||||||
const DeviceInfo &devInfo = pDevice->getDeviceInfo();
|
const DeviceInfo &devInfo = pDevice->getDeviceInfo();
|
||||||
if (devInfo.svmCapabilities != 0) {
|
if (devInfo.svmCapabilities != 0) {
|
||||||
void *ptrSvm = clSVMAlloc(pContext, CL_MEM_READ_WRITE, 256, 4);
|
void *ptrSvm = clSVMAlloc(pContext, CL_MEM_READ_WRITE, 256, 4);
|
||||||
size_t offset = alignUp(512, MemoryConstants::pageSize) + 1;
|
auto svmAlloc = pContext->getSVMAllocsManager()->getSVMAlloc(ptrSvm);
|
||||||
EXPECT_NE(nullptr, ptrSvm);
|
EXPECT_NE(nullptr, svmAlloc);
|
||||||
|
|
||||||
|
size_t offset = svmAlloc->getUnderlyingBufferSize() + 1;
|
||||||
|
|
||||||
auto retVal = clSetKernelArgSVMPointer(
|
auto retVal = clSetKernelArgSVMPointer(
|
||||||
pMockKernel, // cl_kernel kernel
|
pMockKernel, // cl_kernel kernel
|
||||||
|
|||||||
@@ -25,8 +25,10 @@
|
|||||||
#include "runtime/event/event.h"
|
#include "runtime/event/event.h"
|
||||||
#include "runtime/mem_obj/image.h"
|
#include "runtime/mem_obj/image.h"
|
||||||
#include "runtime/utilities/tag_allocator.h"
|
#include "runtime/utilities/tag_allocator.h"
|
||||||
|
#include "runtime/os_interface/os_interface.h"
|
||||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||||
#include "unit_tests/helpers/memory_management.h"
|
#include "unit_tests/helpers/memory_management.h"
|
||||||
|
#include "unit_tests/helpers/variable_backup.h"
|
||||||
#include "unit_tests/utilities/containers_tests_helpers.h"
|
#include "unit_tests/utilities/containers_tests_helpers.h"
|
||||||
#include "unit_tests/fixtures/memory_allocator_fixture.h"
|
#include "unit_tests/fixtures/memory_allocator_fixture.h"
|
||||||
#include "unit_tests/fixtures/memory_manager_fixture.h"
|
#include "unit_tests/fixtures/memory_manager_fixture.h"
|
||||||
@@ -863,6 +865,26 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesDisabledWhenAllocat
|
|||||||
memoryManager.freeGraphicsMemory(svmAllocation);
|
memoryManager.freeGraphicsMemory(svmAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(OsAgnosticMemoryManager, givenDeviceWith64kbPagesEnabledWhenCreatingMemoryManagerThenAllowFor64kbAllocations) {
|
||||||
|
VariableBackup<bool> os64kbPagesEnabled(&OSInterface::osEnabled64kbPages, true);
|
||||||
|
|
||||||
|
HardwareInfo localHwInfo = *platformDevices[0];
|
||||||
|
localHwInfo.capabilityTable.ftr64KBpages = true;
|
||||||
|
|
||||||
|
std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<Device>(&localHwInfo));
|
||||||
|
EXPECT_TRUE(device->getEnabled64kbPages());
|
||||||
|
EXPECT_TRUE(device->getMemoryManager()->peek64kbPagesEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(OsAgnosticMemoryManager, givenDeviceWith64kbPagesDisbledWhenCreatingMemoryManagerThenDisallowFor64kbAllocations) {
|
||||||
|
HardwareInfo localHwInfo = *platformDevices[0];
|
||||||
|
localHwInfo.capabilityTable.ftr64KBpages = false;
|
||||||
|
|
||||||
|
std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<Device>(&localHwInfo));
|
||||||
|
EXPECT_FALSE(device->getEnabled64kbPages());
|
||||||
|
EXPECT_FALSE(device->getMemoryManager()->peek64kbPagesEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocateGraphicsMemoryForSVMIsCalledThen64KBGraphicsAllocationIsReturned) {
|
TEST(OsAgnosticMemoryManager, givenMemoryManagerWith64KBPagesEnabledWhenAllocateGraphicsMemoryForSVMIsCalledThen64KBGraphicsAllocationIsReturned) {
|
||||||
OsAgnosticMemoryManager memoryManager(true);
|
OsAgnosticMemoryManager memoryManager(true);
|
||||||
auto size = 4096u;
|
auto size = 4096u;
|
||||||
|
|||||||
Reference in New Issue
Block a user