2020-01-11 18:25:26 +01:00
|
|
|
/*
|
2021-01-21 13:10:13 +01:00
|
|
|
* Copyright (C) 2020-2021 Intel Corporation
|
2020-01-11 18:25:26 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/program/program_initialization.h"
|
2021-01-21 13:10:13 +01:00
|
|
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
|
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
|
|
|
|
#include "shared/test/common/test_macros/test_checks_shared.h"
|
2020-02-24 01:01:38 +01:00
|
|
|
#include "shared/test/unit_test/compiler_interface/linker_mock.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2020-03-18 13:08:45 +01:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_svm_manager.h"
|
2020-01-11 18:25:26 +01:00
|
|
|
|
|
|
|
|
#include "gmock/gmock.h"
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
2020-03-19 14:26:08 +01:00
|
|
|
using namespace NEO;
|
|
|
|
|
|
2020-01-11 18:25:26 +01:00
|
|
|
TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreNotExportedThenMemoryIsAllocatedAsNonSvmAllocation) {
|
2020-03-05 18:13:32 +01:00
|
|
|
auto &device = *(new MockDevice);
|
2020-07-10 17:04:42 +02:00
|
|
|
REQUIRE_SVM_OR_SKIP(&device);
|
2020-03-05 18:13:32 +01:00
|
|
|
MockClDevice clDevice{&device};
|
2021-03-08 12:27:14 +00:00
|
|
|
MockSVMAllocsManager svmAllocsManager(device.getMemoryManager(), false);
|
2020-01-11 18:25:26 +01:00
|
|
|
WhiteBox<LinkerInput> emptyLinkerInput;
|
|
|
|
|
std::vector<uint8_t> initData;
|
|
|
|
|
initData.resize(64, 7U);
|
|
|
|
|
GraphicsAllocation *alloc = nullptr;
|
|
|
|
|
|
2020-04-14 14:53:52 +02:00
|
|
|
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), true /* constant */, nullptr /* linker input */, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), 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(GraphicsAllocation::AllocationType::CONSTANT_SURFACE, alloc->getAllocationType());
|
|
|
|
|
device.getMemoryManager()->freeGraphicsMemory(alloc);
|
|
|
|
|
|
2020-04-14 14:53:52 +02:00
|
|
|
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), false /* constant */, nullptr /* linker input */, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), 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(GraphicsAllocation::AllocationType::GLOBAL_SURFACE, alloc->getAllocationType());
|
|
|
|
|
device.getMemoryManager()->freeGraphicsMemory(alloc);
|
|
|
|
|
|
2020-04-14 14:53:52 +02:00
|
|
|
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), true /* constant */, &emptyLinkerInput, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), 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(GraphicsAllocation::AllocationType::CONSTANT_SURFACE, alloc->getAllocationType());
|
|
|
|
|
device.getMemoryManager()->freeGraphicsMemory(alloc);
|
|
|
|
|
|
2020-04-14 14:53:52 +02:00
|
|
|
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), false /* constant */, &emptyLinkerInput, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), 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(GraphicsAllocation::AllocationType::GLOBAL_SURFACE, alloc->getAllocationType());
|
|
|
|
|
device.getMemoryManager()->freeGraphicsMemory(alloc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreExportedThenMemoryIsAllocatedAsSvmAllocation) {
|
2020-03-05 18:13:32 +01:00
|
|
|
auto &device = *(new MockDevice);
|
2020-07-10 17:04:42 +02:00
|
|
|
REQUIRE_SVM_OR_SKIP(&device);
|
2020-03-05 18:13:32 +01:00
|
|
|
MockClDevice clDevice{&device};
|
2020-01-11 18:25:26 +01:00
|
|
|
MockMemoryManager memoryManager;
|
2021-03-08 12:27:14 +00:00
|
|
|
MockSVMAllocsManager svmAllocsManager(&memoryManager, false);
|
2020-01-11 18:25:26 +01:00
|
|
|
WhiteBox<LinkerInput> linkerInputExportGlobalVariables;
|
|
|
|
|
WhiteBox<LinkerInput> linkerInputExportGlobalConstants;
|
|
|
|
|
linkerInputExportGlobalVariables.traits.exportsGlobalVariables = true;
|
|
|
|
|
linkerInputExportGlobalConstants.traits.exportsGlobalConstants = true;
|
|
|
|
|
std::vector<uint8_t> initData;
|
|
|
|
|
initData.resize(64, 7U);
|
|
|
|
|
GraphicsAllocation *alloc = nullptr;
|
|
|
|
|
|
2020-04-14 14:53:52 +02:00
|
|
|
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), true /* constant */, &linkerInputExportGlobalConstants, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
|
|
|
|
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
|
|
|
|
ASSERT_NE(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress()))));
|
|
|
|
|
EXPECT_FALSE(alloc->isMemObjectsAllocationWithWritableFlags());
|
|
|
|
|
svmAllocsManager.freeSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress())));
|
|
|
|
|
|
2020-04-14 14:53:52 +02:00
|
|
|
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), true /* constant */, &linkerInputExportGlobalVariables, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), 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()))));
|
|
|
|
|
device.getMemoryManager()->freeGraphicsMemory(alloc);
|
|
|
|
|
|
2020-04-14 14:53:52 +02:00
|
|
|
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), false /* constant */, &linkerInputExportGlobalConstants, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), 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()))));
|
|
|
|
|
device.getMemoryManager()->freeGraphicsMemory(alloc);
|
|
|
|
|
|
2020-04-14 14:53:52 +02:00
|
|
|
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), false /* constant */, &linkerInputExportGlobalVariables, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
|
|
|
|
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
|
|
|
|
EXPECT_NE(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress()))));
|
|
|
|
|
EXPECT_TRUE(alloc->isMemObjectsAllocationWithWritableFlags());
|
|
|
|
|
svmAllocsManager.freeSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress())));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(AllocateGlobalSurfaceTest, GivenNullSvmAllocsManagerWhenGlobalsAreExportedThenMemoryIsAllocatedAsNonSvmAllocation) {
|
2020-07-10 17:04:42 +02:00
|
|
|
auto pDevice = new MockDevice{};
|
|
|
|
|
MockClDevice clDevice{pDevice};
|
2020-01-11 18:25:26 +01:00
|
|
|
WhiteBox<LinkerInput> linkerInputExportGlobalVariables;
|
|
|
|
|
WhiteBox<LinkerInput> linkerInputExportGlobalConstants;
|
|
|
|
|
linkerInputExportGlobalVariables.traits.exportsGlobalVariables = true;
|
|
|
|
|
linkerInputExportGlobalConstants.traits.exportsGlobalConstants = true;
|
|
|
|
|
std::vector<uint8_t> initData;
|
|
|
|
|
initData.resize(64, 7U);
|
|
|
|
|
GraphicsAllocation *alloc = nullptr;
|
|
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(nullptr, *pDevice, initData.size(), true /* constant */, &linkerInputExportGlobalConstants, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
|
|
|
|
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
|
|
|
|
EXPECT_EQ(GraphicsAllocation::AllocationType::CONSTANT_SURFACE, alloc->getAllocationType());
|
2020-07-10 17:04:42 +02:00
|
|
|
pDevice->getMemoryManager()->freeGraphicsMemory(alloc);
|
2020-01-11 18:25:26 +01:00
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(nullptr, *pDevice, initData.size(), true /* constant */, &linkerInputExportGlobalVariables, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
|
|
|
|
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
|
|
|
|
EXPECT_EQ(GraphicsAllocation::AllocationType::CONSTANT_SURFACE, alloc->getAllocationType());
|
2020-07-10 17:04:42 +02:00
|
|
|
pDevice->getMemoryManager()->freeGraphicsMemory(alloc);
|
2020-01-11 18:25:26 +01:00
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(nullptr, *pDevice, initData.size(), false /* constant */, &linkerInputExportGlobalConstants, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
|
|
|
|
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
|
|
|
|
EXPECT_EQ(GraphicsAllocation::AllocationType::GLOBAL_SURFACE, alloc->getAllocationType());
|
2020-07-10 17:04:42 +02:00
|
|
|
pDevice->getMemoryManager()->freeGraphicsMemory(alloc);
|
2020-01-11 18:25:26 +01:00
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(nullptr, *pDevice, initData.size(), false /* constant */, &linkerInputExportGlobalVariables, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
ASSERT_NE(nullptr, alloc);
|
|
|
|
|
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
|
|
|
|
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
|
|
|
|
EXPECT_EQ(GraphicsAllocation::AllocationType::GLOBAL_SURFACE, alloc->getAllocationType());
|
2020-07-10 17:04:42 +02:00
|
|
|
pDevice->getMemoryManager()->freeGraphicsMemory(alloc);
|
2020-01-11 18:25:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(AllocateGlobalSurfaceTest, WhenGlobalsAreNotExportedAndAllocationFailsThenGracefullyReturnsNullptr) {
|
2020-07-10 17:04:42 +02:00
|
|
|
auto pDevice = new MockDevice{};
|
|
|
|
|
MockClDevice clDevice{pDevice};
|
|
|
|
|
auto memoryManager = std::make_unique<MockMemoryManager>(*clDevice.getExecutionEnvironment());
|
2020-01-11 18:25:26 +01:00
|
|
|
memoryManager->failInAllocateWithSizeAndAlignment = true;
|
2020-07-10 17:04:42 +02:00
|
|
|
clDevice.injectMemoryManager(memoryManager.release());
|
2021-03-08 12:27:14 +00:00
|
|
|
MockSVMAllocsManager mockSvmAllocsManager(clDevice.getMemoryManager(), false);
|
2020-01-11 18:25:26 +01:00
|
|
|
WhiteBox<LinkerInput> emptyLinkerInput;
|
|
|
|
|
std::vector<uint8_t> initData;
|
|
|
|
|
initData.resize(64, 7U);
|
|
|
|
|
GraphicsAllocation *alloc = nullptr;
|
|
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(&mockSvmAllocsManager, *pDevice, initData.size(), true /* constant */, nullptr /* linker input */, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
EXPECT_EQ(nullptr, alloc);
|
|
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(&mockSvmAllocsManager, *pDevice, initData.size(), false /* constant */, nullptr /* linker input */, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
EXPECT_EQ(nullptr, alloc);
|
|
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(&mockSvmAllocsManager, *pDevice, initData.size(), true /* constant */, &emptyLinkerInput, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
EXPECT_EQ(nullptr, alloc);
|
|
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(&mockSvmAllocsManager, *pDevice, initData.size(), false /* constant */, &emptyLinkerInput, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
EXPECT_EQ(nullptr, alloc);
|
|
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(nullptr /* svmAllocsManager */, *pDevice, initData.size(), true /* constant */, nullptr /* linker input */, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
EXPECT_EQ(nullptr, alloc);
|
|
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(nullptr /* svmAllocsManager */, *pDevice, initData.size(), false /* constant */, nullptr /* linker input */, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
EXPECT_EQ(nullptr, alloc);
|
|
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(nullptr /* svmAllocsManager */, *pDevice, initData.size(), true /* constant */, &emptyLinkerInput, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
EXPECT_EQ(nullptr, alloc);
|
|
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(nullptr /* svmAllocsManager */, *pDevice, initData.size(), false /* constant */, &emptyLinkerInput, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
EXPECT_EQ(nullptr, alloc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(AllocateGlobalSurfaceTest, WhenGlobalsAreExportedAndAllocationFailsThenGracefullyReturnsNullptr) {
|
2020-07-10 17:04:42 +02:00
|
|
|
auto pDevice = new MockDevice{};
|
|
|
|
|
MockClDevice clDevice{pDevice};
|
|
|
|
|
MockMemoryManager memoryManager{*clDevice.getExecutionEnvironment()};
|
2021-03-08 12:27:14 +00:00
|
|
|
MockSVMAllocsManager svmAllocsManager(&memoryManager, false);
|
2020-01-11 18:25:26 +01:00
|
|
|
memoryManager.failInAllocateWithSizeAndAlignment = true;
|
|
|
|
|
WhiteBox<LinkerInput> linkerInputExportGlobalVariables;
|
|
|
|
|
WhiteBox<LinkerInput> linkerInputExportGlobalConstants;
|
|
|
|
|
linkerInputExportGlobalVariables.traits.exportsGlobalVariables = true;
|
|
|
|
|
linkerInputExportGlobalConstants.traits.exportsGlobalConstants = true;
|
|
|
|
|
std::vector<uint8_t> initData;
|
|
|
|
|
initData.resize(64, 7U);
|
|
|
|
|
GraphicsAllocation *alloc = nullptr;
|
|
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(&svmAllocsManager, *pDevice, initData.size(), true /* constant */, &linkerInputExportGlobalConstants, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
EXPECT_EQ(nullptr, alloc);
|
|
|
|
|
|
2020-07-10 17:04:42 +02:00
|
|
|
alloc = allocateGlobalsSurface(&svmAllocsManager, *pDevice, initData.size(), false /* constant */, &linkerInputExportGlobalVariables, initData.data());
|
2020-01-11 18:25:26 +01:00
|
|
|
EXPECT_EQ(nullptr, alloc);
|
|
|
|
|
}
|
2020-10-06 14:27:04 +02:00
|
|
|
|
|
|
|
|
TEST(AllocateGlobalSurfaceTest, GivenAllocationInLocalMemoryWhichRequiresBlitterWhenAllocatingNonSvmAllocationThenBlitterIsUsed) {
|
|
|
|
|
REQUIRE_SVM_OR_SKIP(defaultHwInfo.get());
|
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
|
|
|
|
|
|
uint32_t blitsCounter = 0;
|
|
|
|
|
uint32_t expectedBlitsCount = 0;
|
|
|
|
|
auto mockBlitMemoryToAllocation = [&blitsCounter](const Device &device, GraphicsAllocation *memory, size_t offset, const void *hostPtr,
|
|
|
|
|
Vec3<size_t> size) -> BlitOperationResult {
|
|
|
|
|
blitsCounter++;
|
|
|
|
|
return BlitOperationResult::Success;
|
|
|
|
|
};
|
|
|
|
|
VariableBackup<BlitHelperFunctions::BlitMemoryToAllocationFunc> blitMemoryToAllocationFuncBackup{
|
|
|
|
|
&BlitHelperFunctions::blitMemoryToAllocation, mockBlitMemoryToAllocation};
|
|
|
|
|
|
|
|
|
|
LocalMemoryAccessMode localMemoryAccessModes[] = {
|
|
|
|
|
LocalMemoryAccessMode::Default,
|
|
|
|
|
LocalMemoryAccessMode::CpuAccessAllowed,
|
|
|
|
|
LocalMemoryAccessMode::CpuAccessDisallowed};
|
|
|
|
|
|
|
|
|
|
std::vector<uint8_t> initData;
|
|
|
|
|
initData.resize(64, 7U);
|
|
|
|
|
|
|
|
|
|
for (auto localMemoryAccessMode : localMemoryAccessModes) {
|
|
|
|
|
DebugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(localMemoryAccessMode));
|
|
|
|
|
for (auto isLocalMemorySupported : ::testing::Bool()) {
|
|
|
|
|
DebugManager.flags.EnableLocalMemory.set(isLocalMemorySupported);
|
|
|
|
|
MockDevice device;
|
2020-10-07 13:39:45 +02:00
|
|
|
device.getExecutionEnvironment()->rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true;
|
2021-03-08 12:27:14 +00:00
|
|
|
MockSVMAllocsManager svmAllocsManager(device.getMemoryManager(), false);
|
2020-10-06 14:27:04 +02:00
|
|
|
|
|
|
|
|
auto pAllocation = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), true /* constant */,
|
|
|
|
|
nullptr /* linker input */, initData.data());
|
|
|
|
|
ASSERT_NE(nullptr, pAllocation);
|
|
|
|
|
EXPECT_EQ(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(pAllocation->getGpuAddress()))));
|
|
|
|
|
EXPECT_EQ(GraphicsAllocation::AllocationType::CONSTANT_SURFACE, pAllocation->getAllocationType());
|
|
|
|
|
|
|
|
|
|
if (pAllocation->isAllocatedInLocalMemoryPool() && (localMemoryAccessMode == LocalMemoryAccessMode::CpuAccessDisallowed)) {
|
|
|
|
|
expectedBlitsCount++;
|
|
|
|
|
}
|
|
|
|
|
EXPECT_EQ(expectedBlitsCount, blitsCounter);
|
|
|
|
|
device.getMemoryManager()->freeGraphicsMemory(pAllocation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|