Enable Mid-Thread preemption for Gen9

Change-Id: Iacec1c8fa899d4fbf0cbb9cc292990546871ca6a
This commit is contained in:
Zdanowicz, Zbigniew
2018-01-12 14:18:53 +01:00
committed by sys_ocldev
parent 8ee2c54a50
commit 474b6a2a23
29 changed files with 243 additions and 61 deletions

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -21,7 +21,7 @@
*/ */
#include <cstdint> #include <cstdint>
#include "built_ins.h" #include "runtime/built_ins/built_ins.h"
#include "runtime/built_ins/vme_dispatch_builder.h" #include "runtime/built_ins/vme_dispatch_builder.h"
#include "runtime/built_ins/sip.h" #include "runtime/built_ins/sip.h"
#include "runtime/compiler_interface/compiler_interface.h" #include "runtime/compiler_interface/compiler_interface.h"

View File

@@ -161,9 +161,6 @@ void CommandStreamReceiver::cleanupResources() {
scratchAllocation = nullptr; scratchAllocation = nullptr;
} }
if (preemptionCsrAllocation) {
memoryManager->freeGraphicsMemory(preemptionCsrAllocation);
}
if (commandStream.getBase()) { if (commandStream.getBase()) {
memoryManager->freeGraphicsMemory(commandStream.getGraphicsAllocation()); memoryManager->freeGraphicsMemory(commandStream.getGraphicsAllocation());

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -72,7 +72,7 @@ bool familyEnabled[IGFX_MAX_CORE] = {
Device::Device(const HardwareInfo &hwInfo, Device::Device(const HardwareInfo &hwInfo,
bool isRootDevice) bool isRootDevice)
: memoryManager(nullptr), enabledClVersion(false), hwInfo(hwInfo), isRoot(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) { osTime(nullptr), slmWindowStartAddress(nullptr) {
memset(&deviceInfo, 0, sizeof(deviceInfo)); memset(&deviceInfo, 0, sizeof(deviceInfo));
deviceExtensions.reserve(1000); deviceExtensions.reserve(1000);
@@ -93,6 +93,10 @@ Device::~Device() {
tagAllocation = nullptr; tagAllocation = nullptr;
commandStreamReceiver = nullptr; commandStreamReceiver = nullptr;
if (memoryManager) { if (memoryManager) {
if (preemptionAllocation) {
memoryManager->freeGraphicsMemory(preemptionAllocation);
preemptionAllocation = nullptr;
}
memoryManager->waitForDeletions(); memoryManager->waitForDeletions();
} }
delete memoryManager; delete memoryManager;
@@ -156,11 +160,11 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo,
size_t requiredSize = pHwInfo->pSysInfo->CsrSizeInMb * MemoryConstants::megaByte; size_t requiredSize = pHwInfo->pSysInfo->CsrSizeInMb * MemoryConstants::megaByte;
size_t alignment = 256 * MemoryConstants::kiloByte; size_t alignment = 256 * MemoryConstants::kiloByte;
bool uncacheable = pDevice->getWaTable()->waCSRUncachable; bool uncacheable = pDevice->getWaTable()->waCSRUncachable;
auto preemptionAllocation = outDevice.memoryManager->allocateGraphicsMemory(requiredSize, alignment, false, uncacheable); pDevice->preemptionAllocation = outDevice.memoryManager->allocateGraphicsMemory(requiredSize, alignment, false, uncacheable);
if (!preemptionAllocation) { if (!pDevice->preemptionAllocation) {
return false; return false;
} }
commandStreamReceiver->setPreemptionCsrAllocation(preemptionAllocation); commandStreamReceiver->setPreemptionCsrAllocation(pDevice->preemptionAllocation);
} }
return true; return true;

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * 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(); } PerformanceCounters *getPerformanceCounters() { return performanceCounters.get(); }
static decltype(&PerformanceCounters::create) createPerformanceCountersFunc; static decltype(&PerformanceCounters::create) createPerformanceCountersFunc;
PreemptionMode getPreemptionMode() const { return preemptionMode; } PreemptionMode getPreemptionMode() const { return preemptionMode; }
GraphicsAllocation *getPreemptionAllocation() const { return preemptionAllocation; }
MOCKABLE_VIRTUAL const WhitelistedRegisters &getWhitelistedRegisters() { return hwInfo.capabilityTable.whitelistedRegisters; } MOCKABLE_VIRTUAL const WhitelistedRegisters &getWhitelistedRegisters() { return hwInfo.capabilityTable.whitelistedRegisters; }
std::vector<unsigned int> simultaneousInterops; std::vector<unsigned int> simultaneousInterops;
std::string deviceExtensions; std::string deviceExtensions;
@@ -148,6 +149,7 @@ class Device : public BaseObject<_cl_device_id> {
volatile uint32_t *tagAddress; volatile uint32_t *tagAddress;
GraphicsAllocation *tagAllocation; GraphicsAllocation *tagAllocation;
GraphicsAllocation *preemptionAllocation;
std::unique_ptr<OSTime> osTime; std::unique_ptr<OSTime> osTime;
std::unique_ptr<DriverInfo> driverInfo; std::unique_ptr<DriverInfo> driverInfo;
std::unique_ptr<PerformanceCounters> performanceCounters; std::unique_ptr<PerformanceCounters> performanceCounters;

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -60,7 +60,7 @@ const RuntimeCapabilityTable BXT::capabilityTable{
true, // ftrSupportsVmeAvcTextureSampler true, // ftrSupportsVmeAvcTextureSampler
false, // ftrSupportsVmeAvcPreemption false, // ftrSupportsVmeAvcPreemption
false, false,
PreemptionMode::ThreadGroup, PreemptionMode::MidThread,
{true, false}, {true, false},
&isSimulationBXT, &isSimulationBXT,
true, true,

View File

@@ -55,7 +55,7 @@ const RuntimeCapabilityTable CFL::capabilityTable{
true, // ftrSupportsVmeAvcTextureSampler true, // ftrSupportsVmeAvcTextureSampler
false, // ftrSupportsVmeAvcPreemption false, // ftrSupportsVmeAvcPreemption
false, false,
PreemptionMode::ThreadGroup, PreemptionMode::MidThread,
{true, false}, {true, false},
&isSimulationCFL, &isSimulationCFL,
true, true,

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -55,7 +55,7 @@ const RuntimeCapabilityTable GLK::capabilityTable{
true, // ftrSupportsVmeAvcTextureSampler true, // ftrSupportsVmeAvcTextureSampler
false, // ftrSupportsVmeAvcPreemption false, // ftrSupportsVmeAvcPreemption
false, false,
PreemptionMode::ThreadGroup, PreemptionMode::MidThread,
{true, false}, {true, false},
&isSimulationGLK, &isSimulationGLK,
true, true,

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -55,7 +55,7 @@ const RuntimeCapabilityTable KBL::capabilityTable{
true, // ftrSupportsVmeAvcTextureSampler true, // ftrSupportsVmeAvcTextureSampler
false, // ftrSupportsVmeAvcPreemption false, // ftrSupportsVmeAvcPreemption
false, false,
PreemptionMode::ThreadGroup, PreemptionMode::MidThread,
{true, false}, {true, false},
&isSimulationKBL, &isSimulationKBL,
true, true,

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -63,7 +63,7 @@ const RuntimeCapabilityTable SKL::capabilityTable{
true, // ftrSupportsVmeAvcTextureSampler true, // ftrSupportsVmeAvcTextureSampler
false, // ftrSupportsVmeAvcPreemption false, // ftrSupportsVmeAvcPreemption
false, false,
PreemptionMode::ThreadGroup, PreemptionMode::MidThread,
{true, false}, {true, false},
&isSimulationSKL, &isSimulationSKL,
true, true,

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -44,7 +44,7 @@ int HwInfoConfigHw<IGFX_BROXTON>::configureHardwareCustom(HardwareInfo *hwInfo,
pSkuTable->ftrGpGpuMidBatchPreempt = 1; pSkuTable->ftrGpGpuMidBatchPreempt = 1;
pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1; pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1;
pSkuTable->ftrGpGpuMidThreadLevelPreempt = 1; pSkuTable->ftrGpGpuMidThreadLevelPreempt = 0;
pSkuTable->ftr3dMidBatchPreempt = 1; pSkuTable->ftr3dMidBatchPreempt = 1;
pSkuTable->ftr3dObjectLevelPreempt = 1; pSkuTable->ftr3dObjectLevelPreempt = 1;
pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1; pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1;

View File

@@ -43,7 +43,7 @@ int HwInfoConfigHw<IGFX_COFFEELAKE>::configureHardwareCustom(HardwareInfo *hwInf
pSkuTable->ftrGpGpuMidBatchPreempt = 1; pSkuTable->ftrGpGpuMidBatchPreempt = 1;
pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1; pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1;
pSkuTable->ftrGpGpuMidThreadLevelPreempt = 1; pSkuTable->ftrGpGpuMidThreadLevelPreempt = 0;
pSkuTable->ftr3dMidBatchPreempt = 1; pSkuTable->ftr3dMidBatchPreempt = 1;
pSkuTable->ftr3dObjectLevelPreempt = 1; pSkuTable->ftr3dObjectLevelPreempt = 1;
pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1; pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1;

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -39,7 +39,7 @@ int HwInfoConfigHw<IGFX_GEMINILAKE>::configureHardwareCustom(HardwareInfo *hwInf
pSkuTable->ftrGpGpuMidBatchPreempt = 1; pSkuTable->ftrGpGpuMidBatchPreempt = 1;
pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1; pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1;
pSkuTable->ftrGpGpuMidThreadLevelPreempt = 1; pSkuTable->ftrGpGpuMidThreadLevelPreempt = 0;
pSkuTable->ftr3dMidBatchPreempt = 1; pSkuTable->ftr3dMidBatchPreempt = 1;
pSkuTable->ftr3dObjectLevelPreempt = 1; pSkuTable->ftr3dObjectLevelPreempt = 1;
pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1; pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1;

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -44,7 +44,7 @@ int HwInfoConfigHw<IGFX_KABYLAKE>::configureHardwareCustom(HardwareInfo *hwInfo,
pSkuTable->ftrGpGpuMidBatchPreempt = 1; pSkuTable->ftrGpGpuMidBatchPreempt = 1;
pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1; pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1;
pSkuTable->ftrGpGpuMidThreadLevelPreempt = 1; pSkuTable->ftrGpGpuMidThreadLevelPreempt = 0;
pSkuTable->ftr3dMidBatchPreempt = 1; pSkuTable->ftr3dMidBatchPreempt = 1;
pSkuTable->ftr3dObjectLevelPreempt = 1; pSkuTable->ftr3dObjectLevelPreempt = 1;
pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1; pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1;

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -45,7 +45,7 @@ int HwInfoConfigHw<IGFX_SKYLAKE>::configureHardwareCustom(HardwareInfo *hwInfo,
pSkuTable->ftrGpGpuMidBatchPreempt = 1; pSkuTable->ftrGpGpuMidBatchPreempt = 1;
pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1; pSkuTable->ftrGpGpuThreadGroupLevelPreempt = 1;
pSkuTable->ftrGpGpuMidThreadLevelPreempt = 1; pSkuTable->ftrGpGpuMidThreadLevelPreempt = 0;
pSkuTable->ftr3dMidBatchPreempt = 1; pSkuTable->ftr3dMidBatchPreempt = 1;
pSkuTable->ftr3dObjectLevelPreempt = 1; pSkuTable->ftr3dObjectLevelPreempt = 1;
pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1; pSkuTable->ftrPerCtxtPreemptionGranularityControl = 1;

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -325,4 +325,28 @@ TEST_F(clCreateCommandQueueWithPropertiesApi, returnErrorOnDeviceWithMedPriority
EXPECT_EQ(nullptr, cmdqd); EXPECT_EQ(nullptr, cmdqd);
EXPECT_EQ(retVal, CL_INVALID_QUEUE_PROPERTIES); EXPECT_EQ(retVal, CL_INVALID_QUEUE_PROPERTIES);
} }
TEST_F(clCreateCommandQueueWithPropertiesApi, returnErrorOnQueueWithPriority) {
auto pDevice = pPlatform->getDevice(0);
DeviceInfo &devInfo = const_cast<DeviceInfo &>(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<DeviceInfo &>(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 } // namespace ULT

View File

@@ -31,7 +31,6 @@
#include "runtime/scheduler/scheduler_kernel.h" #include "runtime/scheduler/scheduler_kernel.h"
#include "unit_tests/fixtures/hello_world_fixture.h" #include "unit_tests/fixtures/hello_world_fixture.h"
#include "unit_tests/helpers/hw_parse.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_kernel.h"
#include "unit_tests/mocks/mock_command_queue.h" #include "unit_tests/mocks/mock_command_queue.h"
#include "unit_tests/mocks/mock_context.h" #include "unit_tests/mocks/mock_context.h"
@@ -84,6 +83,9 @@ void DevicePreemptionTests::forceWhitelistedRegs(bool whitelisted) {
} }
void ThreadGroupPreemptionEnqueueKernelTest::SetUp() { void ThreadGroupPreemptionEnqueueKernelTest::SetUp() {
dbgRestore.reset(new DebugManagerStateRestore());
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::ThreadGroup));
globalHwInfo = const_cast<HardwareInfo *>(platformDevices[0]); globalHwInfo = const_cast<HardwareInfo *>(platformDevices[0]);
originalPreemptionMode = globalHwInfo->capabilityTable.defaultPreemptionMode; originalPreemptionMode = globalHwInfo->capabilityTable.defaultPreemptionMode;
globalHwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::ThreadGroup; globalHwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::ThreadGroup;
@@ -99,6 +101,9 @@ void ThreadGroupPreemptionEnqueueKernelTest::TearDown() {
} }
void MidThreadPreemptionEnqueueKernelTest::SetUp() { void MidThreadPreemptionEnqueueKernelTest::SetUp() {
dbgRestore.reset(new DebugManagerStateRestore());
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
globalHwInfo = const_cast<HardwareInfo *>(platformDevices[0]); globalHwInfo = const_cast<HardwareInfo *>(platformDevices[0]);
originalPreemptionMode = globalHwInfo->capabilityTable.defaultPreemptionMode; originalPreemptionMode = globalHwInfo->capabilityTable.defaultPreemptionMode;
globalHwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; globalHwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread;

View File

@@ -22,6 +22,7 @@
#pragma once #pragma once
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/fixtures/hello_world_fixture.h" #include "unit_tests/fixtures/hello_world_fixture.h"
#include "unit_tests/gen_common/test.h" #include "unit_tests/gen_common/test.h"
@@ -51,8 +52,6 @@ using PreemptionEnqueueKernelFixture = HelloWorldFixture<HelloWorldFixtureFactor
using PreemptionEnqueueKernelTest = Test<PreemptionEnqueueKernelFixture>; using PreemptionEnqueueKernelTest = Test<PreemptionEnqueueKernelFixture>;
} }
class DebugManagerStateRestore;
class DevicePreemptionTests : public ::testing::Test { class DevicePreemptionTests : public ::testing::Test {
public: public:
void SetUp() override; void SetUp() override;
@@ -77,20 +76,22 @@ class DevicePreemptionTests : public ::testing::Test {
struct ThreadGroupPreemptionEnqueueKernelTest : OCLRT::PreemptionEnqueueKernelTest { struct ThreadGroupPreemptionEnqueueKernelTest : OCLRT::PreemptionEnqueueKernelTest {
void SetUp() override; void SetUp() override;
void TearDown() override; void TearDown() override;
OCLRT::HardwareInfo *globalHwInfo; OCLRT::HardwareInfo *globalHwInfo;
OCLRT::PreemptionMode originalPreemptionMode; OCLRT::PreemptionMode originalPreemptionMode;
std::unique_ptr<DebugManagerStateRestore> dbgRestore;
}; };
struct MidThreadPreemptionEnqueueKernelTest : OCLRT::PreemptionEnqueueKernelTest { struct MidThreadPreemptionEnqueueKernelTest : OCLRT::PreemptionEnqueueKernelTest {
void SetUp() override; void SetUp() override;
void TearDown() override; void TearDown() override;
OCLRT::HardwareInfo *globalHwInfo; OCLRT::HardwareInfo *globalHwInfo;
OCLRT::PreemptionMode originalPreemptionMode; OCLRT::PreemptionMode originalPreemptionMode;
std::unique_ptr<DebugManagerStateRestore> dbgRestore;
}; };
struct PreemptionTestHwDetails { struct PreemptionTestHwDetails {

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * 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((outHwInfo.pSysInfo->EUCount - outHwInfo.pSysInfo->EuCountPerPoolMin), outHwInfo.pSysInfo->EuCountPerPoolMax);
EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGttCacheInvalidation); 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(GTTYPE_GTA, outHwInfo.pPlatform->eGTType);
EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGT1); EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGT1);
EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGT1_5); EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGT1_5);

View File

@@ -53,6 +53,29 @@ CFLTEST_F(HwInfoConfigTestLinuxCfl, configureHwInfo) {
EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTC); EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTC);
EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTX); 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(); ReleaseOutHwInfoStructs();
drm->StoredDeviceID = ICFL_GT1_DT_DEVICE_F0_ID; drm->StoredDeviceID = ICFL_GT1_DT_DEVICE_F0_ID;

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * 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->ftrGTC);
EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTX); 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(); ReleaseOutHwInfoStructs();
drm->StoredDeviceID = IGLK_GT2_ULT_18EU_DEVICE_F0_ID; drm->StoredDeviceID = IGLK_GT2_ULT_18EU_DEVICE_F0_ID;

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * 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->ftrGTC);
EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTX); 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(); ReleaseOutHwInfoStructs();
drm->StoredDeviceID = IKBL_GT1_ULT_DEVICE_F0_ID; drm->StoredDeviceID = IKBL_GT1_ULT_DEVICE_F0_ID;

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * 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->ftrGTC);
EXPECT_EQ(0u, outHwInfo.pSkuTable->ftrGTX); 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(); ReleaseOutHwInfoStructs();
drm->StoredDeviceID = ISKL_GT1_DT_DEVICE_F0_ID; drm->StoredDeviceID = ISKL_GT1_DT_DEVICE_F0_ID;

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -46,7 +46,7 @@ GEN9TEST_F(Gen9DeviceCaps, allSkusSupportCorrectlyRoundedDivideSqrt) {
} }
GEN9TEST_F(Gen9DeviceCaps, defaultPreemptionMode) { GEN9TEST_F(Gen9DeviceCaps, defaultPreemptionMode) {
EXPECT_TRUE(PreemptionMode::ThreadGroup == pDevice->getHardwareInfo().capabilityTable.defaultPreemptionMode); EXPECT_EQ(PreemptionMode::MidThread, pDevice->getHardwareInfo().capabilityTable.defaultPreemptionMode);
} }
GEN9TEST_F(Gen9DeviceCaps, whitelistedRegisters) { GEN9TEST_F(Gen9DeviceCaps, whitelistedRegisters) {

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -48,6 +48,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
using BaseClass::CommandStreamReceiver::lastSentThreadAribtrationPolicy; using BaseClass::CommandStreamReceiver::lastSentThreadAribtrationPolicy;
using BaseClass::CommandStreamReceiver::latestFlushedTaskCount; using BaseClass::CommandStreamReceiver::latestFlushedTaskCount;
using BaseClass::CommandStreamReceiver::latestSentStatelessMocsConfig; using BaseClass::CommandStreamReceiver::latestSentStatelessMocsConfig;
using BaseClass::CommandStreamReceiver::lastPreemptionMode;
using BaseClass::CommandStreamReceiver::taskCount; using BaseClass::CommandStreamReceiver::taskCount;
using BaseClass::CommandStreamReceiver::taskLevel; using BaseClass::CommandStreamReceiver::taskLevel;

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -28,6 +28,7 @@
#include "unit_tests/memory_leak_listener.h" #include "unit_tests/memory_leak_listener.h"
#include "unit_tests/mocks/mock_gmm.h" #include "unit_tests/mocks/mock_gmm.h"
#include "runtime/gmm_helper/resource_info.h" #include "runtime/gmm_helper/resource_info.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include <algorithm> #include <algorithm>
#include <mutex> #include <mutex>
@@ -157,6 +158,9 @@ std::string getRunPath(char *argv0) {
return res; return res;
} }
extern int preemptionModeFromDebugManager;
int preemptionModeFromDebugManager = -1;
int main(int argc, char **argv) { int main(int argc, char **argv) {
int retVal = 0; int retVal = 0;
bool useDefaultListener = false; bool useDefaultListener = false;
@@ -352,6 +356,10 @@ int main(int argc, char **argv) {
gEnvironment->setMockFileNames(fclMockFile, igcMockFile); gEnvironment->setMockFileNames(fclMockFile, igcMockFile);
gEnvironment->setDefaultDebugVars(fclDebugVars, igcDebugVars, device); 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<int>(PreemptionMode::Disabled));
#if defined(__linux__) #if defined(__linux__)
//ULTs timeout //ULTs timeout
if (enable_alarm) { if (enable_alarm) {

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -76,6 +76,7 @@ void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr) {
commandStreamReceiver = newCsr; commandStreamReceiver = newCsr;
commandStreamReceiver->setMemoryManager(memoryManager); commandStreamReceiver->setMemoryManager(memoryManager);
commandStreamReceiver->setTagAllocation(tagAllocation); commandStreamReceiver->setTagAllocation(tagAllocation);
commandStreamReceiver->setPreemptionCsrAllocation(preemptionAllocation);
memoryManager->csr = commandStreamReceiver; memoryManager->csr = commandStreamReceiver;
} }

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -27,6 +27,7 @@
#include "runtime/helpers/get_info.h" #include "runtime/helpers/get_info.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "gmock/gmock.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_device.h"
#include "unit_tests/mocks/mock_context.h" #include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_command_queue.h" #include "unit_tests/mocks/mock_command_queue.h"
@@ -109,14 +110,10 @@ TEST(ApiOsTest, notSupportedApiList) {
} }
TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) { TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) {
HardwareInfo *hwInfo = const_cast<HardwareInfo *>(*platformDevices); DebugManagerStateRestore dbgRestore;
auto defaultPreemption = hwInfo->capabilityTable.defaultPreemptionMode; DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; auto pDevice = Device::create<OCLRT::FailDeviceAfterOne>(nullptr);
auto pDevice = Device::create<OCLRT::FailDeviceAfterOne>(hwInfo);
EXPECT_THAT(pDevice, nullptr); EXPECT_THAT(pDevice, nullptr);
hwInfo->capabilityTable.defaultPreemptionMode = defaultPreemption;
} }
} // namespace OCLRT } // namespace OCLRT

View File

@@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -24,6 +24,7 @@
#include "runtime/helpers/get_info.h" #include "runtime/helpers/get_info.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "gmock/gmock.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_device.h"
using namespace ::testing; using namespace ::testing;
@@ -72,14 +73,10 @@ TEST(DeviceOsTest, DeviceCreationFail) {
} }
TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) { TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) {
HardwareInfo *hwInfo = const_cast<HardwareInfo *>(*platformDevices); DebugManagerStateRestore dbgRestore;
auto defaultPreemption = hwInfo->capabilityTable.defaultPreemptionMode; DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread; auto pDevice = Device::create<OCLRT::FailDeviceAfterOne>(nullptr);
auto pDevice = Device::create<OCLRT::FailDeviceAfterOne>(hwInfo);
EXPECT_THAT(pDevice, nullptr); EXPECT_THAT(pDevice, nullptr);
hwInfo->capabilityTable.defaultPreemptionMode = defaultPreemption;
} }
} // namespace OCLRT } // namespace OCLRT

