From 474b6a2a2342c20da107bc483bd5319959463846 Mon Sep 17 00:00:00 2001 From: "Zdanowicz, Zbigniew" Date: Fri, 12 Jan 2018 14:18:53 +0100 Subject: [PATCH] Enable Mid-Thread preemption for Gen9 Change-Id: Iacec1c8fa899d4fbf0cbb9cc292990546871ca6a --- runtime/built_ins/built_ins.cpp | 4 +-- .../command_stream_receiver.cpp | 3 -- runtime/device/device.cpp | 14 ++++++--- runtime/device/device.h | 4 ++- runtime/gen9/hw_info_bxt.cpp | 4 +-- runtime/gen9/hw_info_cfl.cpp | 2 +- runtime/gen9/hw_info_glk.cpp | 4 +-- runtime/gen9/hw_info_kbl.cpp | 4 +-- runtime/gen9/hw_info_skl.cpp | 4 +-- runtime/gen9/linux/hw_info_config_bxt.cpp | 4 +-- runtime/gen9/linux/hw_info_config_cfl.cpp | 2 +- runtime/gen9/linux/hw_info_config_glk.cpp | 4 +-- runtime/gen9/linux/hw_info_config_kbl.cpp | 4 +-- runtime/gen9/linux/hw_info_config_skl.cpp | 4 +-- ...te_command_queue_with_properties_tests.cpp | 26 +++++++++++++++- unit_tests/fixtures/preemption_fixture.cpp | 7 ++++- unit_tests/fixtures/preemption_fixture.h | 9 +++--- .../gen9/bxt/linux/hw_info_config_tests.cpp | 26 +++++++++++++++- .../gen9/cfl/linux/hw_info_config_tests.cpp | 23 ++++++++++++++ .../gen9/glk/linux/hw_info_config_tests.cpp | 23 +++++++++++++- .../gen9/kbl/linux/hw_info_config_tests.cpp | 25 ++++++++++++++- .../gen9/skl/linux/hw_info_config_tests.cpp | 27 +++++++++++++++- unit_tests/gen9/test_device_caps.cpp | 4 +-- .../libult/ult_command_stream_receiver.h | 3 +- unit_tests/main.cpp | 10 +++++- unit_tests/mocks/mock_device.cpp | 3 +- .../os_interface/linux/device_os_tests.cpp | 13 +++----- .../os_interface/windows/device_os_tests.cpp | 13 +++----- unit_tests/preemption/preemption_tests.cpp | 31 ++++++++++++++++++- 29 files changed, 243 insertions(+), 61 deletions(-) diff --git a/runtime/built_ins/built_ins.cpp b/runtime/built_ins/built_ins.cpp index e5432df117..d56e009bfb 100644 --- a/runtime/built_ins/built_ins.cpp +++ b/runtime/built_ins/built_ins.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,7 +21,7 @@ */ #include -#include "built_ins.h" +#include "runtime/built_ins/built_ins.h" #include "runtime/built_ins/vme_dispatch_builder.h" #include "runtime/built_ins/sip.h" #include "runtime/compiler_interface/compiler_interface.h" diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index 56ca02a280..f0ad637735 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -161,9 +161,6 @@ void CommandStreamReceiver::cleanupResources() { scratchAllocation = nullptr; } - if (preemptionCsrAllocation) { - memoryManager->freeGraphicsMemory(preemptionCsrAllocation); - } if (commandStream.getBase()) { memoryManager->freeGraphicsMemory(commandStream.getGraphicsAllocation()); diff --git a/runtime/device/device.cpp b/runtime/device/device.cpp index 2414fb3c9c..8d72d528b4 100644 --- a/runtime/device/device.cpp +++ b/runtime/device/device.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -72,7 +72,7 @@ bool familyEnabled[IGFX_MAX_CORE] = { Device::Device(const HardwareInfo &hwInfo, bool isRootDevice) : memoryManager(nullptr), enabledClVersion(false), hwInfo(hwInfo), isRoot(isRootDevice), - commandStreamReceiver(nullptr), tagAddress(nullptr), tagAllocation(nullptr), + commandStreamReceiver(nullptr), tagAddress(nullptr), tagAllocation(nullptr), preemptionAllocation(nullptr), osTime(nullptr), slmWindowStartAddress(nullptr) { memset(&deviceInfo, 0, sizeof(deviceInfo)); deviceExtensions.reserve(1000); @@ -93,6 +93,10 @@ Device::~Device() { tagAllocation = nullptr; commandStreamReceiver = nullptr; if (memoryManager) { + if (preemptionAllocation) { + memoryManager->freeGraphicsMemory(preemptionAllocation); + preemptionAllocation = nullptr; + } memoryManager->waitForDeletions(); } delete memoryManager; @@ -156,11 +160,11 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, size_t requiredSize = pHwInfo->pSysInfo->CsrSizeInMb * MemoryConstants::megaByte; size_t alignment = 256 * MemoryConstants::kiloByte; bool uncacheable = pDevice->getWaTable()->waCSRUncachable; - auto preemptionAllocation = outDevice.memoryManager->allocateGraphicsMemory(requiredSize, alignment, false, uncacheable); - if (!preemptionAllocation) { + pDevice->preemptionAllocation = outDevice.memoryManager->allocateGraphicsMemory(requiredSize, alignment, false, uncacheable); + if (!pDevice->preemptionAllocation) { return false; } - commandStreamReceiver->setPreemptionCsrAllocation(preemptionAllocation); + commandStreamReceiver->setPreemptionCsrAllocation(pDevice->preemptionAllocation); } return true; diff --git a/runtime/device/device.h b/runtime/device/device.h index a0588cc8ac..915414857d 100644 --- a/runtime/device/device.h +++ b/runtime/device/device.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -122,6 +122,7 @@ class Device : public BaseObject<_cl_device_id> { PerformanceCounters *getPerformanceCounters() { return performanceCounters.get(); } static decltype(&PerformanceCounters::create) createPerformanceCountersFunc; PreemptionMode getPreemptionMode() const { return preemptionMode; } + GraphicsAllocation *getPreemptionAllocation() const { return preemptionAllocation; } MOCKABLE_VIRTUAL const WhitelistedRegisters &getWhitelistedRegisters() { return hwInfo.capabilityTable.whitelistedRegisters; } std::vector simultaneousInterops; std::string deviceExtensions; @@ -148,6 +149,7 @@ class Device : public BaseObject<_cl_device_id> { volatile uint32_t *tagAddress; GraphicsAllocation *tagAllocation; + GraphicsAllocation *preemptionAllocation; std::unique_ptr osTime; std::unique_ptr driverInfo; std::unique_ptr performanceCounters; diff --git a/runtime/gen9/hw_info_bxt.cpp b/runtime/gen9/hw_info_bxt.cpp index 8a94a81f68..bc559b9f2c 100644 --- a/runtime/gen9/hw_info_bxt.cpp +++ b/runtime/gen9/hw_info_bxt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -60,7 +60,7 @@ const RuntimeCapabilityTable BXT::capabilityTable{ true, // ftrSupportsVmeAvcTextureSampler false, // ftrSupportsVmeAvcPreemption false, - PreemptionMode::ThreadGroup, + PreemptionMode::MidThread, {true, false}, &isSimulationBXT, true, diff --git a/runtime/gen9/hw_info_cfl.cpp b/runtime/gen9/hw_info_cfl.cpp index 48093be0d7..1930f2c0ef 100644 --- a/runtime/gen9/hw_info_cfl.cpp +++ b/runtime/gen9/hw_info_cfl.cpp @@ -55,7 +55,7 @@ const RuntimeCapabilityTable CFL::capabilityTable{ true, // ftrSupportsVmeAvcTextureSampler false, // ftrSupportsVmeAvcPreemption false, - PreemptionMode::ThreadGroup, + PreemptionMode::MidThread, {true, false}, &isSimulationCFL, true, diff --git a/runtime/gen9/hw_info_glk.cpp b/runtime/gen9/hw_info_glk.cpp index 4ac59298ce..cec3f4aa09 100644 --- a/runtime/gen9/hw_info_glk.cpp +++ b/runtime/gen9/hw_info_glk.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -55,7 +55,7 @@ const RuntimeCapabilityTable GLK::capabilityTable{ true, // ftrSupportsVmeAvcTextureSampler false, // ftrSupportsVmeAvcPreemption false, - PreemptionMode::ThreadGroup, + PreemptionMode::MidThread, {true, false}, &isSimulationGLK, true, diff --git a/runtime/gen9/hw_info_kbl.cpp b/runtime/gen9/hw_info_kbl.cpp index b87ee36a25..daa86d5fe7 100644 --- a/runtime/gen9/hw_info_kbl.cpp +++ b/runtime/gen9/hw_info_kbl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -55,7 +55,7 @@ const RuntimeCapabilityTable KBL::capabilityTable{ true, // ftrSupportsVmeAvcTextureSampler false, // ftrSupportsVmeAvcPreemption false, - PreemptionMode::ThreadGroup, + PreemptionMode::MidThread, {true, false}, &isSimulationKBL, true, diff --git a/runtime/gen9/hw_info_skl.cpp b/runtime/gen9/hw_info_skl.cpp index 4c5db96415..3dfb3af5b1 100644 --- a/runtime/gen9/hw_info_skl.cpp +++ b/runtime/gen9/hw_info_skl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -63,7 +63,7 @@ const RuntimeCapabilityTable SKL::capabilityTable{ true, // ftrSupportsVmeAvcTextureSampler false, // ftrSupportsVmeAvcPreemption false, - PreemptionMode::ThreadGroup, + PreemptionMode::MidThread, {true, false}, &isSimulationSKL, true, diff --git a/runtime/gen9/linux/hw_info_config_bxt.cpp b/runtime/gen9/linux/hw_info_config_bxt.cpp index afa9892bcc..2e2b705997 100644 --- a/runtime/gen9/linux/hw_info_config_bxt.cpp +++ b/runtime/gen9/linux/hw_info_config_bxt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -44,7 +44,7 @@ int HwInfoConfigHw::configureHardwareCustom(HardwareInfo *hwInfo, pSkuTable->ftrGpGpuMidBatchPreempt = 1; pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1; - pSkuTable->ftrGpGpuMidThreadLevelPreempt = 1; + pSkuTable->ftrGpGpuMidThreadLevelPreempt = 0; pSkuTable->ftr3dMidBatchPreempt = 1; pSkuTable->ftr3dObjectLevelPreempt = 1; pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1; diff --git a/runtime/gen9/linux/hw_info_config_cfl.cpp b/runtime/gen9/linux/hw_info_config_cfl.cpp index 5144c29a6d..e1222ce346 100644 --- a/runtime/gen9/linux/hw_info_config_cfl.cpp +++ b/runtime/gen9/linux/hw_info_config_cfl.cpp @@ -43,7 +43,7 @@ int HwInfoConfigHw::configureHardwareCustom(HardwareInfo *hwInf pSkuTable->ftrGpGpuMidBatchPreempt = 1; pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1; - pSkuTable->ftrGpGpuMidThreadLevelPreempt = 1; + pSkuTable->ftrGpGpuMidThreadLevelPreempt = 0; pSkuTable->ftr3dMidBatchPreempt = 1; pSkuTable->ftr3dObjectLevelPreempt = 1; pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1; diff --git a/runtime/gen9/linux/hw_info_config_glk.cpp b/runtime/gen9/linux/hw_info_config_glk.cpp index fccb06a9bd..4f5968eee5 100644 --- a/runtime/gen9/linux/hw_info_config_glk.cpp +++ b/runtime/gen9/linux/hw_info_config_glk.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -39,7 +39,7 @@ int HwInfoConfigHw::configureHardwareCustom(HardwareInfo *hwInf pSkuTable->ftrGpGpuMidBatchPreempt = 1; pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1; - pSkuTable->ftrGpGpuMidThreadLevelPreempt = 1; + pSkuTable->ftrGpGpuMidThreadLevelPreempt = 0; pSkuTable->ftr3dMidBatchPreempt = 1; pSkuTable->ftr3dObjectLevelPreempt = 1; pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1; diff --git a/runtime/gen9/linux/hw_info_config_kbl.cpp b/runtime/gen9/linux/hw_info_config_kbl.cpp index 1691955670..8d5015cf53 100644 --- a/runtime/gen9/linux/hw_info_config_kbl.cpp +++ b/runtime/gen9/linux/hw_info_config_kbl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -44,7 +44,7 @@ int HwInfoConfigHw::configureHardwareCustom(HardwareInfo *hwInfo, pSkuTable->ftrGpGpuMidBatchPreempt = 1; pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1; - pSkuTable->ftrGpGpuMidThreadLevelPreempt = 1; + pSkuTable->ftrGpGpuMidThreadLevelPreempt = 0; pSkuTable->ftr3dMidBatchPreempt = 1; pSkuTable->ftr3dObjectLevelPreempt = 1; pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1; diff --git a/runtime/gen9/linux/hw_info_config_skl.cpp b/runtime/gen9/linux/hw_info_config_skl.cpp index fac333d735..7cfdc6651c 100644 --- a/runtime/gen9/linux/hw_info_config_skl.cpp +++ b/runtime/gen9/linux/hw_info_config_skl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -45,7 +45,7 @@ int HwInfoConfigHw::configureHardwareCustom(HardwareInfo *hwInfo, pSkuTable->ftrGpGpuMidBatchPreempt = 1; pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1; - pSkuTable->ftrGpGpuMidThreadLevelPreempt = 1; + pSkuTable->ftrGpGpuMidThreadLevelPreempt = 0; pSkuTable->ftr3dMidBatchPreempt = 1; pSkuTable->ftr3dObjectLevelPreempt = 1; pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1; diff --git a/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp b/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp index 760f9b8815..30b1a859fe 100644 --- a/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp +++ b/unit_tests/api/cl_create_command_queue_with_properties_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -325,4 +325,28 @@ TEST_F(clCreateCommandQueueWithPropertiesApi, returnErrorOnDeviceWithMedPriority EXPECT_EQ(nullptr, cmdqd); EXPECT_EQ(retVal, CL_INVALID_QUEUE_PROPERTIES); } + +TEST_F(clCreateCommandQueueWithPropertiesApi, returnErrorOnQueueWithPriority) { + auto pDevice = pPlatform->getDevice(0); + DeviceInfo &devInfo = const_cast(pDevice->getDeviceInfo()); + devInfo.priorityHintsSupported = false; + cl_int retVal = CL_SUCCESS; + cl_queue_properties ondevice[] = {CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_LOW_KHR, 0}; + auto cmdqd = clCreateCommandQueueWithProperties(pContext, devices[0], ondevice, &retVal); + EXPECT_EQ(nullptr, cmdqd); + EXPECT_EQ(retVal, CL_INVALID_QUEUE_PROPERTIES); +} + +TEST_F(clCreateCommandQueueWithPropertiesApi, returnSuccessOnQueueWithPriority) { + auto pDevice = pPlatform->getDevice(0); + DeviceInfo &devInfo = const_cast(pDevice->getDeviceInfo()); + devInfo.priorityHintsSupported = true; + cl_int retVal = CL_SUCCESS; + cl_queue_properties ondevice[] = {CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_LOW_KHR, 0}; + auto cmdqd = clCreateCommandQueueWithProperties(pContext, devices[0], ondevice, &retVal); + EXPECT_NE(nullptr, cmdqd); + EXPECT_EQ(retVal, CL_SUCCESS); + retVal = clReleaseCommandQueue(cmdqd); + EXPECT_EQ(retVal, CL_SUCCESS); +} } // namespace ULT diff --git a/unit_tests/fixtures/preemption_fixture.cpp b/unit_tests/fixtures/preemption_fixture.cpp index c7ef548294..515e5a3fe6 100644 --- a/unit_tests/fixtures/preemption_fixture.cpp +++ b/unit_tests/fixtures/preemption_fixture.cpp @@ -31,7 +31,6 @@ #include "runtime/scheduler/scheduler_kernel.h" #include "unit_tests/fixtures/hello_world_fixture.h" #include "unit_tests/helpers/hw_parse.h" -#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/mocks/mock_kernel.h" #include "unit_tests/mocks/mock_command_queue.h" #include "unit_tests/mocks/mock_context.h" @@ -84,6 +83,9 @@ void DevicePreemptionTests::forceWhitelistedRegs(bool whitelisted) { } void ThreadGroupPreemptionEnqueueKernelTest::SetUp() { + dbgRestore.reset(new DebugManagerStateRestore()); + DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::ThreadGroup)); + globalHwInfo = const_cast(platformDevices[0]); originalPreemptionMode = globalHwInfo->capabilityTable.defaultPreemptionMode; globalHwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::ThreadGroup; @@ -99,6 +101,9 @@ void ThreadGroupPreemptionEnqueueKernelTest::TearDown() { } void MidThreadPreemptionEnqueueKernelTest::SetUp() { + dbgRestore.reset(new DebugManagerStateRestore()); + DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::MidThread)); + globalHwInfo = const_cast(platformDevices[0]); originalPreemptionMode = globalHwInfo->capabilityTable.defaultPreemptionMode; globalHwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; diff --git a/unit_tests/fixtures/preemption_fixture.h b/unit_tests/fixtures/preemption_fixture.h index 5c5d0bc5d6..32f108f8d1 100644 --- a/unit_tests/fixtures/preemption_fixture.h +++ b/unit_tests/fixtures/preemption_fixture.h @@ -22,6 +22,7 @@ #pragma once +#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/fixtures/hello_world_fixture.h" #include "unit_tests/gen_common/test.h" @@ -51,8 +52,6 @@ using PreemptionEnqueueKernelFixture = HelloWorldFixture; } -class DebugManagerStateRestore; - class DevicePreemptionTests : public ::testing::Test { public: void SetUp() override; @@ -77,20 +76,22 @@ class DevicePreemptionTests : public ::testing::Test { struct ThreadGroupPreemptionEnqueueKernelTest : OCLRT::PreemptionEnqueueKernelTest { void SetUp() override; - void TearDown() override; OCLRT::HardwareInfo *globalHwInfo; OCLRT::PreemptionMode originalPreemptionMode; + + std::unique_ptr dbgRestore; }; struct MidThreadPreemptionEnqueueKernelTest : OCLRT::PreemptionEnqueueKernelTest { void SetUp() override; - void TearDown() override; OCLRT::HardwareInfo *globalHwInfo; OCLRT::PreemptionMode originalPreemptionMode; + + std::unique_ptr dbgRestore; }; struct PreemptionTestHwDetails { diff --git a/unit_tests/gen9/bxt/linux/hw_info_config_tests.cpp b/unit_tests/gen9/bxt/linux/hw_info_config_tests.cpp index e79b7387f0..cd23fb2bcb 100644 --- a/unit_tests/gen9/bxt/linux/hw_info_config_tests.cpp +++ b/unit_tests/gen9/bxt/linux/hw_info_config_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -51,6 +51,30 @@ BXTTEST_F(HwInfoConfigTestLinuxBxt, configureHwInfo) { EXPECT_EQ((outHwInfo.pSysInfo->EUCount - outHwInfo.pSysInfo->EuCountPerPoolMin), outHwInfo.pSysInfo->EuCountPerPoolMax); EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGttCacheInvalidation); + //constant sysInfo/ftr flags + EXPECT_EQ(1u, outHwInfo.pSysInfo->VEBoxInfo.Instances.Bits.VEBox0Enabled); + EXPECT_TRUE(outHwInfo.pSysInfo->VEBoxInfo.IsValid); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrVEBOX); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrULT); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrGpGpuMidBatchPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrGpGpuThreadGroupLevelPreempt); + EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGpGpuMidThreadLevelPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftr3dMidBatchPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftr3dObjectLevelPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrPerCtxtPreemptionGranularityControl); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrLCIA); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrPPGTT); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrL3IACoherency); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrIA32eGfxPTEs); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrDisplayYTiling); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrTranslationTable); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrUserModeTranslationTable); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrEnableGuC); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbc); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbc2AddressTranslation); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbcBlitterTracking); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbcCpuTracking); + EXPECT_EQ(GTTYPE_GTA, outHwInfo.pPlatform->eGTType); EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGT1); EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGT1_5); diff --git a/unit_tests/gen9/cfl/linux/hw_info_config_tests.cpp b/unit_tests/gen9/cfl/linux/hw_info_config_tests.cpp index 13f2854928..51972291ed 100644 --- a/unit_tests/gen9/cfl/linux/hw_info_config_tests.cpp +++ b/unit_tests/gen9/cfl/linux/hw_info_config_tests.cpp @@ -53,6 +53,29 @@ CFLTEST_F(HwInfoConfigTestLinuxCfl, configureHwInfo) { EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTC); EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTX); + //constant sysInfo/ftr flags + EXPECT_EQ(1u, outHwInfo.pSysInfo->VEBoxInfo.Instances.Bits.VEBox0Enabled); + EXPECT_TRUE(outHwInfo.pSysInfo->VEBoxInfo.IsValid); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrVEBOX); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrGpGpuMidBatchPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrGpGpuThreadGroupLevelPreempt); + EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGpGpuMidThreadLevelPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftr3dMidBatchPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftr3dObjectLevelPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrPerCtxtPreemptionGranularityControl); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrPPGTT); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrSVM); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrL3IACoherency); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrIA32eGfxPTEs); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrDisplayYTiling); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrTranslationTable); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrUserModeTranslationTable); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrEnableGuC); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbc); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbc2AddressTranslation); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbcBlitterTracking); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbcCpuTracking); + ReleaseOutHwInfoStructs(); drm->StoredDeviceID = ICFL_GT1_DT_DEVICE_F0_ID; diff --git a/unit_tests/gen9/glk/linux/hw_info_config_tests.cpp b/unit_tests/gen9/glk/linux/hw_info_config_tests.cpp index 0c82248d87..48e8aa0539 100644 --- a/unit_tests/gen9/glk/linux/hw_info_config_tests.cpp +++ b/unit_tests/gen9/glk/linux/hw_info_config_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -59,6 +59,27 @@ GLKTEST_F(HwInfoConfigTestLinuxGlk, configureHwInfo) { EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTC); EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTX); + //constant sysInfo/ftr flags + EXPECT_EQ(1u, outHwInfo.pSysInfo->VEBoxInfo.Instances.Bits.VEBox0Enabled); + EXPECT_TRUE(outHwInfo.pSysInfo->VEBoxInfo.IsValid); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrGpGpuMidBatchPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrGpGpuThreadGroupLevelPreempt); + EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGpGpuMidThreadLevelPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftr3dMidBatchPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftr3dObjectLevelPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrPerCtxtPreemptionGranularityControl); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrLCIA); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrPPGTT); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrL3IACoherency); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrIA32eGfxPTEs); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrTranslationTable); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrUserModeTranslationTable); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrEnableGuC); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrTileMappedResource); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrULT); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrAstcHdr2D); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrAstcLdr2D); + ReleaseOutHwInfoStructs(); drm->StoredDeviceID = IGLK_GT2_ULT_18EU_DEVICE_F0_ID; diff --git a/unit_tests/gen9/kbl/linux/hw_info_config_tests.cpp b/unit_tests/gen9/kbl/linux/hw_info_config_tests.cpp index 66fb271a48..70d58fe616 100644 --- a/unit_tests/gen9/kbl/linux/hw_info_config_tests.cpp +++ b/unit_tests/gen9/kbl/linux/hw_info_config_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -53,6 +53,29 @@ KBLTEST_F(HwInfoConfigTestLinuxKbl, configureHwInfo) { EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTC); EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTX); + //constant sysInfo/ftr flags + EXPECT_EQ(1u, outHwInfo.pSysInfo->VEBoxInfo.Instances.Bits.VEBox0Enabled); + EXPECT_TRUE(outHwInfo.pSysInfo->VEBoxInfo.IsValid); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrVEBOX); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrGpGpuMidBatchPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrGpGpuThreadGroupLevelPreempt); + EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGpGpuMidThreadLevelPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftr3dMidBatchPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftr3dObjectLevelPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrPerCtxtPreemptionGranularityControl); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrPPGTT); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrSVM); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrL3IACoherency); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrIA32eGfxPTEs); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrDisplayYTiling); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrTranslationTable); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrUserModeTranslationTable); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrEnableGuC); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbc); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbc2AddressTranslation); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbcBlitterTracking); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbcCpuTracking); + ReleaseOutHwInfoStructs(); drm->StoredDeviceID = IKBL_GT1_ULT_DEVICE_F0_ID; diff --git a/unit_tests/gen9/skl/linux/hw_info_config_tests.cpp b/unit_tests/gen9/skl/linux/hw_info_config_tests.cpp index 9ee604c636..30df2d838f 100644 --- a/unit_tests/gen9/skl/linux/hw_info_config_tests.cpp +++ b/unit_tests/gen9/skl/linux/hw_info_config_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -53,6 +53,31 @@ SKLTEST_F(HwInfoConfigTestLinuxSkl, configureHwInfo) { EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTC); EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTX); + //constant sysInfo/ftr flags + EXPECT_EQ(1u, outHwInfo.pSysInfo->VEBoxInfo.Instances.Bits.VEBox0Enabled); + EXPECT_EQ(1u, outHwInfo.pSysInfo->VDBoxInfo.Instances.Bits.VDBox0Enabled); + EXPECT_TRUE(outHwInfo.pSysInfo->VEBoxInfo.IsValid); + EXPECT_TRUE(outHwInfo.pSysInfo->VDBoxInfo.IsValid); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrGpGpuMidBatchPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrGpGpuThreadGroupLevelPreempt); + EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGpGpuMidThreadLevelPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftr3dMidBatchPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftr3dObjectLevelPreempt); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrPerCtxtPreemptionGranularityControl); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrPPGTT); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrSVM); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrL3IACoherency); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrIA32eGfxPTEs); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrDisplayYTiling); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrTranslationTable); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrUserModeTranslationTable); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrEnableGuC); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbc); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbc2AddressTranslation); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbcBlitterTracking); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrFbcCpuTracking); + EXPECT_EQ(1u, outHwInfo.pSkuTable->ftrVEBOX); + ReleaseOutHwInfoStructs(); drm->StoredDeviceID = ISKL_GT1_DT_DEVICE_F0_ID; diff --git a/unit_tests/gen9/test_device_caps.cpp b/unit_tests/gen9/test_device_caps.cpp index 1fe926457f..da966c4338 100644 --- a/unit_tests/gen9/test_device_caps.cpp +++ b/unit_tests/gen9/test_device_caps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -46,7 +46,7 @@ GEN9TEST_F(Gen9DeviceCaps, allSkusSupportCorrectlyRoundedDivideSqrt) { } GEN9TEST_F(Gen9DeviceCaps, defaultPreemptionMode) { - EXPECT_TRUE(PreemptionMode::ThreadGroup == pDevice->getHardwareInfo().capabilityTable.defaultPreemptionMode); + EXPECT_EQ(PreemptionMode::MidThread, pDevice->getHardwareInfo().capabilityTable.defaultPreemptionMode); } GEN9TEST_F(Gen9DeviceCaps, whitelistedRegisters) { diff --git a/unit_tests/libult/ult_command_stream_receiver.h b/unit_tests/libult/ult_command_stream_receiver.h index f12917ecb3..0be10fb40b 100644 --- a/unit_tests/libult/ult_command_stream_receiver.h +++ b/unit_tests/libult/ult_command_stream_receiver.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -48,6 +48,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw { using BaseClass::CommandStreamReceiver::lastSentThreadAribtrationPolicy; using BaseClass::CommandStreamReceiver::latestFlushedTaskCount; using BaseClass::CommandStreamReceiver::latestSentStatelessMocsConfig; + using BaseClass::CommandStreamReceiver::lastPreemptionMode; using BaseClass::CommandStreamReceiver::taskCount; using BaseClass::CommandStreamReceiver::taskLevel; diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index 06b229020f..91c0a33446 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -28,6 +28,7 @@ #include "unit_tests/memory_leak_listener.h" #include "unit_tests/mocks/mock_gmm.h" #include "runtime/gmm_helper/resource_info.h" +#include "runtime/os_interface/debug_settings_manager.h" #include "gmock/gmock.h" #include #include @@ -157,6 +158,9 @@ std::string getRunPath(char *argv0) { return res; } +extern int preemptionModeFromDebugManager; +int preemptionModeFromDebugManager = -1; + int main(int argc, char **argv) { int retVal = 0; bool useDefaultListener = false; @@ -352,6 +356,10 @@ int main(int argc, char **argv) { gEnvironment->setMockFileNames(fclMockFile, igcMockFile); gEnvironment->setDefaultDebugVars(fclDebugVars, igcDebugVars, device); + // globally override-disable preemption to speed-up test execution + preemptionModeFromDebugManager = OCLRT::DebugManager.flags.ForcePreemptionMode.get(); + OCLRT::DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::Disabled)); + #if defined(__linux__) //ULTs timeout if (enable_alarm) { diff --git a/unit_tests/mocks/mock_device.cpp b/unit_tests/mocks/mock_device.cpp index e91def8275..19a43937cc 100644 --- a/unit_tests/mocks/mock_device.cpp +++ b/unit_tests/mocks/mock_device.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -76,6 +76,7 @@ void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr) { commandStreamReceiver = newCsr; commandStreamReceiver->setMemoryManager(memoryManager); commandStreamReceiver->setTagAllocation(tagAllocation); + commandStreamReceiver->setPreemptionCsrAllocation(preemptionAllocation); memoryManager->csr = commandStreamReceiver; } diff --git a/unit_tests/os_interface/linux/device_os_tests.cpp b/unit_tests/os_interface/linux/device_os_tests.cpp index 2a65e32911..fa89a65660 100644 --- a/unit_tests/os_interface/linux/device_os_tests.cpp +++ b/unit_tests/os_interface/linux/device_os_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -27,6 +27,7 @@ #include "runtime/helpers/get_info.h" #include "gtest/gtest.h" #include "gmock/gmock.h" +#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/mocks/mock_device.h" #include "unit_tests/mocks/mock_context.h" #include "unit_tests/mocks/mock_command_queue.h" @@ -109,14 +110,10 @@ TEST(ApiOsTest, notSupportedApiList) { } TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) { - HardwareInfo *hwInfo = const_cast(*platformDevices); - auto defaultPreemption = hwInfo->capabilityTable.defaultPreemptionMode; - hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; - - auto pDevice = Device::create(hwInfo); + DebugManagerStateRestore dbgRestore; + DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::MidThread)); + auto pDevice = Device::create(nullptr); EXPECT_THAT(pDevice, nullptr); - - hwInfo->capabilityTable.defaultPreemptionMode = defaultPreemption; } } // namespace OCLRT diff --git a/unit_tests/os_interface/windows/device_os_tests.cpp b/unit_tests/os_interface/windows/device_os_tests.cpp index 2a50f681ce..639f04245d 100644 --- a/unit_tests/os_interface/windows/device_os_tests.cpp +++ b/unit_tests/os_interface/windows/device_os_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,6 +24,7 @@ #include "runtime/helpers/get_info.h" #include "gtest/gtest.h" #include "gmock/gmock.h" +#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/mocks/mock_device.h" using namespace ::testing; @@ -72,14 +73,10 @@ TEST(DeviceOsTest, DeviceCreationFail) { } TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) { - HardwareInfo *hwInfo = const_cast(*platformDevices); - auto defaultPreemption = hwInfo->capabilityTable.defaultPreemptionMode; - hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; - - auto pDevice = Device::create(hwInfo); + DebugManagerStateRestore dbgRestore; + DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::MidThread)); + auto pDevice = Device::create(nullptr); EXPECT_THAT(pDevice, nullptr); - - hwInfo->capabilityTable.defaultPreemptionMode = defaultPreemption; } } // namespace OCLRT diff --git a/unit_tests/preemption/preemption_tests.cpp b/unit_tests/preemption/preemption_tests.cpp index e12e442687..e822e89c89 100644 --- a/unit_tests/preemption/preemption_tests.cpp +++ b/unit_tests/preemption/preemption_tests.cpp @@ -34,6 +34,8 @@ using namespace OCLRT; +extern int preemptionModeFromDebugManager; + class ThreadGroupPreemptionTests : public DevicePreemptionTests { void SetUp() override { dbgRestore.reset(new DebugManagerStateRestore()); @@ -98,6 +100,27 @@ TEST_F(ThreadGroupPreemptionTests, allowDefaultModeForNonKernelRequest) { EXPECT_EQ(PreemptionMode::ThreadGroup, PreemptionHelper::taskPreemptionMode(*device, nullptr)); } +TEST_F(ThreadGroupPreemptionTests, givenKernelWithNoEnvironmentPatchSetWhenLSQCWaIsTurnedOnThenThreadGroupPreemptionIsBeingSelected) { + kernelInfo.get()->patchInfo.executionEnvironment = nullptr; + waTable->waDisableLSQCROPERFforOCL = 1; + EXPECT_TRUE(PreemptionHelper::allowThreadGroupPreemption(kernel.get(), waTable)); + EXPECT_EQ(PreemptionMode::ThreadGroup, PreemptionHelper::taskPreemptionMode(*device, kernel.get())); +} + +TEST_F(ThreadGroupPreemptionTests, givenKernelWithEnvironmentPatchSetWhenLSQCWaIsTurnedOnThenThreadGroupPreemptionIsBeingSelected) { + executionEnvironment.get()->UsesFencesForReadWriteImages = 0; + waTable->waDisableLSQCROPERFforOCL = 1; + EXPECT_TRUE(PreemptionHelper::allowThreadGroupPreemption(kernel.get(), waTable)); + EXPECT_EQ(PreemptionMode::ThreadGroup, PreemptionHelper::taskPreemptionMode(*device, kernel.get())); +} + +TEST_F(ThreadGroupPreemptionTests, givenKernelWithEnvironmentPatchSetWhenLSQCWaIsTurnedOffThenThreadGroupPreemptionIsBeingSelected) { + executionEnvironment.get()->UsesFencesForReadWriteImages = 1; + waTable->waDisableLSQCROPERFforOCL = 0; + EXPECT_TRUE(PreemptionHelper::allowThreadGroupPreemption(kernel.get(), waTable)); + EXPECT_EQ(PreemptionMode::ThreadGroup, PreemptionHelper::taskPreemptionMode(*device, kernel.get())); +} + TEST_F(ThreadGroupPreemptionTests, allowMidBatch) { device->setPreemptionMode(PreemptionMode::MidBatch); EXPECT_EQ(PreemptionMode::MidBatch, PreemptionHelper::taskPreemptionMode(*device, nullptr)); @@ -286,7 +309,7 @@ TEST_F(DevicePreemptionTests, setDefaultDisabledPreemptionNoMidBatchSupport) { } TEST(PreemptionTest, defaultMode) { - EXPECT_EQ(0, DebugManager.flags.ForcePreemptionMode.get()); + EXPECT_EQ(0, preemptionModeFromDebugManager); } TEST(PreemptionTest, whenPreemptionModeIsNotMidThreadThenInstructionHeapSipKernelReservedSizeIsEmpty) { @@ -517,6 +540,9 @@ HWTEST_F(MidThreadPreemptionTests, createCsrSurfaceNoWa) { ASSERT_NE(nullptr, csrSurface); EXPECT_FALSE(csrSurface->uncacheable); + GraphicsAllocation *devCsrSurface = mockDevice->getPreemptionAllocation(); + EXPECT_EQ(csrSurface, devCsrSurface); + const_cast(platformDevices[0])->pWaTable = waTable; } @@ -534,5 +560,8 @@ HWTEST_F(MidThreadPreemptionTests, createCsrSurfaceWa) { ASSERT_NE(nullptr, csrSurface); EXPECT_TRUE(csrSurface->uncacheable); + GraphicsAllocation *devCsrSurface = mockDevice->getPreemptionAllocation(); + EXPECT_EQ(csrSurface, devCsrSurface); + const_cast(platformDevices[0])->pWaTable = waTable; }