Skip to content

Commit de3b29e

Browse files
ustachowigcbot
authored andcommitted
Report error message for tgm usage
Introduces a condition to verify that images are not used in kernels for the PVC platform
1 parent a98c040 commit de3b29e

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

IGC/AdaptorOCL/dllInterfaceCompute.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,23 @@ spv_result_t DisassembleSPIRV(
432432
#endif // defined(IGC_SPIRV_TOOLS_ENABLED)
433433

434434
#if defined(IGC_SPIRV_ENABLED)
435+
bool CheckForImageUsage(const std::string & SPIRVBinary) {
436+
std::istringstream repIS(SPIRVBinary);
437+
llvm::Optional<SPIRV::SPIRVModuleReport> report = SPIRV::getSpirvReport(repIS);
438+
SPIRV::SPIRVModuleTextReport textReport = SPIRV::formatSpirvReport(*report);
439+
440+
auto it = std::find(textReport.Capabilities.begin(), textReport.Capabilities.end(), "ImageBasic");
441+
return it != textReport.Capabilities.end();
442+
}
443+
435444
// Translate SPIR-V binary to LLVM Module
436445
bool TranslateSPIRVToLLVM(
437446
const STB_TranslateInputArgs& InputArgs,
438447
llvm::LLVMContext& Context,
439448
llvm::StringRef SPIRVBinary,
440449
llvm::Module*& LLVMModule,
441-
std::string& stringErrMsg)
450+
std::string& stringErrMsg,
451+
const PLATFORM& platform)
442452
{
443453
bool success = true;
444454
std::istringstream IS(SPIRVBinary.str());
@@ -468,6 +478,14 @@ bool TranslateSPIRVToLLVM(
468478
Opts.setSpecConst(SC.first, SC.second);
469479
}
470480

481+
if (platform.eProductFamily == IGFX_PVC) {
482+
if (CheckForImageUsage(SPIRVBinary.str())) {
483+
stringErrMsg = "For PVC platform images should not be used";
484+
return false;
485+
}
486+
}
487+
488+
471489
// Actual translation from SPIR-V to LLVM
472490
success = llvm::readSpirv(Context, Opts, IS, LLVMModule, stringErrMsg);
473491
#else // IGC Legacy SPIRV Translator
@@ -693,7 +711,7 @@ bool ProcessElfInput(
693711
Context.setAsSPIRV();
694712
std::string stringErrMsg;
695713
llvm::StringRef buf(SpvPair.second.pInput, SpvPair.second.InputSize);
696-
success = TranslateSPIRVToLLVM(SpvPair.second, *Context.getLLVMContext(), buf, pKernelModule, stringErrMsg);
714+
success = TranslateSPIRVToLLVM(SpvPair.second, *Context.getLLVMContext(), buf, pKernelModule, stringErrMsg, platform);
697715
if (!success)
698716
{
699717
SetErrorMessage(stringErrMsg, OutputArgs);
@@ -891,7 +909,8 @@ bool ParseInput(
891909
const STB_TranslateInputArgs* pInputArgs,
892910
STB_TranslateOutputArgs* pOutputArgs,
893911
llvm::LLVMContext& oclContext,
894-
TB_DATA_FORMAT inputDataFormatTemp)
912+
TB_DATA_FORMAT inputDataFormatTemp,
913+
const IGC::CPlatform& IGCPlatform)
895914
{
896915
pKernelModule = nullptr;
897916

@@ -955,7 +974,7 @@ bool ParseInput(
955974
#if defined(IGC_SPIRV_ENABLED)
956975
// convert SPIR-V binary to LLVM module
957976
std::string stringErrMsg;
958-
bool success = TranslateSPIRVToLLVM(*pInputArgs, oclContext, strInput, pKernelModule, stringErrMsg);
977+
bool success = TranslateSPIRVToLLVM(*pInputArgs, oclContext, strInput, pKernelModule, stringErrMsg, (PLATFORM&)IGCPlatform);
959978
#else
960979
std::string stringErrMsg{"SPIRV consumption not enabled for the TARGET."};
961980
bool success = false;
@@ -1339,7 +1358,7 @@ bool TranslateBuildSPMD(
13391358
DumpShaderFile(pOutputFolder, outputstr.str().c_str(), outputstr.str().size(), hash, "_cmd.txt");
13401359
}
13411360

1342-
if (!ParseInput(pKernelModule, pInputArgs, pOutputArgs, *llvmContext, inputDataFormatTemp))
1361+
if (!ParseInput(pKernelModule, pInputArgs, pOutputArgs, *llvmContext, inputDataFormatTemp, IGCPlatform))
13431362
{
13441363
return false;
13451364
}
@@ -1521,7 +1540,7 @@ bool TranslateBuildSPMD(
15211540

15221541
IGC::Debug::RegisterComputeErrHandlers(*oclContext.getLLVMContext());
15231542

1524-
if (!ParseInput(pKernelModule, pInputArgs, pOutputArgs, *oclContext.getLLVMContext(), inputDataFormatTemp))
1543+
if (!ParseInput(pKernelModule, pInputArgs, pOutputArgs, *oclContext.getLLVMContext(), inputDataFormatTemp, IGCPlatform))
15251544
{
15261545
return false;
15271546
}

IGC/ocloc_tests/pvc-image-error.cl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*========================== begin_copyright_notice ============================
2+
3+
Copyright (C) 2024 Intel Corporation
4+
5+
SPDX-License-Identifier: MIT
6+
7+
============================= end_copyright_notice ===========================*/
8+
9+
// REQUIRES: pvc-supported
10+
// RUN: ocloc compile -file %s -options "-cl-std=CL2.0" -device pvc 2>&1 | FileCheck %s
11+
12+
// CHECK: error: For PVC platform images should not be used
13+
// XFAIL: *
14+
15+
kernel void test(read_only image2d_t input) {}

0 commit comments

Comments
 (0)