View File

@@ -34,6 +34,8 @@
using namespace OCLRT; using namespace OCLRT;
extern int preemptionModeFromDebugManager;
class ThreadGroupPreemptionTests : public DevicePreemptionTests { class ThreadGroupPreemptionTests : public DevicePreemptionTests {
void SetUp() override { void SetUp() override {
dbgRestore.reset(new DebugManagerStateRestore()); dbgRestore.reset(new DebugManagerStateRestore());
@@ -98,6 +100,27 @@ TEST_F(ThreadGroupPreemptionTests, allowDefaultModeForNonKernelRequest) {
EXPECT_EQ(PreemptionMode::ThreadGroup, PreemptionHelper::taskPreemptionMode(*device, nullptr)); 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) { TEST_F(ThreadGroupPreemptionTests, allowMidBatch) {
device->setPreemptionMode(PreemptionMode::MidBatch); device->setPreemptionMode(PreemptionMode::MidBatch);
EXPECT_EQ(PreemptionMode::MidBatch, PreemptionHelper::taskPreemptionMode(*device, nullptr)); EXPECT_EQ(PreemptionMode::MidBatch, PreemptionHelper::taskPreemptionMode(*device, nullptr));
@@ -286,7 +309,7 @@ TEST_F(DevicePreemptionTests, setDefaultDisabledPreemptionNoMidBatchSupport) {
} }
TEST(PreemptionTest, defaultMode) { TEST(PreemptionTest, defaultMode) {
EXPECT_EQ(0, DebugManager.flags.ForcePreemptionMode.get()); EXPECT_EQ(0, preemptionModeFromDebugManager);
} }
TEST(PreemptionTest, whenPreemptionModeIsNotMidThreadThenInstructionHeapSipKernelReservedSizeIsEmpty) { TEST(PreemptionTest, whenPreemptionModeIsNotMidThreadThenInstructionHeapSipKernelReservedSizeIsEmpty) {
@@ -517,6 +540,9 @@ HWTEST_F(MidThreadPreemptionTests, createCsrSurfaceNoWa) {
ASSERT_NE(nullptr, csrSurface); ASSERT_NE(nullptr, csrSurface);
EXPECT_FALSE(csrSurface->uncacheable); EXPECT_FALSE(csrSurface->uncacheable);
GraphicsAllocation *devCsrSurface = mockDevice->getPreemptionAllocation();
EXPECT_EQ(csrSurface, devCsrSurface);
const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = waTable; const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = waTable;
} }
@@ -534,5 +560,8 @@ HWTEST_F(MidThreadPreemptionTests, createCsrSurfaceWa) {
ASSERT_NE(nullptr, csrSurface); ASSERT_NE(nullptr, csrSurface);
EXPECT_TRUE(csrSurface->uncacheable); EXPECT_TRUE(csrSurface->uncacheable);
GraphicsAllocation *devCsrSurface = mockDevice->getPreemptionAllocation();
EXPECT_EQ(csrSurface, devCsrSurface);
const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = waTable; const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = waTable;
} }