Disable Mid-thread preemption for VME kernels when device does not support it

Change-Id: I925c0ad8f76cf0b41426155448f34ff7700d0444
This commit is contained in:
Zdanowicz, Zbigniew
2017-12-20 17:01:16 +01:00
committed by sys_ocldev
parent 2a00a15141
commit 3c9b82e9cc
2 changed files with 42 additions and 1 deletions

View File

@@ -48,7 +48,8 @@ bool PreemptionHelper::allowThreadGroupPreemption(Kernel *kernel, const Workarou
bool PreemptionHelper::allowMidThreadPreemption(Kernel *kernel, Device &device) {
bool allowedByKernel = true;
if (kernel) {
allowedByKernel = (kernel->getKernelInfo().patchInfo.executionEnvironment->DisableMidThreadPreemption == 0);
allowedByKernel = (kernel->getKernelInfo().patchInfo.executionEnvironment->DisableMidThreadPreemption == 0) &&
!(kernel->isVmeKernel() && !device.getDeviceInfo().vmeAvcSupportsPreemption);
}
bool supportedByDevice = (device.getPreemptionMode() >= PreemptionMode::MidThread);
return supportedByDevice && allowedByKernel;

View File

@@ -130,6 +130,15 @@ TEST_F(MidThreadPreemptionTests, allowMidThreadPreemptionNullKernel) {
EXPECT_TRUE(PreemptionHelper::allowMidThreadPreemption(nullptr, *device));
}
TEST_F(MidThreadPreemptionTests, allowMidThreadPreemptionDeviceSupportPreemptionOnVmeKernel) {
device->setPreemptionMode(PreemptionMode::MidThread);
device->getMutableDeviceInfo()->vmeAvcSupportsPreemption = true;
delete kernel;
kernelInfo->isVmeWorkload = true;
kernel = new MockKernel(&program, *kernelInfo, *device);
EXPECT_TRUE(PreemptionHelper::allowMidThreadPreemption(kernel, *device));
}
TEST_F(MidThreadPreemptionTests, disallowMidThreadPreemptionByDevice) {
device->setPreemptionMode(PreemptionMode::ThreadGroup);
executionEnvironment.DisableMidThreadPreemption = 0;
@@ -142,6 +151,15 @@ TEST_F(MidThreadPreemptionTests, disallowMidThreadPreemptionByKernel) {
EXPECT_FALSE(PreemptionHelper::allowMidThreadPreemption(kernel, *device));
}
TEST_F(MidThreadPreemptionTests, disallowMidThreadPreemptionByVmeKernel) {
device->setPreemptionMode(PreemptionMode::MidThread);
device->getMutableDeviceInfo()->vmeAvcSupportsPreemption = false;
delete kernel;
kernelInfo->isVmeWorkload = true;
kernel = new MockKernel(&program, *kernelInfo, *device);
EXPECT_FALSE(PreemptionHelper::allowMidThreadPreemption(kernel, *device));
}
TEST_F(MidThreadPreemptionTests, taskPreemptionDisallowMidThreadByDevice) {
executionEnvironment.DisableMidThreadPreemption = 0;
device->setPreemptionMode(PreemptionMode::ThreadGroup);
@@ -156,6 +174,17 @@ TEST_F(MidThreadPreemptionTests, taskPreemptionDisallowMidThreadByKernel) {
EXPECT_EQ(PreemptionMode::ThreadGroup, outMode);
}
TEST_F(MidThreadPreemptionTests, taskPreemptionDisallowMidThreadByVmeKernel) {
delete kernel;
kernelInfo->isVmeWorkload = true;
device->getMutableDeviceInfo()->vmeAvcSupportsPreemption = false;
kernel = new MockKernel(&program, *kernelInfo, *device);
device->setPreemptionMode(PreemptionMode::MidThread);
PreemptionMode outMode = PreemptionHelper::taskPreemptionMode(*device, kernel);
//VME disables mid thread and thread group when device does not support it
EXPECT_EQ(PreemptionMode::MidBatch, outMode);
}
TEST_F(MidThreadPreemptionTests, taskPreemptionAllow) {
executionEnvironment.DisableMidThreadPreemption = 0;
device->setPreemptionMode(PreemptionMode::MidThread);
@@ -163,6 +192,17 @@ TEST_F(MidThreadPreemptionTests, taskPreemptionAllow) {
EXPECT_EQ(PreemptionMode::MidThread, outMode);
}
TEST_F(MidThreadPreemptionTests, taskPreemptionAllowDeviceSupportsPreemptionOnVmeKernel) {
executionEnvironment.DisableMidThreadPreemption = 0;
delete kernel;
kernelInfo->isVmeWorkload = true;
kernel = new MockKernel(&program, *kernelInfo, *device);
device->getMutableDeviceInfo()->vmeAvcSupportsPreemption = true;
device->setPreemptionMode(PreemptionMode::MidThread);
PreemptionMode outMode = PreemptionHelper::taskPreemptionMode(*device, kernel);
EXPECT_EQ(PreemptionMode::MidThread, outMode);
}
TEST_F(DevicePreemptionTests, setDefaultMidThreadPreemption) {
RuntimeCapabilityTable devCapabilities = {};