Skip to content

Commit 9a8d4ee

Browse files
L0Debug - Fix scratch offset calculation
- euRatio should only affect EUs offsets - not thread offsets Resolves: NEO-7520 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com> Source: e0370d2
1 parent 5f7d58e commit 9a8d4ee

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

level_zero/tools/source/debug/debug_session_imp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,12 @@ size_t DebugSession::getPerThreadScratchOffset(size_t ptss, EuThread::ThreadId t
278278

279279
const auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily);
280280
uint32_t threadEuRatio = hwInfoConfig.getThreadEuRatioForScratch(hwInfo);
281-
281+
uint32_t multiplyFactor = 1;
282282
if (threadEuRatio / numThreadsPerEu > 1) {
283-
ptss *= threadEuRatio / numThreadsPerEu;
283+
multiplyFactor = threadEuRatio / numThreadsPerEu;
284284
}
285285

286-
auto threadOffset = (((threadId.slice * numSubslicesPerSlice + threadId.subslice) * numEuPerSubslice + threadId.eu) * numThreadsPerEu + threadId.thread) * ptss;
286+
auto threadOffset = (((threadId.slice * numSubslicesPerSlice + threadId.subslice) * numEuPerSubslice + threadId.eu) * numThreadsPerEu * multiplyFactor + threadId.thread) * ptss;
287287
return threadOffset;
288288
}
289289

level_zero/tools/test/unit_tests/sources/debug/xe_hpc_core/pvc/test_debug_session_pvc.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,22 @@ PVCTEST_F(PVCDebugSession, givenPVCRevId3WhenGettingPerThreadScratchOffsetThenPe
3636
EuThread::ThreadId thread0Eu0 = {0, 0, 0, 0, 0};
3737
EuThread::ThreadId thread0Eu1 = {0, 0, 0, 1, 0};
3838
EuThread::ThreadId thread2Subslice1 = {0, 0, 1, 0, 2};
39+
EuThread::ThreadId thread2EuLastSubslice1 = {0, 0, 1, hwInfo.gtSystemInfo.MaxEuPerSubSlice - 1, 2};
3940

4041
const uint32_t ptss = 128;
41-
const uint32_t adjustedPtss = hwInfoConfig.getThreadEuRatioForScratch(hwInfo) / numThreadsPerEu * ptss;
42+
const uint32_t ratio = hwInfoConfig.getThreadEuRatioForScratch(hwInfo) / numThreadsPerEu;
4243

4344
EXPECT_EQ(2u, hwInfoConfig.getThreadEuRatioForScratch(hwInfo) / numThreadsPerEu);
4445

4546
auto offset = debugSession->getPerThreadScratchOffset(ptss, thread0Eu0);
4647
EXPECT_EQ(0u, offset);
4748

4849
offset = debugSession->getPerThreadScratchOffset(ptss, thread0Eu1);
49-
EXPECT_EQ(adjustedPtss * numThreadsPerEu, offset);
50+
EXPECT_EQ(ptss * numThreadsPerEu * ratio, offset);
5051

5152
offset = debugSession->getPerThreadScratchOffset(ptss, thread2Subslice1);
52-
EXPECT_EQ(2 * adjustedPtss + adjustedPtss * hwInfo.gtSystemInfo.MaxEuPerSubSlice * numThreadsPerEu, offset);
53+
EXPECT_EQ((thread2Subslice1.subslice * hwInfo.gtSystemInfo.MaxEuPerSubSlice * numThreadsPerEu * ratio + thread2Subslice1.thread) * ptss, offset);
54+
55+
offset = debugSession->getPerThreadScratchOffset(ptss, thread2EuLastSubslice1);
56+
EXPECT_EQ(((thread2EuLastSubslice1.subslice * hwInfo.gtSystemInfo.MaxEuPerSubSlice + thread2EuLastSubslice1.eu) * numThreadsPerEu * ratio + thread2EuLastSubslice1.thread) * ptss, offset);
5357
}

0 commit comments

Comments
 (0)