Move memory for slm window to memory manager

remove redundant methods from MockDevice

Related-To: NEO-3007

Change-Id: I9cc819b9c9118dbb667f5bf87d1bf15787f9b67f
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2019-08-27 15:26:30 +02:00
committed by sys_ocldev
parent 89824aa848
commit 18982bd016
15 changed files with 94 additions and 126 deletions

View File

@ -72,8 +72,6 @@ Device::~Device() {
} }
executionEnvironment->memoryManager->waitForDeletions(); executionEnvironment->memoryManager->waitForDeletions();
alignedFree(this->slmWindowStartAddress);
executionEnvironment->decRefInternal(); executionEnvironment->decRefInternal();
} }
@ -175,17 +173,6 @@ const DeviceInfo &Device::getDeviceInfo() const {
return deviceInfo; return deviceInfo;
} }
void *Device::getSLMWindowStartAddress() {
prepareSLMWindow();
return this->slmWindowStartAddress;
}
void Device::prepareSLMWindow() {
if (this->slmWindowStartAddress == nullptr) {
this->slmWindowStartAddress = executionEnvironment->memoryManager->allocateSystemMemory(MemoryConstants::slmWindowSize, MemoryConstants::slmWindowAlignment);
}
}
const char *Device::getProductAbbrev() const { const char *Device::getProductAbbrev() const {
return hardwarePrefix[getHardwareInfo().platform.eProductFamily]; return hardwarePrefix[getHardwareInfo().platform.eProductFamily];
} }

View File

@ -51,9 +51,6 @@ class Device : public BaseObject<_cl_device_id> {
const DeviceInfo &getDeviceInfo() const; const DeviceInfo &getDeviceInfo() const;
MOCKABLE_VIRTUAL const WorkaroundTable *getWaTable() const; MOCKABLE_VIRTUAL const WorkaroundTable *getWaTable() const;
void *getSLMWindowStartAddress();
void prepareSLMWindow();
EngineControl &getEngine(aub_stream::EngineType engineType, bool lowPriority); EngineControl &getEngine(aub_stream::EngineType engineType, bool lowPriority);
EngineControl &getDefaultEngine(); EngineControl &getDefaultEngine();
@ -128,8 +125,6 @@ class Device : public BaseObject<_cl_device_id> {
std::vector<EngineControl> engines; std::vector<EngineControl> engines;
void *slmWindowStartAddress = nullptr;
std::string exposedBuiltinKernels = ""; std::string exposedBuiltinKernels = "";
PreemptionMode preemptionMode; PreemptionMode preemptionMode;

View File

@ -49,6 +49,9 @@ MemoryManager::~MemoryManager() {
for (auto &engine : registeredEngines) { for (auto &engine : registeredEngines) {
engine.osContext->decRefInternal(); engine.osContext->decRefInternal();
} }
if (reservedMemory) {
alignedFreeWrapper(reservedMemory);
}
} }
void *MemoryManager::allocateSystemMemory(size_t size, size_t alignment) { void *MemoryManager::allocateSystemMemory(size_t size, size_t alignment) {
@ -456,4 +459,13 @@ void MemoryManager::cleanTemporaryAllocationListOnAllEngines(bool waitForComplet
} }
} }
void *MemoryManager::getReservedMemory(size_t size, size_t alignment) {
static std::mutex mutex;
std::lock_guard<std::mutex> lock(mutex);
if (!reservedMemory) {
reservedMemory = allocateSystemMemory(size, alignment);
}
return reservedMemory;
}
} // namespace NEO } // namespace NEO

View File

