fix: use std::thread detach instead of astd::async for init builtin async

Resolves: GSD-7023

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2024-01-22 10:04:25 +00:00
committed by Compute-Runtime-Automation
parent f3a3ba5cb2
commit 7bd33af394
2 changed files with 13 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -184,7 +184,14 @@ void BuiltinFunctionsLibImpl::initBuiltinImageKernel(ImageBuiltin func) {
BuiltinFunctionsLibImpl::BuiltinFunctionsLibImpl(Device *device, NEO::BuiltIns *builtInsLib) : device(device), builtInsLib(builtInsLib) {
if (initBuiltinsAsyncEnabled(device)) {
this->initAsyncComplete = false;
this->initAsync = std::async(std::launch::async, &BuiltinFunctionsLibImpl::initBuiltinKernel, this, Builtin::fillBufferImmediate);
auto initFunc = [this]() {
this->initBuiltinKernel(Builtin::fillBufferImmediate);
this->initAsync.store(true);
};
std::thread initAsyncThread(initFunc);
initAsyncThread.detach();
}
}
@@ -269,7 +276,8 @@ std::unique_ptr<BuiltinFunctionsLibImpl::BuiltinData> BuiltinFunctionsLibImpl::l
void BuiltinFunctionsLibImpl::ensureInitCompletion() {
if (!this->initAsyncComplete) {
this->initAsync.wait();
while (!this->initAsync.load()) {
}
this->initAsyncComplete = true;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -47,8 +47,8 @@ struct BuiltinFunctionsLibImpl : BuiltinFunctionsLib {
Device *device;
NEO::BuiltIns *builtInsLib;
std::future<void> initAsync = {};
bool initAsyncComplete = true;
std::atomic_bool initAsync = false;
};
struct BuiltinFunctionsLibImpl::BuiltinData {
MOCKABLE_VIRTUAL ~BuiltinData();