Skip to content

Commit cbcf77a

Browse files
Fix out of bound problem while estimating Indirect Object Heap.
- While estimating the required size of Indirect Object Heap we were not handling properly the lack of local ids case - In such case we should allocate one GRF per HW thread that will be unused Change-Id: Ibcd359e431e3ffd9d55628ac7cf7eeefad72e7ba
1 parent 092f3be commit cbcf77a

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

runtime/command_queue/local_id_gen.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -54,8 +54,9 @@ inline size_t getThreadsPerWG(uint32_t simd, size_t lws) {
5454

5555
inline size_t getPerThreadSizeLocalIDs(uint32_t simd, uint32_t numChannels = 3) {
5656
auto numGRFSPerThread = getGRFsPerThread(simd);
57-
58-
return numChannels * numGRFSPerThread * sizeof(GRF);
57+
auto returnSize = numChannels * numGRFSPerThread * sizeof(GRF);
58+
returnSize = std::max(returnSize, sizeof(GRF));
59+
return returnSize;
5960
}
6061

6162
struct LocalIDHelper {

unit_tests/helpers/per_thread_data_tests.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -151,14 +151,15 @@ HWTEST_F(PerThreadDataXYZTests, getThreadPayloadSize) {
151151

152152
typedef PerThreadDataTests<false, false, false, false> PerThreadDataNoIdsTests;
153153

154-
HWTEST_F(PerThreadDataNoIdsTests, getLocalIdSizePerThread) {
155-
EXPECT_EQ(0u, PerThreadDataHelper::getLocalIdSizePerThread(simd, numChannels));
154+
HWTEST_F(PerThreadDataNoIdsTests, givenZeroChannelsWhenPassedTogetLocalIdSizePerThreadThenSizeOfOneGrfIsReturned) {
155+
EXPECT_EQ(32u, PerThreadDataHelper::getLocalIdSizePerThread(simd, numChannels));
156156
}
157157

158-
HWTEST_F(PerThreadDataNoIdsTests, getPerThreadDataSizeTotal) {
159-
size_t localWorkSize = 256;
160-
161-
EXPECT_EQ(0u, PerThreadDataHelper::getPerThreadDataSizeTotal(simd, numChannels, localWorkSize));
158+
HWTEST_F(PerThreadDataNoIdsTests, givenZeroChannelsAndHighWkgSizeWhengetPerThreadDataSizeTotalIsCalledThenReturnedSizeContainsUnusedGrfPerEachThread) {
159+
size_t localWorkSize = 256u;
160+
auto threadCount = localWorkSize / simd;
161+
auto expectedSize = threadCount * sizeof(GRF);
162+
EXPECT_EQ(expectedSize, PerThreadDataHelper::getPerThreadDataSizeTotal(simd, numChannels, localWorkSize));
162163
}
163164

164165
HWTEST_F(PerThreadDataNoIdsTests, sendPerThreadDataDoesntSendAnyData) {

0 commit comments

Comments
 (0)