@ -156,6 +156,7 @@ class MemoryManager {
static std::unique_ptr<MemoryManager> createMemoryManager(ExecutionEnvironment &executionEnvironment); static std::unique_ptr<MemoryManager> createMemoryManager(ExecutionEnvironment &executionEnvironment);
virtual void *reserveCpuAddressRange(size_t size) { return nullptr; }; virtual void *reserveCpuAddressRange(size_t size) { return nullptr; };
virtual void releaseReservedCpuAddressRange(void *reserved, size_t size){}; virtual void releaseReservedCpuAddressRange(void *reserved, size_t size){};
void *getReservedMemory(size_t size, size_t alignment);
protected: protected:
struct AllocationData { struct AllocationData {
@ -224,6 +225,7 @@ class MemoryManager {
std::unique_ptr<DeferredDeleter> multiContextResourceDestructor; std::unique_ptr<DeferredDeleter> multiContextResourceDestructor;
std::unique_ptr<GfxPartition> gfxPartition; std::unique_ptr<GfxPartition> gfxPartition;
std::unique_ptr<LocalMemoryUsageBankSelector> localMemoryUsageBankSelector; std::unique_ptr<LocalMemoryUsageBankSelector> localMemoryUsageBankSelector;
void *reservedMemory = nullptr;
}; };
std::unique_ptr<DeferredDeleter> createDeferredDeleter(); std::unique_ptr<DeferredDeleter> createDeferredDeleter();

View File

@ -379,7 +379,6 @@ cl_int Program::parsePatchList(KernelInfo &kernelInfo, uint32_t kernelNum) {
case DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_START_ADDRESS: case DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_START_ADDRESS:
DBG_LOG(LogPatchTokens, "\n .Type", "LOCAL_MEMORY_STATELESS_WINDOW_START_ADDRESS"); DBG_LOG(LogPatchTokens, "\n .Type", "LOCAL_MEMORY_STATELESS_WINDOW_START_ADDRESS");
LocalMemoryStatelessWindowStartAddressOffset = pDataParameterBuffer->Offset; LocalMemoryStatelessWindowStartAddressOffset = pDataParameterBuffer->Offset;
pDevice->prepareSLMWindow();
break; break;
case DATA_PARAMETER_PREFERRED_WORKGROUP_MULTIPLE: case DATA_PARAMETER_PREFERRED_WORKGROUP_MULTIPLE:
DBG_LOG(LogPatchTokens, "\n .Type", "PREFERRED_WORKGROUP_MULTIPLE"); DBG_LOG(LogPatchTokens, "\n .Type", "PREFERRED_WORKGROUP_MULTIPLE");
@ -844,7 +843,7 @@ cl_int Program::parsePatchList(KernelInfo &kernelInfo, uint32_t kernelNum) {
memset(kernelInfo.crossThreadData, 0x00, crossThreadDataSize); memset(kernelInfo.crossThreadData, 0x00, crossThreadDataSize);
if (LocalMemoryStatelessWindowStartAddressOffset != 0xFFffFFff) { if (LocalMemoryStatelessWindowStartAddressOffset != 0xFFffFFff) {
*(uintptr_t *)&(kernelInfo.crossThreadData[LocalMemoryStatelessWindowStartAddressOffset]) = reinterpret_cast<uintptr_t>(this->pDevice->getSLMWindowStartAddress()); *(uintptr_t *)&(kernelInfo.crossThreadData[LocalMemoryStatelessWindowStartAddressOffset]) = reinterpret_cast<uintptr_t>(this->executionEnvironment.memoryManager->getReservedMemory(MemoryConstants::slmWindowSize, MemoryConstants::slmWindowAlignment));
} }
if (LocalMemoryStatelessWindowSizeOffset != 0xFFffFFff) { if (LocalMemoryStatelessWindowSizeOffset != 0xFFffFFff) {

View File

@ -66,7 +66,7 @@ TEST_F(clCreateImageTest, GivenNullHostPtrWhenCreatingImageThenImageIsCreatedAnd
TEST_F(clCreateImageTest, GivenDeviceThatDoesntSupportImagesWhenCreatingImageThenInvalidOperationErrorIsReturned) { TEST_F(clCreateImageTest, GivenDeviceThatDoesntSupportImagesWhenCreatingImageThenInvalidOperationErrorIsReturned) {
auto device = static_cast<MockDevice *>(pContext->getDevice(0)); auto device = static_cast<MockDevice *>(pContext->getDevice(0));
device->getDeviceInfoToModify()->imageSupport = CL_FALSE; device->deviceInfo.imageSupport = CL_FALSE;
cl_bool imageSupportInfo = CL_TRUE; cl_bool imageSupportInfo = CL_TRUE;
auto status = clGetDeviceInfo(devices[0], CL_DEVICE_IMAGE_SUPPORT, sizeof(imageSupportInfo), &imageSupportInfo, nullptr); auto status = clGetDeviceInfo(devices[0], CL_DEVICE_IMAGE_SUPPORT, sizeof(imageSupportInfo), &imageSupportInfo, nullptr);
EXPECT_EQ(CL_SUCCESS, status); EXPECT_EQ(CL_SUCCESS, status);

View File

@ -147,17 +147,17 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, cpuCopyCriteriaMet) {
buffer.reset(Buffer::create(mockContext.get(), CL_MEM_USE_HOST_PTR, 1 * MB, smallBufferPtr, retVal)); buffer.reset(Buffer::create(mockContext.get(), CL_MEM_USE_HOST_PTR, 1 * MB, smallBufferPtr, retVal));
// platform LP == true && size <= 10 MB // platform LP == true && size <= 10 MB
mockDevice->getDeviceInfoToModify()->platformLP = true; mockDevice->deviceInfo.platformLP = true;
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(CL_TRUE, 0, smallBufferPtr, 1 * MB)); EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(CL_TRUE, 0, smallBufferPtr, 1 * MB));
// platform LP == false && size <= 10 MB // platform LP == false && size <= 10 MB
mockDevice->getDeviceInfoToModify()->platformLP = false; mockDevice->deviceInfo.platformLP = false;
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(CL_TRUE, 0, smallBufferPtr, 1 * MB)); EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(CL_TRUE, 0, smallBufferPtr, 1 * MB));
buffer.reset(Buffer::create(mockContext.get(), CL_MEM_ALLOC_HOST_PTR, largeBufferSize, nullptr, retVal)); buffer.reset(Buffer::create(mockContext.get(), CL_MEM_ALLOC_HOST_PTR, largeBufferSize, nullptr, retVal));
// platform LP == false && size > 10 MB // platform LP == false && size > 10 MB
mockDevice->getDeviceInfoToModify()->platformLP = false; mockDevice->deviceInfo.platformLP = false;
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(CL_TRUE, 0, buffer->getCpuAddress(), largeBufferSize)); EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(CL_TRUE, 0, buffer->getCpuAddress(), largeBufferSize));
alignedFree(smallBufferPtr); alignedFree(smallBufferPtr);
@ -198,7 +198,7 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, cpuCopyCriteriaNotMet) {
buffer.reset(Buffer::create(mockContext.get(), CL_MEM_ALLOC_HOST_PTR, largeBufferSize, nullptr, retVal)); buffer.reset(Buffer::create(mockContext.get(), CL_MEM_ALLOC_HOST_PTR, largeBufferSize, nullptr, retVal));
// platform LP == true && size > 10 MB // platform LP == true && size > 10 MB
mockDevice->getDeviceInfoToModify()->platformLP = true; mockDevice->deviceInfo.platformLP = true;
EXPECT_FALSE(buffer->isReadWriteOnCpuAllowed(CL_TRUE, 0, buffer->getCpuAddress(), largeBufferSize)); EXPECT_FALSE(buffer->isReadWriteOnCpuAllowed(CL_TRUE, 0, buffer->getCpuAddress(), largeBufferSize));
alignedFree(alignedHostPtr); alignedFree(alignedHostPtr);

View File

@ -114,7 +114,7 @@ struct PerformanceHintCommandQueueTest : public PerformanceHintTest,
PerformanceHintTest::SetUp(); PerformanceHintTest::SetUp();
std::tie(profilingEnabled, preemptionSupported) = GetParam(); std::tie(profilingEnabled, preemptionSupported) = GetParam();
device = new MockDevice; device = new MockDevice;
device->getDeviceInfoToModify()->preemptionSupported = preemptionSupported; device->deviceInfo.preemptionSupported = preemptionSupported;
} }
void TearDown() override { void TearDown() override {

View File

@ -181,7 +181,7 @@ TEST_P(PackedYuvExtensionSupportedImageFormatsTest, retrieveImageFormatsPackedYU
bool isReadOnly = false; bool isReadOnly = false;
std::tie(imageFormatsFlags, imageFormats) = GetParam(); std::tie(imageFormatsFlags, imageFormats) = GetParam();
device->getDeviceInfoToModify()->packedYuvExtension = true; device->deviceInfo.packedYuvExtension = true;
retVal = context->getSupportedImageFormats( retVal = context->getSupportedImageFormats(
device.get(), device.get(),
@ -265,7 +265,7 @@ TEST_P(NV12ExtensionSupportedImageFormatsTest, givenNV12ExtensionWhenQueriedForI
bool Nv12FormatFound = false; bool Nv12FormatFound = false;
std::tie(imageFormatsFlags, imageFormats) = GetParam(); std::tie(imageFormatsFlags, imageFormats) = GetParam();
device->getDeviceInfoToModify()->nv12Extension = true; device->deviceInfo.nv12Extension = true;
retVal = context->getSupportedImageFormats( retVal = context->getSupportedImageFormats(
device.get(), device.get(),
@ -333,7 +333,7 @@ TEST_P(NV12ExtensionUnsupportedImageFormatsTest, givenNV12ExtensionWhenQueriedFo
bool Nv12FormatFound = false; bool Nv12FormatFound = false;
std::tie(imageFormatsFlags, imageFormats) = GetParam(); std::tie(imageFormatsFlags, imageFormats) = GetParam();
device->getDeviceInfoToModify()->nv12Extension = true; device->deviceInfo.nv12Extension = true;
retVal = context->getSupportedImageFormats( retVal = context->getSupportedImageFormats(
device.get(), device.get(),
@ -393,7 +393,7 @@ TEST_P(NV12ExtensionSupportedImageFormatsTest, retrieveLessImageFormatsThanAvail
uint32_t imageFormats; uint32_t imageFormats;
std::tie(imageFormatsFlags, imageFormats) = GetParam(); std::tie(imageFormatsFlags, imageFormats) = GetParam();
device->getDeviceInfoToModify()->nv12Extension = true; device->deviceInfo.nv12Extension = true;
retVal = context->getSupportedImageFormats( retVal = context->getSupportedImageFormats(
device.get(), device.get(),

View File

@ -5,25 +5,17 @@
* *
*/ */
#include "core/helpers/basic_math.h"
#include "core/unit_tests/helpers/debug_manager_state_restore.h" #include "core/unit_tests/helpers/debug_manager_state_restore.h"
#include "runtime/command_stream/command_stream_receiver.h" #include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/device/driver_info.h" #include "runtime/device/driver_info.h"
#include "runtime/helpers/hw_info.h"
#include "runtime/helpers/options.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/os_interface/os_interface.h" #include "runtime/os_interface/os_interface.h"
#include "runtime/source_level_debugger/source_level_debugger.h"
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/helpers/hw_helper_tests.h" #include "unit_tests/helpers/hw_helper_tests.h"
#include "unit_tests/helpers/variable_backup.h" #include "unit_tests/helpers/variable_backup.h"
#include "unit_tests/mocks/mock_builtins.h" #include "unit_tests/mocks/mock_builtins.h"
#include "unit_tests/mocks/mock_device.h" #include "unit_tests/mocks/mock_device.h"
#include "driver_version.h" #include "driver_version.h"
#include "gmock/gmock.h" #include "gtest/gtest.h"
#include <memory> #include <memory>
@ -33,33 +25,7 @@ extern const char *familyName[];
using namespace NEO; using namespace NEO;
typedef Test<DeviceFixture> DeviceGetCapsF; TEST(DeviceGetCapsTest, validate) {
TEST_F(DeviceGetCapsF, GivenDeviceCapsWhenQueryingForSLMWindowStartAddressThenSharedAndValidPointerGetsReturned) {
auto adr1 = pDevice->getSLMWindowStartAddress();
EXPECT_NE(nullptr, adr1);
auto adr2 = pDevice->getSLMWindowStartAddress();
EXPECT_EQ(adr2, adr1);
}
TEST_F(DeviceGetCapsF, GivenDeviceCapsWhenCallinThenSharedAndValidPointerGetsReturned) {
EXPECT_EQ(nullptr, this->pDevice->peekSlmWindowStartAddress());
this->pDevice->prepareSLMWindow();
void *preparedAddr = this->pDevice->peekSlmWindowStartAddress();
EXPECT_NE(nullptr, preparedAddr);
EXPECT_EQ(preparedAddr, this->pDevice->getSLMWindowStartAddress());
this->pDevice->prepareSLMWindow();
EXPECT_EQ(preparedAddr, this->pDevice->peekSlmWindowStartAddress());
}
TEST_F(DeviceGetCapsF, GivenDeviceCapsWhenQueryingForSLMWindowStartAddressThenPointerWithProperAlignmentIsReturned) {
auto addr = reinterpret_cast<uintptr_t>(pDevice->getSLMWindowStartAddress());
constexpr uintptr_t alignment = 128 * 1024; // 128 KB
constexpr uintptr_t mask = alignment - 1;
EXPECT_EQ(0U, mask & addr);
}
TEST(Device_GetCaps, validate) {
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
const auto &sysInfo = platformDevices[0]->gtSystemInfo; const auto &sysInfo = platformDevices[0]->gtSystemInfo;
@ -182,7 +148,7 @@ TEST(Device_GetCaps, validate) {
} }
} }
TEST(Device_GetCaps, validateImage3DDimensions) { TEST(DeviceGetCapsTest, validateImage3DDimensions) {
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
@ -197,7 +163,7 @@ TEST(Device_GetCaps, validateImage3DDimensions) {
EXPECT_EQ(2048u, caps.image3DMaxDepth); EXPECT_EQ(2048u, caps.image3DMaxDepth);
} }
TEST(Device_GetCaps, givenDontForcePreemptionModeDebugVariableWhenCreateDeviceThenSetDefaultHwPreemptionMode) { TEST(DeviceGetCapsTest, givenDontForcePreemptionModeDebugVariableWhenCreateDeviceThenSetDefaultHwPreemptionMode) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
{ {
DebugManager.flags.ForcePreemptionMode.set(-1); DebugManager.flags.ForcePreemptionMode.set(-1);
@ -207,7 +173,7 @@ TEST(Device_GetCaps, givenDontForcePreemptionModeDebugVariableWhenCreateDeviceTh
} }
} }
TEST(Device_GetCaps, givenForcePreemptionModeDebugVariableWhenCreateDeviceThenSetForcedMode) { TEST(DeviceGetCapsTest, givenForcePreemptionModeDebugVariableWhenCreateDeviceThenSetForcedMode) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
{ {
PreemptionMode forceMode = PreemptionMode::MidThread; PreemptionMode forceMode = PreemptionMode::MidThread;
@ -222,7 +188,7 @@ TEST(Device_GetCaps, givenForcePreemptionModeDebugVariableWhenCreateDeviceThenSe
} }
} }
TEST(Device_GetCaps, givenDeviceWithMidThreadPreemptionWhenDeviceIsCreatedThenSipKernelIsNotCreated) { TEST(DeviceGetCapsTest, givenDeviceWithMidThreadPreemptionWhenDeviceIsCreatedThenSipKernelIsNotCreated) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
{ {
auto builtIns = new MockBuiltins(); auto builtIns = new MockBuiltins();
@ -238,7 +204,7 @@ TEST(Device_GetCaps, givenDeviceWithMidThreadPreemptionWhenDeviceIsCreatedThenSi
} }
} }
TEST(Device_GetCaps, givenForceOclVersion21WhenCapsAreCreatedThenDeviceReportsOpenCL21) { TEST(DeviceGetCapsTest, givenForceOclVersion21WhenCapsAreCreatedThenDeviceReportsOpenCL21) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
{ {
DebugManager.flags.ForceOCLVersion.set(21); DebugManager.flags.ForceOCLVersion.set(21);
@ -250,7 +216,7 @@ TEST(Device_GetCaps, givenForceOclVersion21WhenCapsAreCreatedThenDeviceReportsOp
} }
} }
TEST(Device_GetCaps, givenForceOclVersion20WhenCapsAreCreatedThenDeviceReportsOpenCL20) { TEST(DeviceGetCapsTest, givenForceOclVersion20WhenCapsAreCreatedThenDeviceReportsOpenCL20) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
{ {
DebugManager.flags.ForceOCLVersion.set(20); DebugManager.flags.ForceOCLVersion.set(20);
@ -262,7 +228,7 @@ TEST(Device_GetCaps, givenForceOclVersion20WhenCapsAreCreatedThenDeviceReportsOp
} }
} }
TEST(Device_GetCaps, givenForceOclVersion12WhenCapsAreCreatedThenDeviceReportsOpenCL12) { TEST(DeviceGetCapsTest, givenForceOclVersion12WhenCapsAreCreatedThenDeviceReportsOpenCL12) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
{ {
DebugManager.flags.ForceOCLVersion.set(12); DebugManager.flags.ForceOCLVersion.set(12);
@ -274,7 +240,7 @@ TEST(Device_GetCaps, givenForceOclVersion12WhenCapsAreCreatedThenDeviceReportsOp
} }
} }
TEST(Device_GetCaps, givenForceInvalidOclVersionWhenCapsAreCreatedThenDeviceWillDefaultToOpenCL12) { TEST(DeviceGetCapsTest, givenForceInvalidOclVersionWhenCapsAreCreatedThenDeviceWillDefaultToOpenCL12) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
{ {
DebugManager.flags.ForceOCLVersion.set(1); DebugManager.flags.ForceOCLVersion.set(1);
@ -286,7 +252,7 @@ TEST(Device_GetCaps, givenForceInvalidOclVersionWhenCapsAreCreatedThenDeviceWill
} }
} }
TEST(Device_GetCaps, givenForce32bitAddressingWhenCapsAreCreatedThenDeviceReports32bitAddressingOptimization) { TEST(DeviceGetCapsTest, givenForce32bitAddressingWhenCapsAreCreatedThenDeviceReports32bitAddressingOptimization) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
{ {
DebugManager.flags.Force32bitAddressing.set(true); DebugManager.flags.Force32bitAddressing.set(true);
@ -305,7 +271,7 @@ TEST(Device_GetCaps, givenForce32bitAddressingWhenCapsAreCreatedThenDeviceReport
} }
} }
TEST(Device_GetCaps, alignGlobalMemSizeDownToPageSize) { TEST(DeviceGetCapsTest, alignGlobalMemSizeDownToPageSize) {
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
@ -314,7 +280,7 @@ TEST(Device_GetCaps, alignGlobalMemSizeDownToPageSize) {
EXPECT_EQ(caps.globalMemSize, expectedSize); EXPECT_EQ(caps.globalMemSize, expectedSize);
} }
TEST(Device_GetCaps, checkGlobalMemSize) { TEST(DeviceGetCapsTest, checkGlobalMemSize) {
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
auto pMemManager = device->getMemoryManager(); auto pMemManager = device->getMemoryManager();
@ -333,7 +299,7 @@ TEST(Device_GetCaps, checkGlobalMemSize) {
EXPECT_EQ(caps.globalMemSize, expectedSize); EXPECT_EQ(caps.globalMemSize, expectedSize);
} }
TEST(Device_GetCaps, givenDeviceCapsWhenLocalMemoryIsEnabledThenCalculateGlobalMemSizeBasedOnLocalMemory) { TEST(DeviceGetCapsTest, givenDeviceCapsWhenLocalMemoryIsEnabledThenCalculateGlobalMemSizeBasedOnLocalMemory) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableLocalMemory.set(true); DebugManager.flags.EnableLocalMemory.set(true);
@ -355,7 +321,7 @@ TEST(Device_GetCaps, givenDeviceCapsWhenLocalMemoryIsEnabledThenCalculateGlobalM
EXPECT_EQ(caps.globalMemSize, expectedSize); EXPECT_EQ(caps.globalMemSize, expectedSize);
} }
TEST(Device_GetCaps, givenGlobalMemSizeWhenCalculatingMaxAllocSizeThenAdjustToHWCap) { TEST(DeviceGetCapsTest, givenGlobalMemSizeWhenCalculatingMaxAllocSizeThenAdjustToHWCap) {
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
@ -369,7 +335,7 @@ TEST(Device_GetCaps, givenGlobalMemSizeWhenCalculatingMaxAllocSizeThenAdjustToHW
EXPECT_EQ(caps.maxMemAllocSize, expectedSize); EXPECT_EQ(caps.maxMemAllocSize, expectedSize);
} }
TEST(Device_GetCaps, extensionsStringEndsWithSpace) { TEST(DeviceGetCapsTest, extensionsStringEndsWithSpace) {
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
auto len = strlen(caps.deviceExtensions); auto len = strlen(caps.deviceExtensions);
@ -377,13 +343,13 @@ TEST(Device_GetCaps, extensionsStringEndsWithSpace) {
EXPECT_EQ(' ', caps.deviceExtensions[len - 1]); EXPECT_EQ(' ', caps.deviceExtensions[len - 1]);
} }
TEST(Device_GetCaps, DISABLED_givenDeviceWhenCapsAreCreateThenClGLSharingIsReported) { TEST(DeviceGetCapsTest, DISABLED_givenDeviceWhenCapsAreCreateThenClGLSharingIsReported) {
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_gl_sharing "))); EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_gl_sharing ")));
} }
TEST(Device_GetCaps, givenOpenCLVersion21WhenCapsAreCreatedThenDeviceReportsClKhrSubgroupsExtension) { TEST(DeviceGetCapsTest, givenOpenCLVersion21WhenCapsAreCreatedThenDeviceReportsClKhrSubgroupsExtension) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForceOCLVersion.set(21); DebugManager.flags.ForceOCLVersion.set(21);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
@ -392,7 +358,7 @@ TEST(Device_GetCaps, givenOpenCLVersion21WhenCapsAreCreatedThenDeviceReportsClKh
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_subgroups"))); EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_subgroups")));
} }
TEST(Device_GetCaps, givenOpenCLVersion20WhenCapsAreCreatedThenDeviceDoesntReportClKhrSubgroupsExtension) { TEST(DeviceGetCapsTest, givenOpenCLVersion20WhenCapsAreCreatedThenDeviceDoesntReportClKhrSubgroupsExtension) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForceOCLVersion.set(20); DebugManager.flags.ForceOCLVersion.set(20);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
@ -401,7 +367,7 @@ TEST(Device_GetCaps, givenOpenCLVersion20WhenCapsAreCreatedThenDeviceDoesntRepor
EXPECT_THAT(caps.deviceExtensions, testing::Not(testing::HasSubstr(std::string("cl_khr_subgroups")))); EXPECT_THAT(caps.deviceExtensions, testing::Not(testing::HasSubstr(std::string("cl_khr_subgroups"))));
} }
TEST(Device_GetCaps, givenOpenCLVersion21WhenCapsAreCreatedThenDeviceReportsClKhrIlProgramExtension) { TEST(DeviceGetCapsTest, givenOpenCLVersion21WhenCapsAreCreatedThenDeviceReportsClKhrIlProgramExtension) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForceOCLVersion.set(21); DebugManager.flags.ForceOCLVersion.set(21);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
@ -410,7 +376,7 @@ TEST(Device_GetCaps, givenOpenCLVersion21WhenCapsAreCreatedThenDeviceReportsClKh
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_il_program"))); EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_il_program")));
} }
TEST(Device_GetCaps, givenOpenCLVersion20WhenCapsAreCreatedThenDeviceDoesntReportClKhrIlProgramExtension) { TEST(DeviceGetCapsTest, givenOpenCLVersion20WhenCapsAreCreatedThenDeviceDoesntReportClKhrIlProgramExtension) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForceOCLVersion.set(20); DebugManager.flags.ForceOCLVersion.set(20);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
@ -419,7 +385,7 @@ TEST(Device_GetCaps, givenOpenCLVersion20WhenCapsAreCreatedThenDeviceDoesntRepor
EXPECT_THAT(caps.deviceExtensions, testing::Not(testing::HasSubstr(std::string("cl_khr_il_program")))); EXPECT_THAT(caps.deviceExtensions, testing::Not(testing::HasSubstr(std::string("cl_khr_il_program"))));
} }
TEST(Device_GetCaps, givenOpenCLVersion21WhenCapsAreCreatedThenDeviceReportsClIntelSpirvExtensions) { TEST(DeviceGetCapsTest, givenOpenCLVersion21WhenCapsAreCreatedThenDeviceReportsClIntelSpirvExtensions) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForceOCLVersion.set(21); DebugManager.flags.ForceOCLVersion.set(21);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
@ -431,7 +397,7 @@ TEST(Device_GetCaps, givenOpenCLVersion21WhenCapsAreCreatedThenDeviceReportsClIn
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_spirv_no_integer_wrap_decoration"))); EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_spirv_no_integer_wrap_decoration")));
} }
TEST(Device_GetCaps, givenOpenCLVersion12WhenCapsAreCreatedThenDeviceDoesntReportClIntelSpirvExtensions) { TEST(DeviceGetCapsTest, givenOpenCLVersion12WhenCapsAreCreatedThenDeviceDoesntReportClIntelSpirvExtensions) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForceOCLVersion.set(12); DebugManager.flags.ForceOCLVersion.set(12);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
@ -443,7 +409,7 @@ TEST(Device_GetCaps, givenOpenCLVersion12WhenCapsAreCreatedThenDeviceDoesntRepor
EXPECT_THAT(caps.deviceExtensions, testing::Not(testing::HasSubstr(std::string("cl_khr_spirv_no_integer_wrap_decoration")))); EXPECT_THAT(caps.deviceExtensions, testing::Not(testing::HasSubstr(std::string("cl_khr_spirv_no_integer_wrap_decoration"))));
} }
TEST(Device_GetCaps, givenEnableNV12setToTrueWhenCapsAreCreatedThenDeviceReportsNV12Extension) { TEST(DeviceGetCapsTest, givenEnableNV12setToTrueWhenCapsAreCreatedThenDeviceReportsNV12Extension) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableNV12.set(true); DebugManager.flags.EnableNV12.set(true);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
@ -453,7 +419,7 @@ TEST(Device_GetCaps, givenEnableNV12setToTrueWhenCapsAreCreatedThenDeviceReports
EXPECT_TRUE(caps.nv12Extension); EXPECT_TRUE(caps.nv12Extension);
} }
TEST(Device_GetCaps, givenEnablePackedYuvsetToTrueWhenCapsAreCreatedThenDeviceReportsPackedYuvExtension) { TEST(DeviceGetCapsTest, givenEnablePackedYuvsetToTrueWhenCapsAreCreatedThenDeviceReportsPackedYuvExtension) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnablePackedYuv.set(true); DebugManager.flags.EnablePackedYuv.set(true);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
@ -463,7 +429,7 @@ TEST(Device_GetCaps, givenEnablePackedYuvsetToTrueWhenCapsAreCreatedThenDeviceRe
EXPECT_TRUE(caps.packedYuvExtension); EXPECT_TRUE(caps.packedYuvExtension);
} }
TEST(Device_GetCaps, givenEnableNV12setToFalseWhenCapsAreCreatedThenDeviceDoesNotReportNV12Extension) { TEST(DeviceGetCapsTest, givenEnableNV12setToFalseWhenCapsAreCreatedThenDeviceDoesNotReportNV12Extension) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableNV12.set(false); DebugManager.flags.EnableNV12.set(false);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
@ -473,7 +439,7 @@ TEST(Device_GetCaps, givenEnableNV12setToFalseWhenCapsAreCreatedThenDeviceDoesNo
EXPECT_FALSE(caps.nv12Extension); EXPECT_FALSE(caps.nv12Extension);
} }
TEST(Device_GetCaps, givenEnablePackedYuvsetToFalseWhenCapsAreCreatedThenDeviceDoesNotReportPackedYuvExtension) { TEST(DeviceGetCapsTest, givenEnablePackedYuvsetToFalseWhenCapsAreCreatedThenDeviceDoesNotReportPackedYuvExtension) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnablePackedYuv.set(false); DebugManager.flags.EnablePackedYuv.set(false);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
@ -483,7 +449,7 @@ TEST(Device_GetCaps, givenEnablePackedYuvsetToFalseWhenCapsAreCreatedThenDeviceD
EXPECT_FALSE(caps.packedYuvExtension); EXPECT_FALSE(caps.packedYuvExtension);
} }
TEST(Device_GetCaps, givenEnableVmeSetToTrueAndDeviceSupportsVmeWhenCapsAreCreatedThenDeviceReportsVmeExtensionAndBuiltins) { TEST(DeviceGetCapsTest, givenEnableVmeSetToTrueAndDeviceSupportsVmeWhenCapsAreCreatedThenDeviceReportsVmeExtensionAndBuiltins) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableIntelVme.set(true); DebugManager.flags.EnableIntelVme.set(true);
auto hwInfo = *platformDevices[0]; auto hwInfo = *platformDevices[0];
@ -498,7 +464,7 @@ TEST(Device_GetCaps, givenEnableVmeSetToTrueAndDeviceSupportsVmeWhenCapsAreCreat
EXPECT_THAT(caps.builtInKernels, testing::HasSubstr("block_motion_estimate_intel")); EXPECT_THAT(caps.builtInKernels, testing::HasSubstr("block_motion_estimate_intel"));
} }
TEST(Device_GetCaps, givenEnableVmeSetToTrueAndDeviceDoesNotSupportVmeWhenCapsAreCreatedThenDeviceDoesNotReportVmeExtensionAndBuiltins) { TEST(DeviceGetCapsTest, givenEnableVmeSetToTrueAndDeviceDoesNotSupportVmeWhenCapsAreCreatedThenDeviceDoesNotReportVmeExtensionAndBuiltins) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableIntelVme.set(true); DebugManager.flags.EnableIntelVme.set(true);
auto hwInfo = *platformDevices[0]; auto hwInfo = *platformDevices[0];
@ -513,7 +479,7 @@ TEST(Device_GetCaps, givenEnableVmeSetToTrueAndDeviceDoesNotSupportVmeWhenCapsAr
EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_motion_estimate_intel"))); EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_motion_estimate_intel")));
} }
TEST(Device_GetCaps, givenEnableVmeSetToFalseAndDeviceDoesNotSupportVmeWhenCapsAreCreatedThenDeviceDoesNotReportVmeExtensionAndBuiltins) { TEST(DeviceGetCapsTest, givenEnableVmeSetToFalseAndDeviceDoesNotSupportVmeWhenCapsAreCreatedThenDeviceDoesNotReportVmeExtensionAndBuiltins) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableIntelVme.set(false); DebugManager.flags.EnableIntelVme.set(false);
auto hwInfo = *platformDevices[0]; auto hwInfo = *platformDevices[0];
@ -528,7 +494,7 @@ TEST(Device_GetCaps, givenEnableVmeSetToFalseAndDeviceDoesNotSupportVmeWhenCapsA
EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_motion_estimate_intel"))); EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_motion_estimate_intel")));
} }
TEST(Device_GetCaps, givenEnableVmeSetToFalseAndDeviceSupportsVmeWhenCapsAreCreatedThenDeviceDoesNotReportVmeExtensionAndBuiltins) { TEST(DeviceGetCapsTest, givenEnableVmeSetToFalseAndDeviceSupportsVmeWhenCapsAreCreatedThenDeviceDoesNotReportVmeExtensionAndBuiltins) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableIntelVme.set(false); DebugManager.flags.EnableIntelVme.set(false);
auto hwInfo = *platformDevices[0]; auto hwInfo = *platformDevices[0];
@ -543,7 +509,7 @@ TEST(Device_GetCaps, givenEnableVmeSetToFalseAndDeviceSupportsVmeWhenCapsAreCrea
EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_motion_estimate_intel"))); EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_motion_estimate_intel")));
} }
TEST(Device_GetCaps, givenEnableAdvancedVmeSetToTrueAndDeviceSupportsVmeWhenCapsAreCreatedThenDeviceReportsAdvancedVmeExtensionAndBuiltins) { TEST(DeviceGetCapsTest, givenEnableAdvancedVmeSetToTrueAndDeviceSupportsVmeWhenCapsAreCreatedThenDeviceReportsAdvancedVmeExtensionAndBuiltins) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableIntelAdvancedVme.set(true); DebugManager.flags.EnableIntelAdvancedVme.set(true);
auto hwInfo = *platformDevices[0]; auto hwInfo = *platformDevices[0];
@ -557,7 +523,7 @@ TEST(Device_GetCaps, givenEnableAdvancedVmeSetToTrueAndDeviceSupportsVmeWhenCaps
EXPECT_THAT(caps.builtInKernels, testing::HasSubstr("block_advanced_motion_estimate_bidirectional_check_intel")); EXPECT_THAT(caps.builtInKernels, testing::HasSubstr("block_advanced_motion_estimate_bidirectional_check_intel"));
} }
TEST(Device_GetCaps, givenEnableAdvancedVmeSetToTrueAndDeviceDoesNotSupportVmeWhenCapsAreCreatedThenDeviceDoesNotReportAdvancedVmeExtensionAndBuiltins) { TEST(DeviceGetCapsTest, givenEnableAdvancedVmeSetToTrueAndDeviceDoesNotSupportVmeWhenCapsAreCreatedThenDeviceDoesNotReportAdvancedVmeExtensionAndBuiltins) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableIntelAdvancedVme.set(true); DebugManager.flags.EnableIntelAdvancedVme.set(true);
auto hwInfo = *platformDevices[0]; auto hwInfo = *platformDevices[0];
@ -571,7 +537,7 @@ TEST(Device_GetCaps, givenEnableAdvancedVmeSetToTrueAndDeviceDoesNotSupportVmeWh
EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_advanced_motion_estimate_bidirectional_check_intel"))); EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_advanced_motion_estimate_bidirectional_check_intel")));
} }
TEST(Device_GetCaps, givenEnableAdvancedVmeSetToFalseAndDeviceDoesNotSupportVmeWhenCapsAreCreatedThenDeviceDoesNotReportAdvancedVmeExtensionAndBuiltins) { TEST(DeviceGetCapsTest, givenEnableAdvancedVmeSetToFalseAndDeviceDoesNotSupportVmeWhenCapsAreCreatedThenDeviceDoesNotReportAdvancedVmeExtensionAndBuiltins) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableIntelAdvancedVme.set(false); DebugManager.flags.EnableIntelAdvancedVme.set(false);
auto hwInfo = *platformDevices[0]; auto hwInfo = *platformDevices[0];
@ -585,7 +551,7 @@ TEST(Device_GetCaps, givenEnableAdvancedVmeSetToFalseAndDeviceDoesNotSupportVmeW
EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_advanced_motion_estimate_bidirectional_check_intel"))); EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_advanced_motion_estimate_bidirectional_check_intel")));
} }
TEST(Device_GetCaps, givenEnableAdvancedVmeSetToFalseAndDeviceSupportsVmeWhenCapsAreCreatedThenDeviceDoesNotReportAdvancedVmeExtensionAndBuiltins) { TEST(DeviceGetCapsTest, givenEnableAdvancedVmeSetToFalseAndDeviceSupportsVmeWhenCapsAreCreatedThenDeviceDoesNotReportAdvancedVmeExtensionAndBuiltins) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableIntelAdvancedVme.set(false); DebugManager.flags.EnableIntelAdvancedVme.set(false);
auto hwInfo = *platformDevices[0]; auto hwInfo = *platformDevices[0];
@ -599,33 +565,33 @@ TEST(Device_GetCaps, givenEnableAdvancedVmeSetToFalseAndDeviceSupportsVmeWhenCap
EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_advanced_motion_estimate_bidirectional_check_intel"))); EXPECT_THAT(caps.builtInKernels, testing::Not(testing::HasSubstr("block_advanced_motion_estimate_bidirectional_check_intel")));
} }
TEST(Device_GetCaps, byDefaultVmeIsTurnedOn) { TEST(DeviceGetCapsTest, byDefaultVmeIsTurnedOn) {
DebugSettingsManager<DebugFunctionalityLevel::RegKeys> freshDebugSettingsManager; DebugSettingsManager<DebugFunctionalityLevel::RegKeys> freshDebugSettingsManager;
EXPECT_TRUE(freshDebugSettingsManager.flags.EnableIntelVme.get()); EXPECT_TRUE(freshDebugSettingsManager.flags.EnableIntelVme.get());
} }
TEST(Device_GetCaps, deviceReportsPriorityHintsExtension) { TEST(DeviceGetCapsTest, deviceReportsPriorityHintsExtension) {
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_priority_hints"))); EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_priority_hints")));
} }
TEST(Device_GetCaps, deviceReportsCreateCommandQueueExtension) { TEST(DeviceGetCapsTest, deviceReportsCreateCommandQueueExtension) {
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_create_command_queue"))); EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_create_command_queue")));
} }
TEST(Device_GetCaps, deviceReportsThrottleHintsExtension) { TEST(DeviceGetCapsTest, deviceReportsThrottleHintsExtension) {
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_throttle_hints"))); EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_khr_throttle_hints")));
} }
TEST(Device_GetCaps, givenAtleastOCL2DeviceThenExposesMipMapAndUnifiedMemoryExtensions) { TEST(DeviceGetCapsTest, givenAtleastOCL2DeviceThenExposesMipMapAndUnifiedMemoryExtensions) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForceOCLVersion.set(20); DebugManager.flags.ForceOCLVersion.set(20);
@ -637,7 +603,7 @@ TEST(Device_GetCaps, givenAtleastOCL2DeviceThenExposesMipMapAndUnifiedMemoryExte
EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_intel_unified_shared_memory_preview"))); EXPECT_THAT(caps.deviceExtensions, testing::HasSubstr(std::string("cl_intel_unified_shared_memory_preview")));
} }
TEST(Device_GetCaps, givenOCL12DeviceThenDoesNotExposesMipMapAndUnifiedMemoryExtensions) { TEST(DeviceGetCapsTest, givenOCL12DeviceThenDoesNotExposesMipMapAndUnifiedMemoryExtensions) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForceOCLVersion.set(12); DebugManager.flags.ForceOCLVersion.set(12);
@ -649,7 +615,7 @@ TEST(Device_GetCaps, givenOCL12DeviceThenDoesNotExposesMipMapAndUnifiedMemoryExt
EXPECT_THAT(caps.deviceExtensions, testing::Not(testing::HasSubstr(std::string("cl_intel_unified_shared_memory_preview")))); EXPECT_THAT(caps.deviceExtensions, testing::Not(testing::HasSubstr(std::string("cl_intel_unified_shared_memory_preview"))));
} }
TEST(Device_GetCaps, givenDeviceThatDoesntHaveFp64ThenExtensionIsNotReported) { TEST(DeviceGetCapsTest, givenDeviceThatDoesntHaveFp64ThenExtensionIsNotReported) {
HardwareInfo nonFp64Device = *platformDevices[0]; HardwareInfo nonFp64Device = *platformDevices[0];
nonFp64Device.capabilityTable.ftrSupportsFP64 = false; nonFp64Device.capabilityTable.ftrSupportsFP64 = false;
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&nonFp64Device)); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&nonFp64Device));
@ -794,7 +760,7 @@ class DriverInfoMock : public DriverInfo {
const std::string DriverInfoMock::testDeviceName = "testDeviceName"; const std::string DriverInfoMock::testDeviceName = "testDeviceName";
const std::string DriverInfoMock::testVersion = "testVersion"; const std::string DriverInfoMock::testVersion = "testVersion";
TEST(Device_GetCaps, givenSystemWithDriverInfoWhenGettingNameAndVersionThenReturnValuesFromDriverInfo) { TEST(DeviceGetCapsTest, givenSystemWithDriverInfoWhenGettingNameAndVersionThenReturnValuesFromDriverInfo) {
auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]); auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]);
DriverInfoMock *driverInfoMock = new DriverInfoMock(); DriverInfoMock *driverInfoMock = new DriverInfoMock();
@ -808,7 +774,7 @@ TEST(Device_GetCaps, givenSystemWithDriverInfoWhenGettingNameAndVersionThenRetur
delete device; delete device;
} }
TEST(Device_GetCaps, givenSystemWithNoDriverInfoWhenGettingNameAndVersionThenReturnDefaultValues) { TEST(DeviceGetCapsTest, givenSystemWithNoDriverInfoWhenGettingNameAndVersionThenReturnDefaultValues) {
auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]); auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]);
device->setDriverInfo(nullptr); device->setDriverInfo(nullptr);
@ -832,7 +798,7 @@ TEST(Device_GetCaps, givenSystemWithNoDriverInfoWhenGettingNameAndVersionThenRet
delete device; delete device;
} }
TEST(Device_GetCaps, GivenFlagEnabled64kbPagesWhenSetThenReturnCorrectValue) { TEST(DeviceGetCapsTest, GivenFlagEnabled64kbPagesWhenSetThenReturnCorrectValue) {
DebugManagerStateRestore dbgRestore; DebugManagerStateRestore dbgRestore;
VariableBackup<bool> OsEnabled64kbPagesBackup(&OSInterface::osEnabled64kbPages); VariableBackup<bool> OsEnabled64kbPagesBackup(&OSInterface::osEnabled64kbPages);
@ -871,7 +837,7 @@ TEST(Device_GetCaps, GivenFlagEnabled64kbPagesWhenSetThenReturnCorrectValue) {
EXPECT_TRUE(memoryManager->peek64kbPagesEnabled()); EXPECT_TRUE(memoryManager->peek64kbPagesEnabled());
} }
TEST(Device_GetCaps, givenDeviceWithNullSourceLevelDebuggerWhenCapsAreInitializedThenSourceLevelDebuggerActiveIsSetToFalse) { TEST(DeviceGetCapsTest, givenDeviceWithNullSourceLevelDebuggerWhenCapsAreInitializedThenSourceLevelDebuggerActiveIsSetToFalse) {
std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0])); std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();

