Skip to content

Commit 8f52dd0

Browse files
aparshin-inteligcbot
authored andcommitted
[Autobackout][FuncReg]Revert of change: 484e05a
implement proper error reporting for the case when VC platform selector could not determine target platform
1 parent 64f688c commit 8f52dd0

File tree

7 files changed

+37
-120
lines changed

7 files changed

+37
-120
lines changed

IGC/AdaptorOCL/ocl_igc_interface/impl/fcl_ocl_translation_ctx_impl.cpp

Lines changed: 27 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static std::vector<const char*>
179179
const std::string& inputFile,
180180
CIF::Builtins::BufferSimple* options,
181181
llvm::StringSaver& stringSaver,
182-
const std::string& platform,
182+
const char *platform,
183183
unsigned stepping) {
184184

185185
llvm::SmallVector<const char*, 20> userArgs;
@@ -216,12 +216,11 @@ static std::vector<const char*>
216216
return S.startswith("-march=") || S.startswith("-mcpu=");
217217
});
218218
if (!CmArchPresent) {
219-
// Prefer user-specified architecture. If none specified -
220-
// pass the runtime-selected architecture.
221-
if (platform.empty())
222-
result.push_back(stringSaver.save("-march=" + cmfeDefaultArch).data());
219+
// Pass the runtime-specified architecture if user hasn't specified one
220+
if (platform)
221+
result.push_back(stringSaver.save("-march=" + std::string(platform)).data());
223222
else
224-
result.push_back(stringSaver.save("-march=" + platform).data());
223+
result.push_back(stringSaver.save("-march=" + cmfeDefaultArch).data());
225224
}
226225

227226
result.insert(result.end(), userArgs.begin(), userArgs.end());
@@ -304,15 +303,15 @@ static std::string getCMFEWrapperDir() {
304303
#endif
305304
}
306305

