mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 08:53:55 +08:00
Fail build program if local mem size is higher then device capabilities.
Resolves: NEO-3411 Change-Id: I04e0b97bfeb9e66e4ea730a15e0c6bfd764cab62 Signed-off-by: Zdunowski, Piotr <piotr.zdunowski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
a0e7b703ca
commit
1460713d69
@@ -285,7 +285,7 @@ void Device::initializeCaps() {
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "computeUnitsUsedForScratch: %d\n", deviceInfo.computeUnitsUsedForScratch);
|
||||
|
||||
deviceInfo.localMemType = CL_LOCAL;
|
||||
deviceInfo.localMemSize = hwInfo.capabilityTable.slmSize << 10;
|
||||
deviceInfo.localMemSize = hwInfo.capabilityTable.slmSize * KB;
|
||||
|
||||
deviceInfo.imageSupport = hwInfo.capabilityTable.supportsImages;
|
||||
deviceInfo.image2DMaxWidth = 16384;
|
||||
|
||||
@@ -864,6 +864,10 @@ cl_int Program::parsePatchList(KernelInfo &kernelInfo, uint32_t kernelNum) {
|
||||
retVal = kernelInfo.createKernelAllocation(this->pDevice->getMemoryManager()) ? CL_SUCCESS : CL_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
if (this->pDevice && kernelInfo.workloadInfo.slmStaticSize > this->pDevice->getDeviceInfo().localMemSize) {
|
||||
retVal = CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
DEBUG_BREAK_IF(kernelInfo.heapInfo.pKernelHeader->KernelHeapSize && !this->pDevice);
|
||||
|
||||
return retVal;
|
||||
|
||||
@@ -2060,6 +2060,68 @@ TEST_F(ProgramTests, ProgramFromGenBinaryWithPATCH_TOKEN_GLOBAL_MEMORY_OBJECT_KE
|
||||
delete pProgram;
|
||||
}
|
||||
|
||||
TEST_F(ProgramTests, givenProgramFromGenBinaryWhenSLMSizeIsBiggerThenDeviceLimitThenReturnError) {
|
||||
cl_int retVal = CL_INVALID_BINARY;
|
||||
char genBin[1024] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'};
|
||||
size_t binSize = 10;
|
||||
|
||||
auto program = std::unique_ptr<Program>(Program::createFromGenBinary(*pDevice->getExecutionEnvironment(), nullptr, &genBin[0], binSize, false, &retVal));
|
||||
|
||||
EXPECT_NE(nullptr, program.get());
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ((uint32_t)CL_PROGRAM_BINARY_TYPE_EXECUTABLE, (uint32_t)program->getProgramBinaryType());
|
||||
|
||||
cl_device_id deviceId = pContext->getDevice(0);
|
||||
Device *pDevice = castToObject<Device>(deviceId);
|
||||
program->setDevice(pDevice);
|
||||
char *pBin = &genBin[0];
|
||||
retVal = CL_INVALID_BINARY;
|
||||
binSize = 0;
|
||||
|
||||
// Prepare simple program binary containing patch token PATCH_TOKEN_ALLOCATE_LOCAL_SURFACE
|
||||
SProgramBinaryHeader *pBHdr = (SProgramBinaryHeader *)pBin;
|
||||
pBHdr->Magic = iOpenCL::MAGIC_CL;
|
||||
pBHdr->Version = iOpenCL::CURRENT_ICBE_VERSION;
|
||||
pBHdr->Device = pDevice->getHardwareInfo().platform.eRenderCoreFamily;
|
||||
pBHdr->GPUPointerSizeInBytes = 8;
|
||||
pBHdr->NumberOfKernels = 1;
|
||||
pBHdr->SteppingId = 0;
|
||||
pBHdr->PatchListSize = 0;
|
||||
pBin += sizeof(SProgramBinaryHeader);
|
||||
binSize += sizeof(SProgramBinaryHeader);
|
||||
|
||||
SKernelBinaryHeaderCommon *pKHdr = (SKernelBinaryHeaderCommon *)pBin;
|
||||
pKHdr->CheckSum = 0;
|
||||
pKHdr->ShaderHashCode = 0;
|
||||
pKHdr->KernelNameSize = 8;
|
||||
pKHdr->PatchListSize = sizeof(iOpenCL::SPatchAllocateLocalSurface);
|
||||
pKHdr->KernelHeapSize = 0;
|
||||
pKHdr->GeneralStateHeapSize = 0;
|
||||
pKHdr->DynamicStateHeapSize = 0;
|
||||
pKHdr->SurfaceStateHeapSize = 0;
|
||||
pKHdr->KernelUnpaddedSize = 0;
|
||||
pBin += sizeof(SKernelBinaryHeaderCommon);
|
||||
binSize += sizeof(SKernelBinaryHeaderCommon);
|
||||
|
||||
strcpy(pBin, "TstCopy");
|
||||
pBin += pKHdr->KernelNameSize;
|
||||
binSize += pKHdr->KernelNameSize;
|
||||
|
||||
SPatchAllocateLocalSurface *pPatch = (SPatchAllocateLocalSurface *)pBin;
|
||||
pPatch->Token = iOpenCL::PATCH_TOKEN_ALLOCATE_LOCAL_SURFACE;
|
||||
pPatch->Size = sizeof(iOpenCL::SPatchAllocateLocalSurface);
|
||||
pPatch->TotalInlineLocalMemorySize = static_cast<uint32_t>(pDevice->getDeviceInfo().localMemSize * 2);
|
||||
|
||||
pBin += sizeof(SPatchAllocateLocalSurface);
|
||||
binSize += sizeof(SPatchAllocateLocalSurface);
|
||||
|
||||
// Decode prepared program binary
|
||||
program->storeGenBinary(&genBin[0], binSize);
|
||||
retVal = program->processGenBinary();
|
||||
|
||||
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
|
||||
}
|
||||
|
||||
TEST_F(ProgramTests, ProgramFromGenBinaryWithPATCH_TOKEN_GTPIN_FREE_GRF_INFO) {
|
||||
#define GRF_INFO_SIZE 44u
|
||||
cl_int retVal = CL_INVALID_BINARY;
|
||||
|
||||
Reference in New Issue
Block a user