View File

@ -45,7 +45,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, GetDeviceInfoMemCapabilitiesTest, GivenValidParamete
TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsErrorWhenPlanarYuvExtensionDisabled) { TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsErrorWhenPlanarYuvExtensionDisabled) {
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)); auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
device->getDeviceInfoToModify()->nv12Extension = false; device->deviceInfo.nv12Extension = false;
uint32_t value; uint32_t value;
auto retVal = device->getDeviceInfo( auto retVal = device->getDeviceInfo(
@ -68,7 +68,7 @@ TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsErrorWhenPlanarYuvExtens
TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsCorrectValuesWhenPlanarYuvExtensionEnabled) { TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsCorrectValuesWhenPlanarYuvExtensionEnabled) {
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)); auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
device->getDeviceInfoToModify()->nv12Extension = true; device->deviceInfo.nv12Extension = true;
size_t value = 0; size_t value = 0;
auto retVal = device->getDeviceInfo( auto retVal = device->getDeviceInfo(

View File

@ -790,7 +790,7 @@ TEST_F(KernelPrivateSurfaceTest, GivenKernelWhenPrivateSurfaceTooBigAndGpuPointe
pKernelInfo->gpuPointerSize = 4; pKernelInfo->gpuPointerSize = 4;
pDevice->getMemoryManager()->setForce32BitAllocations(false); pDevice->getMemoryManager()->setForce32BitAllocations(false);
if (pDevice->getDeviceInfo().computeUnitsUsedForScratch == 0) if (pDevice->getDeviceInfo().computeUnitsUsedForScratch == 0)
pDevice->getDeviceInfoToModify()->computeUnitsUsedForScratch = 120; pDevice->deviceInfo.computeUnitsUsedForScratch = 120;
EXPECT_EQ(CL_OUT_OF_RESOURCES, pKernel->initialize()); EXPECT_EQ(CL_OUT_OF_RESOURCES, pKernel->initialize());
} }
@ -809,7 +809,7 @@ TEST_F(KernelPrivateSurfaceTest, GivenKernelWhenPrivateSurfaceTooBigAndGpuPointe
pKernelInfo->gpuPointerSize = 4; pKernelInfo->gpuPointerSize = 4;
pDevice->getMemoryManager()->setForce32BitAllocations(true); pDevice->getMemoryManager()->setForce32BitAllocations(true);
if (pDevice->getDeviceInfo().computeUnitsUsedForScratch == 0) if (pDevice->getDeviceInfo().computeUnitsUsedForScratch == 0)
pDevice->getDeviceInfoToModify()->computeUnitsUsedForScratch = 120; pDevice->deviceInfo.computeUnitsUsedForScratch = 120;
EXPECT_EQ(CL_OUT_OF_RESOURCES, pKernel->initialize()); EXPECT_EQ(CL_OUT_OF_RESOURCES, pKernel->initialize());
} }
@ -828,7 +828,7 @@ TEST_F(KernelPrivateSurfaceTest, GivenKernelWhenPrivateSurfaceTooBigAndGpuPointe
pKernelInfo->gpuPointerSize = 8; pKernelInfo->gpuPointerSize = 8;
pDevice->getMemoryManager()->setForce32BitAllocations(true); pDevice->getMemoryManager()->setForce32BitAllocations(true);
if (pDevice->getDeviceInfo().computeUnitsUsedForScratch == 0) if (pDevice->getDeviceInfo().computeUnitsUsedForScratch == 0)
pDevice->getDeviceInfoToModify()->computeUnitsUsedForScratch = 120; pDevice->deviceInfo.computeUnitsUsedForScratch = 120;
EXPECT_EQ(CL_OUT_OF_RESOURCES, pKernel->initialize()); EXPECT_EQ(CL_OUT_OF_RESOURCES, pKernel->initialize());
} }

