Skip to content

Commit 24a0eac

Browse files
ViacheslavRbigcbot
authored andcommitted
Add check for IGC destruction.
If IGC static objects are destructed then IGC returns error code to driver.
1 parent e1cf4f5 commit 24a0eac

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

IGC/AdaptorOCL/ocl_igc_interface/impl/igc_ocl_translation_ctx_impl.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ inline TC::TB_DATA_FORMAT toLegacyFormat(CodeType::CodeType_t format){
8686
}
8787
}
8888

89+
struct IGC_State {
90+
protected:
91+
bool isAlive;
92+
public:
93+
IGC_State() {
94+
isAlive = true;
95+
}
96+
~IGC_State() {
97+
isAlive = false;
98+
}
99+
static const bool isDestructed() {
100+
static const IGC_State obj;
101+
return !obj.isAlive;
102+
}
103+
};
104+
89105
CIF_DECLARE_INTERFACE_PIMPL(IgcOclTranslationCtx) : CIF::PimplBase
90106
{
91107
CIF_PIMPL_DECLARE_CONSTRUCTOR(CIF::Version_t version, CIF_PIMPL(IgcOclDeviceCtx) *globalState,
@@ -115,6 +131,9 @@ CIF_DECLARE_INTERFACE_PIMPL(IgcOclTranslationCtx) : CIF::PimplBase
115131
CIF::Builtins::BufferSimple *outSpecConstantsIds,
116132
CIF::Builtins::BufferSimple *outSpecConstantsSizes)
117133
{
134+
if (IGC_State::isDestructed()) {
135+
return false;
136+
}
118137
bool success = false;
119138
const char* pInput = src->GetMemory<char>();
120139
uint32_t inputSize = static_cast<uint32_t>(src->GetSizeRaw());
@@ -159,6 +178,10 @@ CIF_DECLARE_INTERFACE_PIMPL(IgcOclTranslationCtx) : CIF::PimplBase
159178
if(outputInterface == nullptr){
160179
return nullptr; // OOM
161180
}
181+
if (IGC_State::isDestructed()) {
182+
outputInterface->GetImpl()->SetError(TranslationErrorType::UnhandledInput, "IGC is destructed");
183+
return outputInterface.release();
184+
}
162185

163186
TC::STB_TranslateInputArgs inputArgs;
164187
if(src != nullptr){

0 commit comments

Comments
 (0)