mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Print warning when kernel uses too much SLM
Instead of just returning proper error code in case of exceeding available Shared Local Memory size we also want to print error message to make debugging easier. Related-To: NEO-7280 Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
d4cddc7ecd
commit
7953d15826
@ -39,7 +39,10 @@ TEST_F(clEnqueueNDRangeKernelTests, GivenValidParametersWhenExecutingKernelThenS
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueNDRangeKernelTests, GivenKernelWithSlmSizeExceedingLocalMemorySizeWhenExecutingKernelThenOutOfResourcesIsReturned) {
|
||||
TEST_F(clEnqueueNDRangeKernelTests, GivenKernelWithSlmSizeExceedingLocalMemorySizeWhenExecutingKernelThenDebugMsgErrIsPrintedAndOutOfResourcesIsReturned) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.PrintDebugMessages.set(true);
|
||||
|
||||
cl_uint workDim = 1;
|
||||
size_t globalWorkOffset[3] = {0, 0, 0};
|
||||
size_t globalWorkSize[3] = {1, 1, 1};
|
||||
@ -48,6 +51,8 @@ TEST_F(clEnqueueNDRangeKernelTests, GivenKernelWithSlmSizeExceedingLocalMemorySi
|
||||
cl_event *eventWaitList = nullptr;
|
||||
cl_event *event = nullptr;
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
|
||||
auto localMemSize = static_cast<uint32_t>(pDevice->getDevice().getDeviceInfo().localMemSize);
|
||||
|
||||
pProgram->mockKernelInfo.kernelDescriptor.kernelAttributes.slmInlineSize = localMemSize - 10u;
|
||||
@ -64,6 +69,11 @@ TEST_F(clEnqueueNDRangeKernelTests, GivenKernelWithSlmSizeExceedingLocalMemorySi
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStderr();
|
||||
EXPECT_EQ(std::string(""), output);
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
|
||||
pProgram->mockKernelInfo.kernelDescriptor.kernelAttributes.slmInlineSize = localMemSize + 10u;
|
||||
retVal = clEnqueueNDRangeKernel(
|
||||
pCommandQueue,
|
||||
@ -77,6 +87,11 @@ TEST_F(clEnqueueNDRangeKernelTests, GivenKernelWithSlmSizeExceedingLocalMemorySi
|
||||
event);
|
||||
|
||||
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
|
||||
|
||||
output = testing::internal::GetCapturedStderr();
|
||||
const auto &slmInlineSize = pProgram->mockKernelInfo.kernelDescriptor.kernelAttributes.slmInlineSize;
|
||||
std::string expectedOutput = "Size of SLM (" + std::to_string(slmInlineSize) + ") larger than available (" + std::to_string(localMemSize) + ")\n";
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueNDRangeKernelTests, GivenQueueIncapableWhenExecutingKernelThenInvalidOperationIsReturned) {
|
||||
|
@ -3005,10 +3005,15 @@ TEST_F(KernelCreateTest, whenInitFailedThenReturnNull) {
|
||||
EXPECT_EQ(nullptr, ret);
|
||||
}
|
||||
|
||||
TEST_F(KernelCreateTest, whenSlmSizeExceedsLocalMemorySizeThenReturnOutOfResources) {
|
||||
TEST_F(KernelCreateTest, whenSlmSizeExceedsLocalMemorySizeThenDebugMsgErrIsPrintedAndOutOfResourcesIsReturned) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.PrintDebugMessages.set(true);
|
||||
|
||||
KernelInfo info{};
|
||||
cl_int retVal{};
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
|
||||
auto localMemSize = static_cast<uint32_t>(mockProgram.mDevice.getDevice().getDeviceInfo().localMemSize);
|
||||
|
||||
info.kernelDescriptor.kernelAttributes.slmInlineSize = localMemSize - 10u;
|
||||
@ -3016,6 +3021,11 @@ TEST_F(KernelCreateTest, whenSlmSizeExceedsLocalMemorySizeThenReturnOutOfResourc
|
||||
EXPECT_EQ(nullptr, ret);
|
||||
EXPECT_NE(CL_OUT_OF_RESOURCES, retVal);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStderr();
|
||||
EXPECT_EQ(std::string(""), output);
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
|
||||
retVal = 0;
|
||||
|
||||
info.kernelDescriptor.kernelAttributes.slmInlineSize = localMemSize + 10u;
|
||||
@ -3023,6 +3033,11 @@ TEST_F(KernelCreateTest, whenSlmSizeExceedsLocalMemorySizeThenReturnOutOfResourc
|
||||
EXPECT_EQ(nullptr, ret);
|
||||
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
|
||||
|
||||
output = testing::internal::GetCapturedStderr();
|
||||
const auto &slmInlineSize = info.kernelDescriptor.kernelAttributes.slmInlineSize;
|
||||
std::string expectedOutput = "Size of SLM (" + std::to_string(slmInlineSize) + ") larger than available (" + std::to_string(localMemSize) + ")\n";
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
|
||||
ret = Kernel::create<MockKernel>(&mockProgram, info, mockProgram.mDevice, nullptr);
|
||||
EXPECT_EQ(nullptr, ret);
|
||||
}
|
||||
|
@ -2063,16 +2063,28 @@ TEST_F(ProgramTests, whenCreatingFromZebinThenAppendAllowZebinFlagToBuildOptions
|
||||
EXPECT_STREQ(expectedOptions.c_str(), program->options.c_str());
|
||||
}
|
||||
|
||||
TEST_F(ProgramTests, givenProgramFromGenBinaryWhenSLMSizeIsBiggerThenDeviceLimitThenReturnError) {
|
||||
TEST_F(ProgramTests, givenProgramFromGenBinaryWhenSLMSizeIsBiggerThenDeviceLimitThenPrintDebugMsgAndReturnError) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.PrintDebugMessages.set(true);
|
||||
|
||||
PatchTokensTestData::ValidProgramWithKernelUsingSlm patchtokensProgram;
|
||||
patchtokensProgram.slmMutable->TotalInlineLocalMemorySize = static_cast<uint32_t>(pDevice->getDeviceInfo().localMemSize * 2);
|
||||
patchtokensProgram.recalcTokPtr();
|
||||
auto program = std::make_unique<MockProgram>(nullptr, false, toClDeviceVector(*pClDevice));
|
||||
program->buildInfos[rootDeviceIndex].unpackedDeviceBinary = makeCopy(patchtokensProgram.storage.data(), patchtokensProgram.storage.size());
|
||||
program->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize = patchtokensProgram.storage.size();
|
||||
|
||||
::testing::internal::CaptureStderr();
|
||||
|
||||
auto retVal = program->processGenBinary(*pClDevice);
|
||||
|
||||
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStderr();
|
||||
const auto &slmInlineSize = patchtokensProgram.slmMutable->TotalInlineLocalMemorySize;
|
||||
const auto &localMemSize = pDevice->getDeviceInfo().localMemSize;
|
||||
std::string expectedOutput = "Size of SLM (" + std::to_string(slmInlineSize) + ") larger than available (" + std::to_string(localMemSize) + ")\n";
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
}
|
||||
|
||||
TEST_F(ProgramTests, givenExistingConstantSurfacesWhenProcessGenBinaryThenCleanupTheSurfaceOnlyForSpecificDevice) {
|
||||
|
Reference in New Issue
Block a user