Skip to content

Commit 9a4d515

Browse files
Return error when Kernel SIMD size is not in expected range
Change-Id: Ic4411535cd97f6e4e2c0252c43ab90c78713c5c5 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
1 parent 5d12bd8 commit 9a4d515

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!groovy
22
dependenciesRevision='b67325e72bcd5baa03886d87cac9afe6aea8cebd-1371'
33
strategy='EQUAL'
4-
allowedCD=219
4+
allowedCD=221
55
allowedF=11

runtime/kernel/kernel.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ cl_int Kernel::initialize() {
195195
const auto &patchInfo = kernelInfo.patchInfo;
196196

197197
reconfigureKernel();
198+
auto &hwInfo = device.getHardwareInfo();
199+
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
200+
auto maxSimdSize = getKernelInfo().getMaxSimdSize();
201+
202+
if (maxSimdSize != 1 && maxSimdSize < hwHelper.getMinimalSIMDSize()) {
203+
return CL_INVALID_KERNEL;
204+
}
198205

199206
crossThreadDataSize = patchInfo.dataParameterStream
200207
? patchInfo.dataParameterStream->DataParameterStreamSize
@@ -242,8 +249,8 @@ cl_int Kernel::initialize() {
242249
preferredWkgMultipleOffset = workloadInfo.preferredWkgMultipleOffset != WorkloadInfo::undefinedOffset ? ptrOffset(crossThread, workloadInfo.preferredWkgMultipleOffset) : preferredWkgMultipleOffset;
243250

244251
*maxWorkGroupSizeForCrossThreadData = maxKernelWorkGroupSize;
245-
*dataParameterSimdSize = getKernelInfo().getMaxSimdSize();
246-
*preferredWkgMultipleOffset = getKernelInfo().getMaxSimdSize();
252+
*dataParameterSimdSize = maxSimdSize;
253+
*preferredWkgMultipleOffset = maxSimdSize;
247254
*parentEventOffset = WorkloadInfo::invalidParentEvent;
248255
}
249256

@@ -359,7 +366,7 @@ cl_int Kernel::initialize() {
359366
usingBuffers = true;
360367
allBufferArgsStateful &= static_cast<uint32_t>(argInfo.pureStatefulBufferAccess);
361368
this->auxTranslationRequired |= !kernelInfo.kernelArgInfo[i].pureStatefulBufferAccess &&
362-
HwHelper::renderCompressedBuffersSupported(getDevice().getHardwareInfo());
369+
HwHelper::renderCompressedBuffersSupported(hwInfo);
363370
} else if (argInfo.isDeviceQueue) {
364371
kernelArgHandlers[i] = &Kernel::setArgDevQueue;
365372
kernelArguments[i].type = DEVICE_QUEUE_OBJ;
@@ -368,7 +375,7 @@ cl_int Kernel::initialize() {
368375
}
369376
}
370377

371-
auxTranslationRequired &= HwHelper::get(device.getHardwareInfo().platform.eRenderCoreFamily).requiresAuxResolves();
378+
auxTranslationRequired &= hwHelper.requiresAuxResolves();
372379

373380
if (DebugManager.flags.DisableAuxTranslation.get()) {
374381
auxTranslationRequired = false;

unit_tests/kernel/kernel_tests.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,36 @@ TEST(KernelTest, whenNullAllocationThenAssignNullPointerToCacheFlushVector) {
27322732
EXPECT_EQ(nullptr, kernel.mockKernel->kernelArgRequiresCacheFlush[0]);
27332733
}
27342734

2735+
TEST(KernelTest, givenKernelCompiledWithSimdSizeLowerThanExpectedWhenInitializingThenReturnError) {
2736+
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
2737+
auto minSimd = HwHelper::get(device->getHardwareInfo().platform.eRenderCoreFamily).getMinimalSIMDSize();
2738+
MockKernelWithInternals kernel(*device);
2739+
kernel.executionEnvironment.CompiledSIMD32 = 0;
2740+
kernel.executionEnvironment.CompiledSIMD16 = 0;
2741+
kernel.executionEnvironment.CompiledSIMD8 = 1;
2742+
2743+
cl_int retVal = kernel.mockKernel->initialize();
2744+
2745+
if (minSimd > 8) {
2746+
EXPECT_EQ(CL_INVALID_KERNEL, retVal);
2747+
} else {
2748+
EXPECT_EQ(CL_SUCCESS, retVal);
2749+
}
2750+
}
2751+
2752+
TEST(KernelTest, givenKernelCompiledWithSimdOneWhenInitializingThenReturnError) {
2753+
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
2754+
MockKernelWithInternals kernel(*device);
2755+
kernel.executionEnvironment.CompiledSIMD32 = 0;
2756+
kernel.executionEnvironment.CompiledSIMD16 = 0;
2757+
kernel.executionEnvironment.CompiledSIMD8 = 0;
2758+
kernel.executionEnvironment.LargestCompiledSIMDSize = 1;
2759+
2760+
cl_int retVal = kernel.mockKernel->initialize();
2761+
2762+
EXPECT_EQ(CL_SUCCESS, retVal);
2763+
}
2764+
27352765
TEST(KernelTest, whenAllocationRequiringCacheFlushThenAssignAllocationPointerToCacheFlushVector) {
27362766
MockGraphicsAllocation mockAllocation;
27372767
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));

0 commit comments

Comments
 (0)