View File

@ -1845,3 +1845,20 @@ TEST_F(MemoryAllocatorTest, whenReservingAddressRangeThenExpectProperAddressAndR
EXPECT_EQ(size, allocation->getReservedAddressSize()); EXPECT_EQ(size, allocation->getReservedAddressSize());
memoryManager->freeGraphicsMemory(allocation); memoryManager->freeGraphicsMemory(allocation);
} }
TEST(MemoryManagerTest, givenMemoryManagerWhenGettingReservedMemoryThenAllocateIt) {
MockExecutionEnvironment executionEnvironment(*platformDevices);
MockMemoryManager memoryManager(false, false, executionEnvironment);
EXPECT_EQ(nullptr, memoryManager.reservedMemory);
memoryManager.getReservedMemory(MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize);
EXPECT_NE(nullptr, memoryManager.reservedMemory);
}
TEST(MemoryManagerTest, givenMemoryManagerWhenGetReservedMemoryIsCalledManyTimesThenReuseSameMemory) {
MockExecutionEnvironment executionEnvironment(*platformDevices);
MockMemoryManager memoryManager(false, false, executionEnvironment);
auto reservedMemory = memoryManager.getReservedMemory(MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize);
memoryManager.getReservedMemory(MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize);
memoryManager.getReservedMemory(MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize);
EXPECT_EQ(reservedMemory, memoryManager.reservedMemory);
}

