Check if we do not access outside of array.
Change-Id: I3357b745d36398ad52777054f64a7915278c0463
This commit is contained in:
parent
9e89d4e6cd
commit
41f0ac3019
|
@ -21,6 +21,7 @@
|
|||
*/
|
||||
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/helpers/array_count.h"
|
||||
#include "runtime/helpers/basic_math.h"
|
||||
#include "runtime/helpers/debug_helpers.h"
|
||||
#include "runtime/helpers/dispatch_info.h"
|
||||
|
@ -100,8 +101,9 @@ inline uint32_t factor<0>(size_t workItems, uint32_t workSize, uint32_t maxWorkG
|
|||
|
||||
void computePowerOfTwoLWS(const size_t workItems[3], size_t simdSize, uint32_t maxWorkGroupSize, size_t workGroupSize[3], const uint32_t workDim, bool canUseNx4) {
|
||||
uint32_t targetIndex = canUseNx4 ? 2 : 0;
|
||||
auto arraySize = arrayCount(optimalHardwareThreadCountGeneric);
|
||||
|
||||
while (optimalHardwareThreadCountGeneric[targetIndex] > 1 && maxWorkGroupSize < optimalHardwareThreadCountGeneric[targetIndex] * simdSize)
|
||||
while (targetIndex < arraySize && optimalHardwareThreadCountGeneric[targetIndex] > 1 && maxWorkGroupSize < optimalHardwareThreadCountGeneric[targetIndex] * simdSize)
|
||||
targetIndex++;
|
||||
uint32_t optimalLocalThreads = optimalHardwareThreadCountGeneric[targetIndex];
|
||||
|
||||
|
|
|
@ -624,6 +624,17 @@ TEST(localWorkSizeTest, givenDispatchInfoWhenWorkSizeInfoIsCreatedThenItHasCorre
|
|||
WorkSizeInfo workSizeInfo(dispatchInfo);
|
||||
EXPECT_EQ(workSizeInfo.numThreadsPerSubSlice, threadsPerEu * euPerSubSlice);
|
||||
}
|
||||
TEST(localWorkSizeTest, givenMaxWorkgroupSizeEqualToSimdSizeWhenLwsIsCalculatedThenItIsDownsizedToMaxWorkgroupSize) {
|
||||
WorkSizeInfo wsInfo(32, 0u, 32, 0u, platformDevices[0]->pPlatform->eRenderCoreFamily, 32u, 0u, false, false);
|
||||
uint32_t workDim = 2;
|
||||
size_t workGroup[3] = {32, 32, 1};
|
||||
size_t workGroupSize[3];
|
||||
|
||||
OCLRT::computeWorkgroupSizeND(wsInfo, workGroupSize, workGroup, workDim);
|
||||
EXPECT_EQ(workGroupSize[0], 32u);
|
||||
EXPECT_EQ(workGroupSize[1], 1u);
|
||||
EXPECT_EQ(workGroupSize[2], 1u);
|
||||
}
|
||||
|
||||
TEST(localWorkSizeTest, givenDebugVariableEnableComputeWorkSizeNDWhenCheckValueExpectTrue) {
|
||||
EXPECT_TRUE(DebugManager.flags.EnableComputeWorkSizeND.get());
|
||||
|
|
Loading…
Reference in New Issue