mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
fix: osAgnostic path for allocate with alignment
Resolves: NEO-9334 Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
fdb5a53f85
commit
67b0b18be3
@@ -811,7 +811,7 @@ TEST_F(DeviceHostPointerTest, givenHostPointerNotAcceptedByKernelThenNewAllocati
|
||||
EXPECT_EQ(NEO::AllocationType::internalHostMemory, allocation->getAllocationType());
|
||||
EXPECT_EQ(rootDeviceIndex, allocation->getRootDeviceIndex());
|
||||
EXPECT_NE(allocation->getUnderlyingBuffer(), reinterpret_cast<void *>(buffer));
|
||||
EXPECT_EQ(allocation->getUnderlyingBufferSize(), size);
|
||||
EXPECT_EQ(alignUp(size, MemoryConstants::pageSize), allocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(buffer, allocation->getUnderlyingBuffer(), size));
|
||||
|
||||
neoDevice->getMemoryManager()->freeGraphicsMemory(allocation);
|
||||
|
||||
@@ -701,8 +701,9 @@ TEST_F(KernelImmutableDataTests, givenKernelInitializedWithPrivateMemoryThenPriv
|
||||
|
||||
EXPECT_NE(nullptr, kernel->privateMemoryGraphicsAllocation);
|
||||
|
||||
size_t expectedSize = perHwThreadPrivateMemorySizeRequested *
|
||||
device->getNEODevice()->getDeviceInfo().computeUnitsUsedForScratch;
|
||||
size_t expectedSize = alignUp(perHwThreadPrivateMemorySizeRequested *
|
||||
device->getNEODevice()->getDeviceInfo().computeUnitsUsedForScratch,
|
||||
MemoryConstants::pageSize);
|
||||
EXPECT_EQ(expectedSize, kernel->privateMemoryGraphicsAllocation->getUnderlyingBufferSize());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -42,10 +42,10 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillBuffer(
|
||||
|
||||
if (patternSize == 1) {
|
||||
int patternInt = (uint32_t)((*(uint8_t *)pattern << 24) | (*(uint8_t *)pattern << 16) | (*(uint8_t *)pattern << 8) | *(uint8_t *)pattern);
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), sizeof(int), &patternInt, sizeof(int));
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), sizeof(uint32_t), &patternInt, sizeof(uint32_t));
|
||||
} else if (patternSize == 2) {
|
||||
int patternInt = (uint32_t)((*(uint16_t *)pattern << 16) | *(uint16_t *)pattern);
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), sizeof(int), &patternInt, sizeof(int));
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), sizeof(uint32_t), &patternInt, sizeof(uint32_t));
|
||||
} else {
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), patternSize, pattern, patternSize);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -502,10 +502,10 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemFill(void *svmPtr,
|
||||
|
||||
if (patternSize == 1) {
|
||||
int patternInt = (uint32_t)((*(uint8_t *)pattern << 24) | (*(uint8_t *)pattern << 16) | (*(uint8_t *)pattern << 8) | *(uint8_t *)pattern);
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), sizeof(int), &patternInt, sizeof(int));
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), sizeof(uint32_t), &patternInt, sizeof(uint32_t));
|
||||
} else if (patternSize == 2) {
|
||||
int patternInt = (uint32_t)((*(uint16_t *)pattern << 16) | *(uint16_t *)pattern);
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), sizeof(int), &patternInt, sizeof(int));
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), sizeof(uint32_t), &patternInt, sizeof(uint32_t));
|
||||
} else {
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), patternSize, pattern, patternSize);
|
||||
}
|
||||
|
||||
@@ -361,8 +361,8 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueScratchSpaceTests, GivenKernelRequiringScratc
|
||||
EXPECT_EQ(gsHaddress + ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, graphicsAllocation->getGpuAddress());
|
||||
}
|
||||
|
||||
auto allocationSize = scratchSize * pDevice->getDeviceInfo().computeUnitsUsedForScratch;
|
||||
EXPECT_EQ(graphicsAllocation->getUnderlyingBufferSize(), allocationSize);
|
||||
auto allocationSize = alignUp(scratchSize * pDevice->getDeviceInfo().computeUnitsUsedForScratch, MemoryConstants::pageMask);
|
||||
EXPECT_EQ(allocationSize, graphicsAllocation->getUnderlyingBufferSize());
|
||||
|
||||
// Generically validate this command
|
||||
Parse::template validateCommand<MEDIA_VFE_STATE *>(cmdList.begin(), itorCmd);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -140,7 +140,7 @@ HWTEST_P(EnqueueSvmMemFillTest, givenEnqueueSVMMemFillWhenUsingFillBufferBuilder
|
||||
}
|
||||
void validateInput(const BuiltinOpParams &conf) const override {
|
||||
auto patternAllocation = conf.srcMemObj->getMultiGraphicsAllocation().getDefaultGraphicsAllocation();
|
||||
EXPECT_EQ(patternSize, patternAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(MemoryConstants::pageSize, patternAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(pattern, patternAllocation->getUnderlyingBuffer(), patternSize));
|
||||
};
|
||||
const void *pattern;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -91,12 +91,12 @@ TEST_F(CommandStreamReceiverMultiRootDeviceTest, WhenCreatingCommandStreamGraphi
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 100u, 0u);
|
||||
EXPECT_EQ(allocation, commandStream.getGraphicsAllocation());
|
||||
EXPECT_EQ(128u, commandStream.getMaxAvailableSpace());
|
||||
EXPECT_EQ(MemoryConstants::pageSize, commandStream.getMaxAvailableSpace());
|
||||
EXPECT_EQ(expectedRootDeviceIndex, commandStream.getGraphicsAllocation()->getRootDeviceIndex());
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 1024u, 0u);
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, MemoryConstants::pageSize64k, 0u);
|
||||
EXPECT_NE(allocation, commandStream.getGraphicsAllocation());
|
||||
EXPECT_EQ(0u, commandStream.getMaxAvailableSpace() % MemoryConstants::pageSize64k);
|
||||
EXPECT_EQ(0u, commandStream.getMaxAvailableSpace() % MemoryConstants::pageSize);
|
||||
EXPECT_EQ(expectedRootDeviceIndex, commandStream.getGraphicsAllocation()->getRootDeviceIndex());
|
||||
mockMemoryManager->freeGraphicsMemory(commandStream.getGraphicsAllocation());
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "shared/source/memory_manager/memory_allocation.h"
|
||||
#include "shared/source/memory_manager/residency.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
|
||||
#include "shared/source/os_interface/product_helper.h"
|
||||
namespace NEO {
|
||||
struct OsHandleOsAgnostic : OsHandle {
|
||||
};
|
||||
@@ -62,30 +62,32 @@ bool OsAgnosticMemoryManager::is64kbPagesEnabled(const HardwareInfo *hwInfo) {
|
||||
}
|
||||
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) {
|
||||
auto sizeAligned = alignUp(allocationData.size, MemoryConstants::pageSize);
|
||||
auto alignment = alignUpNonZero(allocationData.alignment, MemoryConstants::pageSize);
|
||||
auto sizeAligned = alignUp(allocationData.size, alignment);
|
||||
MemoryAllocation *memoryAllocation = nullptr;
|
||||
|
||||
if (fakeBigAllocations && allocationData.size > bigAllocation) {
|
||||
if (fakeBigAllocations && sizeAligned > bigAllocation) {
|
||||
memoryAllocation = createMemoryAllocation(
|
||||
allocationData.type, nullptr, reinterpret_cast<void *>(dummyAddress), dummyAddress, allocationData.size, counter,
|
||||
allocationData.type, nullptr, reinterpret_cast<void *>(dummyAddress), dummyAddress, sizeAligned, counter,
|
||||
MemoryPool::system4KBPages, allocationData.rootDeviceIndex, allocationData.flags.uncacheable, allocationData.flags.flushL3, false);
|
||||
counter++;
|
||||
return memoryAllocation;
|
||||
}
|
||||
|
||||
auto alignment = allocationData.alignment;
|
||||
if (allocationData.type == AllocationType::svmCpu) {
|
||||
alignment = MemoryConstants::pageSize2M;
|
||||
sizeAligned = alignUp(allocationData.size, MemoryConstants::pageSize2M);
|
||||
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex];
|
||||
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
|
||||
alignment = productHelper.getSvmCpuAlignment();
|
||||
sizeAligned = alignUp(allocationData.size, alignment);
|
||||
}
|
||||
|
||||
auto cpuAllocationSize = sizeAligned;
|
||||
if (GraphicsAllocation::isDebugSurfaceAllocationType(allocationData.type)) {
|
||||
sizeAligned *= allocationData.storageInfo.getNumBanks();
|
||||
cpuAllocationSize *= allocationData.storageInfo.getNumBanks();
|
||||
}
|
||||
|
||||
auto ptr = allocateSystemMemory(sizeAligned, alignment ? alignUp(alignment, MemoryConstants::pageSize) : MemoryConstants::pageSize);
|
||||
auto ptr = allocateSystemMemory(cpuAllocationSize, alignment);
|
||||
if (ptr != nullptr) {
|
||||
memoryAllocation = createMemoryAllocation(allocationData.type, ptr, ptr, reinterpret_cast<uint64_t>(ptr), allocationData.size,
|
||||
memoryAllocation = createMemoryAllocation(allocationData.type, ptr, ptr, reinterpret_cast<uint64_t>(ptr), sizeAligned,
|
||||
counter, MemoryPool::system4KBPages, allocationData.rootDeviceIndex, allocationData.flags.uncacheable, allocationData.flags.flushL3, false);
|
||||
|
||||
if (allocationData.type == AllocationType::svmCpu) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -70,7 +70,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
aubCsr->getFlatBatchBufferHelper().flattenBatchBuffer(aubCsr->getRootDeviceIndex(), batchBuffer, sizeBatchBuffer, DispatchMode::immediateDispatch, pDevice->getDeviceBitfield()),
|
||||
[&](GraphicsAllocation *ptr) { memoryManager->freeGraphicsMemory(ptr); });
|
||||
EXPECT_NE(nullptr, flatBatchBuffer->getUnderlyingBuffer());
|
||||
EXPECT_EQ(alignUp(128u + 128u, MemoryConstants::pageSize), sizeBatchBuffer);
|
||||
size_t expectedAlignedSize = alignUp(128u, MemoryConstants::pageSize) + alignUp(128u, MemoryConstants::pageSize);
|
||||
EXPECT_EQ(expectedAlignedSize, sizeBatchBuffer);
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
memoryManager->freeGraphicsMemory(chainedBatchBuffer);
|
||||
|
||||
@@ -815,7 +815,10 @@ HWTEST_F(CommandStreamReceiverTest, givenOverrideCsrAllocationSizeWhenCreatingCo
|
||||
|
||||
bool ret = commandStreamReceiver.createPreemptionAllocation();
|
||||
ASSERT_TRUE(ret);
|
||||
EXPECT_EQ(static_cast<size_t>(overrideSize), commandStreamReceiver.preemptionAllocation->getUnderlyingBufferSize());
|
||||
auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
|
||||
auto aligment = gfxCoreHelper.getPreemptionAllocationAlignment();
|
||||
size_t expectedAlignedSize = alignUp(overrideSize, aligment);
|
||||
EXPECT_EQ(expectedAlignedSize, commandStreamReceiver.preemptionAllocation->getUnderlyingBufferSize());
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverTest, whenCreatingPreemptionAllocationForBcsThenNoAllocationIsCreated) {
|
||||
@@ -2068,11 +2071,11 @@ TEST_F(CommandStreamReceiverTest, givenMinimumSizeDoesNotExceedCurrentWhenCallin
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 100u, 0u);
|
||||
EXPECT_EQ(allocation, commandStream.getGraphicsAllocation());
|
||||
EXPECT_EQ(128u, commandStream.getMaxAvailableSpace());
|
||||
EXPECT_EQ(MemoryConstants::pageSize, commandStream.getMaxAvailableSpace());
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 128u, 0u);
|
||||
EXPECT_EQ(allocation, commandStream.getGraphicsAllocation());
|
||||
EXPECT_EQ(128u, commandStream.getMaxAvailableSpace());
|
||||
EXPECT_EQ(MemoryConstants::pageSize, commandStream.getMaxAvailableSpace());
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandStream.getGraphicsAllocation());
|
||||
}
|
||||
@@ -2081,7 +2084,7 @@ TEST_F(CommandStreamReceiverTest, givenMinimumSizeExceedsCurrentWhenCallingEnsur
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), 128u, AllocationType::commandBuffer, pDevice->getDeviceBitfield()});
|
||||
LinearStream commandStream{allocation};
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 129u, 0u);
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, MemoryConstants::pageSize + 1, 0u);
|
||||
EXPECT_NE(allocation, commandStream.getGraphicsAllocation());
|
||||
memoryManager->freeGraphicsMemory(commandStream.getGraphicsAllocation());
|
||||
}
|
||||
@@ -2090,11 +2093,13 @@ TEST_F(CommandStreamReceiverTest, givenMinimumSizeExceedsCurrentWhenCallingEnsur
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), 128u, AllocationType::commandBuffer, pDevice->getDeviceBitfield()});
|
||||
LinearStream commandStream{allocation};
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 129u, 0u);
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, MemoryConstants::pageSize + 1, 0u);
|
||||
|
||||
EXPECT_EQ(MemoryConstants::pageSize64k, commandStream.getGraphicsAllocation()->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(MemoryConstants::pageSize64k, commandStream.getMaxAvailableSpace());
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, MemoryConstants::pageSize64k + 1u, 0u);
|
||||
|
||||
EXPECT_EQ(2 * MemoryConstants::pageSize64k, commandStream.getGraphicsAllocation()->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(2 * MemoryConstants::pageSize64k, commandStream.getMaxAvailableSpace());
|
||||
|
||||
@@ -2108,7 +2113,7 @@ TEST_F(CommandStreamReceiverTest, givenForceCommandBufferAlignmentWhenEnsureComm
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), 128u, AllocationType::commandBuffer, pDevice->getDeviceBitfield()});
|
||||
LinearStream commandStream{allocation};
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 129u, 0u);
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, MemoryConstants::pageSize + 1, 0u);
|
||||
EXPECT_EQ(2 * MemoryConstants::megaByte, commandStream.getGraphicsAllocation()->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(2 * MemoryConstants::megaByte, commandStream.getMaxAvailableSpace());
|
||||
|
||||
@@ -2119,7 +2124,7 @@ TEST_F(CommandStreamReceiverTest, givenAdditionalAllocationSizeWhenCallingEnsure
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), 128u, AllocationType::commandBuffer, pDevice->getDeviceBitfield()});
|
||||
LinearStream commandStream{allocation};
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 129u, 350u);
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, MemoryConstants::pageSize + 1, 350u);
|
||||
EXPECT_NE(allocation, commandStream.getGraphicsAllocation());
|
||||
EXPECT_EQ(MemoryConstants::pageSize64k, commandStream.getGraphicsAllocation()->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(MemoryConstants::pageSize64k - 350u, commandStream.getMaxAvailableSpace());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "shared/source/compiler_interface/external_functions.h"
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/source/helpers/blit_helper.h"
|
||||
#include "shared/source/helpers/local_memory_access_modes.h"
|
||||
#include "shared/source/program/program_initialization.h"
|
||||
@@ -33,9 +34,10 @@ TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreNotExportedTh
|
||||
initData.resize(64, 7U);
|
||||
GraphicsAllocation *alloc = nullptr;
|
||||
|
||||
size_t aligmentSize = alignUp(initData.size(), MemoryConstants::pageSize);
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), 0u, true /* constant */, nullptr /* linker input */, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(aligmentSize, alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
EXPECT_EQ(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress()))));
|
||||
EXPECT_EQ(AllocationType::constantSurface, alloc->getAllocationType());
|
||||
@@ -43,7 +45,7 @@ TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreNotExportedTh
|
||||
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), 0u, false /* constant */, nullptr /* linker input */, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(aligmentSize, alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
EXPECT_EQ(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress()))));
|
||||
EXPECT_EQ(AllocationType::globalSurface, alloc->getAllocationType());
|
||||
@@ -51,7 +53,7 @@ TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreNotExportedTh
|
||||
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), 0u, true /* constant */, &emptyLinkerInput, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(aligmentSize, alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
EXPECT_EQ(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress()))));
|
||||
EXPECT_EQ(AllocationType::constantSurface, alloc->getAllocationType());
|
||||
@@ -59,7 +61,7 @@ TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreNotExportedTh
|
||||
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), 0u, false /* constant */, &emptyLinkerInput, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(aligmentSize, alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
EXPECT_EQ(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress()))));
|
||||
EXPECT_EQ(AllocationType::globalSurface, alloc->getAllocationType());
|
||||
@@ -80,6 +82,7 @@ TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreExportedThenM
|
||||
std::vector<uint8_t> initData;
|
||||
initData.resize(64, 7U);
|
||||
GraphicsAllocation *alloc = nullptr;
|
||||
size_t expectedAlignedSize = alignUp(initData.size(), MemoryConstants::pageSize);
|
||||
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), 0u, true /* constant */, &linkerInputExportGlobalConstants, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
@@ -94,7 +97,7 @@ TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreExportedThenM
|
||||
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), 0u, true /* constant */, &linkerInputExportGlobalVariables, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(expectedAlignedSize, alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
EXPECT_EQ(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress()))));
|
||||
EXPECT_EQ(AllocationType::constantSurface, alloc->getAllocationType());
|
||||
@@ -102,7 +105,7 @@ TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreExportedThenM
|
||||
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), 0u, false /* constant */, &linkerInputExportGlobalConstants, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(expectedAlignedSize, alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
EXPECT_EQ(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress()))));
|
||||
EXPECT_EQ(AllocationType::globalSurface, alloc->getAllocationType());
|
||||
@@ -130,31 +133,32 @@ TEST(AllocateGlobalSurfaceTest, GivenNullSvmAllocsManagerWhenGlobalsAreExportedT
|
||||
std::vector<uint8_t> initData;
|
||||
initData.resize(64, 7U);
|
||||
GraphicsAllocation *alloc = nullptr;
|
||||
size_t expectedAlignedSize = alignUp(initData.size(), MemoryConstants::pageSize);
|
||||
|
||||
alloc = allocateGlobalsSurface(nullptr, device, initData.size(), 0u, true /* constant */, &linkerInputExportGlobalConstants, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(expectedAlignedSize, alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
EXPECT_EQ(AllocationType::constantSurface, alloc->getAllocationType());
|
||||
device.getMemoryManager()->freeGraphicsMemory(alloc);
|
||||
|
||||
alloc = allocateGlobalsSurface(nullptr, device, initData.size(), 0u, true /* constant */, &linkerInputExportGlobalVariables, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(expectedAlignedSize, alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
EXPECT_EQ(AllocationType::constantSurface, alloc->getAllocationType());
|
||||
device.getMemoryManager()->freeGraphicsMemory(alloc);
|
||||
|
||||
alloc = allocateGlobalsSurface(nullptr, device, initData.size(), 0u, false /* constant */, &linkerInputExportGlobalConstants, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(expectedAlignedSize, alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
EXPECT_EQ(AllocationType::globalSurface, alloc->getAllocationType());
|
||||
device.getMemoryManager()->freeGraphicsMemory(alloc);
|
||||
|
||||
alloc = allocateGlobalsSurface(nullptr, device, initData.size(), 0u, false /* constant */, &linkerInputExportGlobalVariables, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(expectedAlignedSize, alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
EXPECT_EQ(AllocationType::globalSurface, alloc->getAllocationType());
|
||||
device.getMemoryManager()->freeGraphicsMemory(alloc);
|
||||
@@ -251,10 +255,10 @@ TEST(AllocateGlobalSurfaceTest, whenAllocatingGlobalSurfaceWithNonZeroZeroInitSi
|
||||
std::fill(initData.begin() + 32, initData.end(), 16u); // this data should not be transfered
|
||||
GraphicsAllocation *alloc = nullptr;
|
||||
size_t zeroInitSize = 32u;
|
||||
|
||||
size_t expectedAlignedSize = alignUp(initData.size(), MemoryConstants::pageSize);
|
||||
alloc = allocateGlobalsSurface(nullptr, device, initData.size(), zeroInitSize, true, &emptyLinkerInput, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
EXPECT_EQ(64u, alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(expectedAlignedSize, alloc->getUnderlyingBufferSize());
|
||||
|
||||
auto dataPtr = reinterpret_cast<uint8_t *>(alloc->getUnderlyingBuffer());
|
||||
EXPECT_EQ(0, memcmp(dataPtr, initData.data(), 32u));
|
||||
|
||||
Reference in New Issue
Block a user