fix: Correct logic for SIMD1

- For calculating number of threads per workgroup, treat simd 1 as it
  was simd 32
- Correct logic of calculating space for per thread data for simd 1
- Minor: unit tests refactor
- Corrected naming
Related-To: NEO-8261
Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
Kacper Nowak
2023-09-01 19:20:39 +02:00
committed by Compute-Runtime-Automation
parent b053e9348e
commit fc099ead2e
4 changed files with 68 additions and 17 deletions

View File

@@ -12,6 +12,7 @@
#include "shared/source/helpers/bindless_heaps_helper.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/local_memory_access_modes.h"
#include "shared/source/helpers/per_thread_data.h"
#include "shared/source/helpers/ray_tracing_helper.h"
#include "shared/source/indirect_heap/indirect_heap.h"
#include "shared/source/kernel/implicit_args.h"
@@ -295,19 +296,36 @@ TEST_F(SetKernelArgCacheTest, givenValidBufferArgumentWhenSetMultipleTimesThenSe
using KernelImpSetGroupSizeTest = Test<DeviceFixture>;
TEST_F(KernelImpSetGroupSizeTest, WhenCalculatingLocalIdsThenGrfSizeIsTakenFromCapabilityTable) {
TEST_F(KernelImpSetGroupSizeTest, givenLocalIdGenerationByRuntimeEnabledWhenSettingGroupSizeThenProperlyGenerateLocalIds) {
Mock<KernelImp> mockKernel;
Mock<Module> mockModule(this->device, nullptr);
mockKernel.descriptor.kernelAttributes.simdSize = 1;
mockKernel.kernelRequiresGenerationOfLocalIdsByRuntime = true; // although it is enabled for SIMD 1, make sure it is enforced
mockKernel.descriptor.kernelAttributes.numLocalIdChannels = 3;
mockKernel.module = &mockModule;
auto grfSize = mockModule.getDevice()->getHwInfo().capabilityTable.grfSize;
uint32_t groupSize[3] = {2, 3, 5};
auto ret = mockKernel.setGroupSize(groupSize[0], groupSize[1], groupSize[2]);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
EXPECT_EQ(groupSize[0] * groupSize[1] * groupSize[2], mockKernel.numThreadsPerThreadGroup);
EXPECT_EQ(grfSize * groupSize[0] * groupSize[1] * groupSize[2], mockKernel.perThreadDataSizeForWholeThreadGroup);
ASSERT_LE(grfSize * groupSize[0] * groupSize[1] * groupSize[2], mockKernel.perThreadDataSizeForWholeThreadGroup);
const auto &gfxHelper = mockModule.getDevice()->getGfxCoreHelper();
auto numThreadsPerTG = gfxHelper.calculateNumThreadsPerThreadGroup(
mockKernel.descriptor.kernelAttributes.simdSize,
groupSize[0] * groupSize[1] * groupSize[2],
grfSize,
mockKernel.kernelRequiresGenerationOfLocalIdsByRuntime);
auto perThreadDataSizeForWholeTGNeeded =
static_cast<uint32_t>(NEO::PerThreadDataHelper::getPerThreadDataSizeTotal(
mockKernel.descriptor.kernelAttributes.simdSize,
grfSize,
mockKernel.descriptor.kernelAttributes.numLocalIdChannels,
groupSize[0] * groupSize[1] * groupSize[2],
!mockKernel.kernelRequiresGenerationOfLocalIdsByRuntime,
gfxHelper));
EXPECT_EQ(numThreadsPerTG, mockKernel.getNumThreadsPerThreadGroup());
EXPECT_EQ((perThreadDataSizeForWholeTGNeeded / numThreadsPerTG), mockKernel.perThreadDataSize);
using LocalIdT = unsigned short;
auto threadOffsetInLocalIds = grfSize / sizeof(LocalIdT);
auto generatedLocalIds = reinterpret_cast<LocalIdT *>(mockKernel.perThreadDataForWholeThreadGroup);
@@ -335,7 +353,6 @@ TEST_F(KernelImpSetGroupSizeTest, givenLocalIdGenerationByRuntimeDisabledWhenSet
uint32_t groupSize[3] = {2, 3, 5};
auto ret = mockKernel.setGroupSize(groupSize[0], groupSize[1], groupSize[2]);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
EXPECT_EQ(groupSize[0] * groupSize[1] * groupSize[2], mockKernel.numThreadsPerThreadGroup);
EXPECT_EQ(0u, mockKernel.perThreadDataSizeForWholeThreadGroup);
EXPECT_EQ(0u, mockKernel.perThreadDataSize);
EXPECT_EQ(nullptr, mockKernel.perThreadDataForWholeThreadGroup);