View File

@ -33,20 +33,9 @@ class MockDevice : public RootDevice {
bool hasDriverInfo(); bool hasDriverInfo();
bool getCpuTime(uint64_t *timeStamp) { return true; }; bool getCpuTime(uint64_t *timeStamp) { return true; };
void *peekSlmWindowStartAddress() const {
return this->slmWindowStartAddress;
}
MockDevice(); MockDevice();
MockDevice(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex); MockDevice(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
DeviceInfo *getDeviceInfoToModify() {
return &this->deviceInfo;
}
void initializeCaps() override {
Device::initializeCaps();
}
void setPreemptionMode(PreemptionMode mode) { void setPreemptionMode(PreemptionMode mode) {
preemptionMode = mode; preemptionMode = mode;
} }

View File

@ -46,6 +46,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
using MemoryManager::useInternal32BitAllocator; using MemoryManager::useInternal32BitAllocator;
using OsAgnosticMemoryManager::allocateGraphicsMemoryForImageFromHostPtr; using OsAgnosticMemoryManager::allocateGraphicsMemoryForImageFromHostPtr;
using MemoryManagerCreate<OsAgnosticMemoryManager>::MemoryManagerCreate; using MemoryManagerCreate<OsAgnosticMemoryManager>::MemoryManagerCreate;
using MemoryManager::reservedMemory;
MockMemoryManager(ExecutionEnvironment &executionEnvironment) : MockMemoryManager(false, executionEnvironment) {} MockMemoryManager(ExecutionEnvironment &executionEnvironment) : MockMemoryManager(false, executionEnvironment) {}