mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
fix: setGroupSize caching to not hide error
When setting kernel group size with incorrect values, error would not be returned if method called with same arguments a second time. Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
8ada5db581
commit
56b167f530
@@ -301,15 +301,12 @@ ze_result_t KernelImp::setGroupSize(uint32_t groupSizeX, uint32_t groupSizeY,
|
||||
return ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION;
|
||||
}
|
||||
|
||||
this->groupSize[0] = groupSizeX;
|
||||
this->groupSize[1] = groupSizeY;
|
||||
this->groupSize[2] = groupSizeZ;
|
||||
for (uint32_t i = 0u; i < 3u; i++) {
|
||||
if (kernelDescriptor.kernelAttributes.requiredWorkgroupSize[i] != 0 &&
|
||||
kernelDescriptor.kernelAttributes.requiredWorkgroupSize[i] != this->groupSize[i]) {
|
||||
kernelDescriptor.kernelAttributes.requiredWorkgroupSize[i] != groupSize[i]) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
|
||||
"Invalid group size {%d, %d, %d} specified, requiredWorkGroupSize = {%d, %d, %d}\n",
|
||||
this->groupSize[0], this->groupSize[1], this->groupSize[2],
|
||||
groupSize[0], groupSize[1], groupSize[2],
|
||||
kernelDescriptor.kernelAttributes.requiredWorkgroupSize[0],
|
||||
kernelDescriptor.kernelAttributes.requiredWorkgroupSize[1],
|
||||
kernelDescriptor.kernelAttributes.requiredWorkgroupSize[2]);
|
||||
@@ -355,6 +352,9 @@ ze_result_t KernelImp::setGroupSize(uint32_t groupSizeX, uint32_t groupSizeY,
|
||||
|
||||
this->perThreadDataSize = perThreadDataSizeForWholeThreadGroup / numThreadsPerThreadGroup;
|
||||
}
|
||||
this->groupSize[0] = groupSizeX;
|
||||
this->groupSize[1] = groupSizeY;
|
||||
this->groupSize[2] = groupSizeZ;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -341,8 +341,18 @@ TEST_F(KernelImpSetGroupSizeTest, givenIncorrectGroupSizeDimensionWhenSettingGro
|
||||
}
|
||||
mockKernel.module = &mockModule;
|
||||
|
||||
uint32_t groupSize[3] = {1, 1, 1};
|
||||
uint32_t groupSize[3] = {2, 2, 2};
|
||||
auto ret = mockKernel.setGroupSize(groupSize[0], groupSize[1], groupSize[2]);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
|
||||
|
||||
groupSize[0] = 1;
|
||||
groupSize[1] = 1;
|
||||
groupSize[2] = 1;
|
||||
ret = mockKernel.setGroupSize(groupSize[0], groupSize[1], groupSize[2]);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION, ret);
|
||||
|
||||
// check that caching does not hide error
|
||||
ret = mockKernel.setGroupSize(groupSize[0], groupSize[1], groupSize[2]);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION, ret);
|
||||
}
|
||||
|
||||
@@ -647,6 +657,28 @@ TEST_F(KernelImmutableDataTests, givenKernelInitializedWithNoPrivateMemoryThenPr
|
||||
EXPECT_EQ(nullptr, kernel->privateMemoryGraphicsAllocation);
|
||||
}
|
||||
|
||||
TEST_F(KernelImmutableDataTests, givenKernelInitializedWithRequiredGroupSizeThenGroupSizeIsSetByDefault) {
|
||||
uint32_t perHwThreadPrivateMemorySizeRequested = 0u;
|
||||
bool isInternal = false;
|
||||
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData = std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
mockKernelImmData->mockKernelDescriptor->kernelAttributes.requiredWorkgroupSize[0] = 2u;
|
||||
mockKernelImmData->mockKernelDescriptor->kernelAttributes.requiredWorkgroupSize[1] = 3u;
|
||||
mockKernelImmData->mockKernelDescriptor->kernelAttributes.requiredWorkgroupSize[2] = 4u;
|
||||
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
|
||||
createKernel(kernel.get());
|
||||
|
||||
auto groupSize = kernel->getGroupSize();
|
||||
EXPECT_EQ(groupSize[0], 2u);
|
||||
EXPECT_EQ(groupSize[1], 3u);
|
||||
EXPECT_EQ(groupSize[2], 4u);
|
||||
}
|
||||
|
||||
TEST_F(KernelImmutableDataTests, givenKernelInitializedWithPrivateMemoryThenPrivateMemoryIsCreated) {
|
||||
uint32_t perHwThreadPrivateMemorySizeRequested = 32u;
|
||||
bool isInternal = false;
|
||||
|
||||
Reference in New Issue
Block a user