mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 18:00:01 +08:00
Introduce debug flag ForceExtendedUSMBufferSize usage for L0
Forces extended buffer size by adding pageSize specify by number when debug flag is >=1 in L0 USM calls Usage: ForceExtendedUSMBufferSize=2 size += (2 * pageSize) Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a95198521e
commit
f7a5d29085
@@ -57,6 +57,9 @@ ze_result_t ContextImp::allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc,
|
|||||||
size_t size,
|
size_t size,
|
||||||
size_t alignment,
|
size_t alignment,
|
||||||
void **ptr) {
|
void **ptr) {
|
||||||
|
if (NEO::DebugManager.flags.ForceExtendedUSMBufferSize.get() >= 1) {
|
||||||
|
size += (MemoryConstants::pageSize * NEO::DebugManager.flags.ForceExtendedUSMBufferSize.get());
|
||||||
|
}
|
||||||
|
|
||||||
bool relaxedSizeAllowed = NEO::DebugManager.flags.AllowUnrestrictedSize.get();
|
bool relaxedSizeAllowed = NEO::DebugManager.flags.AllowUnrestrictedSize.get();
|
||||||
if (hostDesc->pNext) {
|
if (hostDesc->pNext) {
|
||||||
@@ -104,6 +107,9 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
|
|||||||
const ze_device_mem_alloc_desc_t *deviceDesc,
|
const ze_device_mem_alloc_desc_t *deviceDesc,
|
||||||
size_t size,
|
size_t size,
|
||||||
size_t alignment, void **ptr) {
|
size_t alignment, void **ptr) {
|
||||||
|
if (NEO::DebugManager.flags.ForceExtendedUSMBufferSize.get() >= 1) {
|
||||||
|
size += (MemoryConstants::pageSize * NEO::DebugManager.flags.ForceExtendedUSMBufferSize.get());
|
||||||
|
}
|
||||||
|
|
||||||
auto device = Device::fromHandle(hDevice);
|
auto device = Device::fromHandle(hDevice);
|
||||||
if (isDeviceDefinedForThisContext(device) == false) {
|
if (isDeviceDefinedForThisContext(device) == false) {
|
||||||
@@ -185,6 +191,9 @@ ze_result_t ContextImp::allocSharedMem(ze_device_handle_t hDevice,
|
|||||||
size_t size,
|
size_t size,
|
||||||
size_t alignment,
|
size_t alignment,
|
||||||
void **ptr) {
|
void **ptr) {
|
||||||
|
if (NEO::DebugManager.flags.ForceExtendedUSMBufferSize.get() >= 1) {
|
||||||
|
size += (MemoryConstants::pageSize * NEO::DebugManager.flags.ForceExtendedUSMBufferSize.get());
|
||||||
|
}
|
||||||
|
|
||||||
auto device = this->devices.begin()->second;
|
auto device = this->devices.begin()->second;
|
||||||
if (hDevice != nullptr) {
|
if (hDevice != nullptr) {
|
||||||
|
|||||||
@@ -277,6 +277,64 @@ TEST_F(MemoryTest, givenSharedPointerThenDriverGetAllocPropertiesReturnsExpected
|
|||||||
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(MemoryTest, givenForceExtendedUSMBufferSizeDebugFlagWhenUSMAllocationIsCreatedThenSizeIsProperlyExtended) {
|
||||||
|
DebugManagerStateRestore restorer;
|
||||||
|
|
||||||
|
constexpr auto bufferSize = 16;
|
||||||
|
auto pageSizeNumber = 2;
|
||||||
|
NEO::DebugManager.flags.ForceExtendedUSMBufferSize.set(pageSizeNumber);
|
||||||
|
auto extendedBufferSize = bufferSize + MemoryConstants::pageSize * pageSizeNumber;
|
||||||
|
size_t alignment = 1u;
|
||||||
|
void *ptr = nullptr;
|
||||||
|
|
||||||
|
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||||
|
ze_host_mem_alloc_desc_t hostDesc = {};
|
||||||
|
ze_result_t result = context->allocSharedMem(device->toHandle(), &deviceDesc,
|
||||||
|
&hostDesc, bufferSize, alignment, &ptr);
|
||||||
|
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||||
|
EXPECT_NE(nullptr, ptr);
|
||||||
|
|
||||||
|
auto alloc = context->getDriverHandle()->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||||
|
EXPECT_NE(alloc, nullptr);
|
||||||
|
EXPECT_EQ(alloc->size, extendedBufferSize);
|
||||||
|
|
||||||
|
result = context->freeMem(ptr);
|
||||||
|
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
||||||
|
|
||||||
|
pageSizeNumber = 4;
|
||||||
|
NEO::DebugManager.flags.ForceExtendedUSMBufferSize.set(pageSizeNumber);
|
||||||
|
extendedBufferSize = bufferSize + MemoryConstants::pageSize * pageSizeNumber;
|
||||||
|
|
||||||
|
hostDesc = {};
|
||||||
|
result = context->allocHostMem(&hostDesc, bufferSize, alignment, &ptr);
|
||||||
|
|
||||||
|
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||||
|
EXPECT_NE(nullptr, ptr);
|
||||||
|
|
||||||
|
alloc = context->getDriverHandle()->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||||
|
EXPECT_NE(alloc, nullptr);
|
||||||
|
EXPECT_EQ(alloc->size, extendedBufferSize);
|
||||||
|
|
||||||
|
result = context->freeMem(ptr);
|
||||||
|
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
||||||
|
|
||||||
|
pageSizeNumber = 8;
|
||||||
|
NEO::DebugManager.flags.ForceExtendedUSMBufferSize.set(pageSizeNumber);
|
||||||
|
extendedBufferSize = bufferSize + MemoryConstants::pageSize * pageSizeNumber;
|
||||||
|
|
||||||
|
deviceDesc = {};
|
||||||
|
result = context->allocDeviceMem(device->toHandle(), &deviceDesc, bufferSize, alignment, &ptr);
|
||||||
|
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||||
|
EXPECT_NE(nullptr, ptr);
|
||||||
|
|
||||||
|
alloc = context->getDriverHandle()->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||||
|
EXPECT_NE(alloc, nullptr);
|
||||||
|
EXPECT_EQ(alloc->size, extendedBufferSize);
|
||||||
|
|
||||||
|
result = context->freeMem(ptr);
|
||||||
|
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(MemoryTest, givenHostPointerThenDriverGetAllocPropertiesReturnsMemoryId) {
|
TEST_F(MemoryTest, givenHostPointerThenDriverGetAllocPropertiesReturnsMemoryId) {
|
||||||
size_t size = 10;
|
size_t size = 10;
|
||||||
size_t alignment = 1u;
|
size_t alignment = 1u;
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, EngineUsageHint, -1, "-1: default, >=0: engine u
|
|||||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceBcsEngineIndex, -1, "-1: default, >=0 Copy Engine index")
|
DECLARE_DEBUG_VARIABLE(int32_t, ForceBcsEngineIndex, -1, "-1: default, >=0 Copy Engine index")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, Force2dImageAsArray, -1, "-1: default, 0: WA Disabled, 1: Forces surface state of 2dImage to array")
|
DECLARE_DEBUG_VARIABLE(int32_t, Force2dImageAsArray, -1, "-1: default, 0: WA Disabled, 1: Forces surface state of 2dImage to array")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceExtendedBufferSize, -1, "-1: default, 0: disabled, >=1: Forces extended buffer size by specify pageSize number in clCreateBuffer, clCreateBufferWithProperties and clCreateBufferWithPropertiesINTEL calls")
|
DECLARE_DEBUG_VARIABLE(int32_t, ForceExtendedBufferSize, -1, "-1: default, 0: disabled, >=1: Forces extended buffer size by specify pageSize number in clCreateBuffer, clCreateBufferWithProperties and clCreateBufferWithPropertiesINTEL calls")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceExtendedUSMBufferSize, -1, "-1: default, 0: disabled, >=1: Forces extended buffer size by specify pageSize number in clHostMemAllocINTEL, clDeviceMemAllocINTEL and clSharedMemAllocINTEL calls")
|
DECLARE_DEBUG_VARIABLE(int32_t, ForceExtendedUSMBufferSize, -1, "-1: default, 0: disabled, >=1: Forces extended buffer size by specify pageSize number in USM calls")
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceSimdMessageSizeInWalker, -1, "-1: default, >=0 Program given value in Walker command for SIMD size")
|
DECLARE_DEBUG_VARIABLE(int32_t, ForceSimdMessageSizeInWalker, -1, "-1: default, >=0 Program given value in Walker command for SIMD size")
|
||||||
/*LOGGING FLAGS*/
|
/*LOGGING FLAGS*/
|
||||||
DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")
|
DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")
|
||||||
|
|||||||
Reference in New Issue
Block a user