306+
#endif // defined(IGC_VC_ENABLED)
307+
307308
// This essentialy duplicates existing DumpShaderFile in dllInterfaceCompute
308309
// but now I see no way to reuse it. To be converged later
309-
static void DumpInputs(const PLATFORM *Platform,
310-
const std::string& SelectedPlatform,
310+
static void DumpInputs(PLATFORM *Platform, const char *Selected,
311311
int Stepping, CIF::Builtins::BufferSimple* src,
312312
CIF::Builtins::BufferSimple* options,
313313
CIF::Builtins::BufferSimple* internalOptions,
314-
CIF::Builtins::BufferSimple* tracingOptions)
315-
{
314+
CIF::Builtins::BufferSimple* tracingOptions) {
316315
#if defined( _DEBUG ) || defined( _INTERNAL )
317316
// check for shader dumps enabled
318317
if (!FCL_IGC_IS_FLAG_ENABLED(ShaderDumpEnable))
@@ -336,7 +335,7 @@ static void DumpInputs(const PLATFORM *Platform,
336335
Os << "NEO passed: DisplayCore = " << Core
337336
<< ", RenderCore = " << RenderCore << ", Product = " << Product
338337
<< ", Revision = " << RevId << "\n";
339-
Os << "IGC translated into: <" << SelectedPlatform << ">, " << Stepping << "\n";
338+
Os << "IGC translated into: " << Selected << ", " << Stepping << "\n";
340339
} else {
341340
Os << "Nothing came from NEO\n";
342341
}
@@ -379,40 +378,6 @@ static void DumpInputs(const PLATFORM *Platform,
379378
#endif // defined( _DEBUG ) || defined( _INTERNAL )
380379
}
381380

382-
struct CMFEPlatform {
383-
std::string PlatformStr;
384-
unsigned Stepping;
385-
};
386-
387-
template <typename T>
388-
static llvm::Optional<CMFEPlatform> describeCMFEPlatform(
389-
const T *platformImpl,
390-
CIF::Builtins::BufferSimple* src,
391-
CIF::Builtins::BufferSimple* options,
392-
CIF::Builtins::BufferSimple* internalOptions,
393-
CIF::Builtins::BufferSimple* tracingOptions)
394-
{
395-
bool Error = false;
396-
const PLATFORM *platformDescr = nullptr;
397-
unsigned stepping = 0;
398-
std::string platformStr;
399-
400-
if (platformImpl)
401-
{
402-
platformDescr = &platformImpl->p;
403-
stepping = platformDescr->usRevId;
404-
platformStr = cmc::getPlatformStr(*platformDescr, /* inout */ stepping);
405-
Error = platformStr.empty();
406-
}
407-
DumpInputs(platformDescr, platformStr, stepping,
408-
src, options, internalOptions, tracingOptions);
409-
410-
if (Error)
411-
return {};
412-
return CMFEPlatform { platformStr, stepping };
413-
}
414-
#endif // defined(IGC_VC_ENABLED)
415-
416381
OclTranslationOutputBase* CIF_PIMPL(FclOclTranslationCtx)::TranslateCM(
417382
CIF::Version_t outVersion,
418383
CIF::Builtins::BufferSimple* src,
@@ -428,22 +393,27 @@ OclTranslationOutputBase* CIF_PIMPL(FclOclTranslationCtx)::TranslateCM(
428393
if (outputInterface == nullptr)
429394
return nullptr;
430395

396+
PLATFORM *platformDescr = nullptr;
397+
const char *platformStr = nullptr;
398+
unsigned stepping = 0U;
399+
400+
if(globalState.GetPlatformImpl()){
401+
// NEO supports platform interface
402+
auto *PlatformImpl = globalState.GetPlatformImpl();
403+
platformDescr = &PlatformImpl->p;
404+
stepping = PlatformImpl->p.usRevId;
405+
platformStr = cmc::getPlatformStr(PlatformImpl->p, /* inout */ stepping);
406+
}
407+
408+
DumpInputs(platformDescr, platformStr, stepping,
409+
src, options, internalOptions, tracingOptions);
410+
431411
OclTranslationOutputBase& Out = *outputInterface;
432412

433413
#if defined(IGC_VC_ENABLED)
434414
auto ErrFn = [&Out](const std::string& Err) {
435415
Out.GetImpl()->SetError(TranslationErrorType::Internal, Err.c_str());
436416
};
437-
438-
auto MaybePlatform = describeCMFEPlatform(globalState.GetPlatformImpl(),
439-
src, options, internalOptions,
440-
tracingOptions);
441-
if (!MaybePlatform)
442-
{
443-
ErrFn("could not derive platform string and stepping");
444-
return outputInterface;
445-
}
446-
447417
auto MaybeFE =
448418
IGC::AdaptorCM::Frontend::makeFEWrapper(ErrFn, getCMFEWrapperDir());
449419
if (!MaybeFE)
@@ -456,8 +426,8 @@ OclTranslationOutputBase* CIF_PIMPL(FclOclTranslationCtx)::TranslateCM(
456426
llvm::BumpPtrAllocator A;
457427
llvm::StringSaver Saver(A);
458428
auto& FE = MaybeFE.getValue();
459-
auto FeArgs = processFeOptions(FE.LibInfo(), OptSrc.getValue(), options, Saver,
460-
MaybePlatform->PlatformStr, MaybePlatform->Stepping);
429+
auto FeArgs = processFeOptions(FE.LibInfo(), OptSrc.getValue(),
430+
options, Saver, platformStr, stepping);
461431

462432
auto Drv = FE.buildDriverInvocation(FeArgs.size(), FeArgs.data());
463433
if (!Drv)

IGC/VectorCompiler/igcdeps/src/TranslationInterface.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,13 @@ class BuildDiag {
5050
void addWarning(const std::string &Str) {
5151
BuildLog << "warning: " << Str << "\n";
5252
}
53-
void addError(const std::string &Str) {
54-
BuildLog << "error: " << Str << "\n";
55-
HasError = true;
56-
}
5753
std::string getLog() const { return BuildLog.str(); }
58-
bool hasError() const { return HasError; }
5954

6055
private:
56+
// for now, we don't differentiate between warnings and errors
57+
// the expectation is that a marker indicating an error shall be
58+
// reported by other means
6159
std::ostringstream BuildLog;
62-
bool HasError = false;
6360
};
6461

6562
} // namespace
@@ -131,14 +128,12 @@ std::unique_ptr<llvm::MemoryBuffer> getVCModuleBuffer() {
131128
}
132129

133130
static void adjustPlatform(const IGC::CPlatform &IGCPlatform,
134-
vc::CompileOptions &Opts, BuildDiag &Diag) {
131+
vc::CompileOptions &Opts) {
135132
auto &PlatformInfo = IGCPlatform.getPlatformInfo();
136133
unsigned RevId = PlatformInfo.usRevId;
137134
Opts.CPUStr = cmc::getPlatformStr(PlatformInfo, /* inout */ RevId);
138135
Opts.RevId = RevId;
139136
Opts.WATable = &IGCPlatform.getWATable();
140-
if (Opts.CPUStr.empty())
141-
Diag.addError("could not determine target Platform");
142137
}
143138

144139
static void adjustFileType(TC::TB_DATA_FORMAT DataFormat,
@@ -210,7 +205,7 @@ static void adjustDumpOptions(vc::CompileOptions &Opts) {
210205
static void adjustOptions(const IGC::CPlatform &IGCPlatform,
211206
TC::TB_DATA_FORMAT DataFormat,
212207
vc::CompileOptions &Opts, BuildDiag &Diag) {
213-
adjustPlatform(IGCPlatform, Opts, Diag);
208+
adjustPlatform(IGCPlatform, Opts);
214209
adjustFileType(DataFormat, Opts);
215210
adjustOptLevel(Opts);
216211
adjustBinaryFormat(Opts.Binary);
@@ -430,15 +425,8 @@ std::error_code vc::translateBuild(const TC::STB_TranslateInputArgs *InputArgs,
430425

431426
// here we have Opts set and can dump what we got from runtime and how
432427
// we understood it
433-
// we intentionally query Diag object after Platform dumps
434428
dumpPlatform(Opts, IGCPlatform.getPlatformInfo(), *Dumper);
435429

436-
// Note: we intentionally query Diag object after Platform dumps
437-
if (Diag.hasError())
438-
return getError(
439-
llvm::make_error<vc::CompilationAbortedError>(Diag.getLog()),
440-
OutputArgs);
441-
442430
if (IGC_IS_FLAG_ENABLED(ShaderOverride))
443431
Opts.ShaderOverrider =
444432
vc::createVC_IGCShaderOverrider(Hash, IGCPlatform.getPlatformInfo());

IGC/VectorCompiler/include/vc/Support/Status.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,6 @@ class OptionError final : public llvm::ErrorInfo<OptionError> {
135135
}
136136
};
137137

138-
class CompilationAbortedError final
139-
: public llvm::ErrorInfo<CompilationAbortedError> {
140-
public:
141-
static char ID;
142-
143-
private:
144-
std::string Message;
145-
146-
public:
147-
CompilationAbortedError(llvm::StringRef Msg) : Message(Msg.str()) {}
148-
149-
void log(llvm::raw_ostream &OS) const override;
150-
std::error_code convertToErrorCode() const override {
151-
return make_error_code(errc::compilation_aborted);
152-
}
153-
};
154-
155138
} // namespace vc
156139

157140
#endif

IGC/VectorCompiler/include/vc/Support/StatusCode.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ enum class errc {
4141
// Bad option in internal options.
4242
invalid_internal_option,
4343

44-
// Loading of OCL BiF module failed.
44+
// loading OCL BiF module failed
4545
bif_load_fail,
46-
47-
// Compilation was aborted.
48-
compilation_aborted
4946
};
5047

5148
const std::error_category &err_category() noexcept;

IGC/VectorCompiler/include/vc/Support/StatusTraits.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ template <> struct ErrorTraits<errc::bif_load_fail> {
6868
}
6969
};
7070

71-
template <> struct ErrorTraits<errc::compilation_aborted> {
72-
static llvm::StringRef getMessage() { return "compilation aborted"; }
73-
};
74-
7571
} // namespace vc
7672

7773
#endif

IGC/VectorCompiler/lib/Support/Status.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ std::string vc_error_category::message(int condition) const {
4949
return std::string(ErrorTraits<errc::invalid_internal_option>::getMessage());
5050
case errc::bif_load_fail:
5151
return std::string(ErrorTraits<errc::bif_load_fail>::getMessage());
52-
case errc::compilation_aborted:
53-
return std::string(ErrorTraits<errc::compilation_aborted>::getMessage());
5452
}
5553
IGC_ASSERT_EXIT_MESSAGE(0, "Unknown error code");
5654
}
@@ -130,12 +128,4 @@ void OptionError::log(llvm::raw_ostream &OS) const {
130128
}
131129
// }}
132130

133-
// CompilationAbortedError {{
134-
char CompilationAbortedError::ID = 0;
135-
136-
void CompilationAbortedError::log(llvm::raw_ostream &OS) const {
137-
OS << ErrorTraits<errc::compilation_aborted>::getMessage() << ": " << Message;
138-
}
139-
// }}
140-
141131
} // namespace vc

IGC/common/VCPlatformSelector.hpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,7 @@ SPDX-License-Identifier: MIT
2121

2222
namespace cmc {
2323

24-
// getPlatformStr:
25-
// given a PLATFORM data structure and "revision ID" returns
26-
// "Platform String" - the string identifier for the targeted platform.
27-
// Note: the interpretation of RevId ("revision ID") depends on the target
28-
// platform. RevID is considered an input/output parameter and may be
29-
// changed during the invocation.
30-
// If the target platform can not be derived - an empty string is returned,
31-
// in this case the client code is expected to report an error.
32-
inline std::string getPlatformStr(const PLATFORM &Platform, unsigned &RevId) {
24+
inline const char *getPlatformStr(PLATFORM Platform, unsigned &RevId) {
3325
// after some consultations with Wndows KMD folks,
3426
// only render core shall be used in all cases
3527
auto Core = Platform.eRenderCoreFamily;
@@ -52,9 +44,10 @@ inline std::string getPlatformStr(const PLATFORM &Platform, unsigned &RevId) {
5244
if (Product == IGFX_DG1)
5345
return "DG1";
5446
default:
55-
// Return an empty platform string to indicate an error.
56-
return "";
47+
IGC_ASSERT_MESSAGE(0, "unsupported platform");
48+
break;
5749
}
50+
return IGC_MANGLE("SKL");
5851
}
5952

6053
} // namespace cmc

0 commit comments

Comments
 (0)