refactor: move logic to dedicated functions

Related-To: NEO-14577
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk
2025-12-02 10:05:05 +00:00
committed by Compute-Runtime-Automation
parent 6c136527d6
commit fefc1f6a36
2 changed files with 27 additions and 6 deletions

View File

@@ -46,21 +46,37 @@ uint64_t HostFunctionStreamer::getHostFunctionId() const {
void HostFunctionStreamer::signalHostFunctionCompletion(const HostFunction &hostFunction) {
if (hostFunction.isInOrder) {
*hostFunctionIdAddress = HostFunctionStatus::completed;
isBusy.store(false, std::memory_order_release);
setHostFunctionIdAsCompleted();
endInOrderExecution();
}
}
void HostFunctionStreamer::prepareForExecution(const HostFunction &hostFunction) {
if (hostFunction.isInOrder) {
isBusy.store(true, std::memory_order_release);
startInOrderExecution();
} else {
*hostFunctionIdAddress = HostFunctionStatus::completed;
setHostFunctionIdAsCompleted();
}
pendingHostFunctions.fetch_sub(1, std::memory_order_acq_rel);
}
void HostFunctionStreamer::setHostFunctionIdAsCompleted() {
*hostFunctionIdAddress = HostFunctionStatus::completed;
}
void HostFunctionStreamer::endInOrderExecution() {
inOrderExecutionInProgress.store(false, std::memory_order_release);
}
void HostFunctionStreamer::startInOrderExecution() {
inOrderExecutionInProgress.store(true, std::memory_order_release);
}
bool HostFunctionStreamer::isInOrderExecutionInProgress() const {
return inOrderExecutionInProgress.load(std::memory_order_acquire);
}
HostFunction HostFunctionStreamer::getHostFunction() {
std::unique_lock lock(hostFunctionsMutex);
auto hostFunctionId = getHostFunctionId();
@@ -107,7 +123,7 @@ uint64_t HostFunctionStreamer::isHostFunctionReadyToExecute() const {
return false;
}
if (isBusy.load(std::memory_order_acquire)) {
if (isInOrderExecutionInProgress()) {
return false;
}

View File

@@ -66,6 +66,11 @@ class HostFunctionStreamer {
void prepareForExecution(const HostFunction &hostFunction);
private:
void setHostFunctionIdAsCompleted();
void startInOrderExecution();
void endInOrderExecution();
bool isInOrderExecutionInProgress() const;
std::mutex hostFunctionsMutex;
std::unordered_map<uint64_t, HostFunction> hostFunctions;
volatile uint64_t *hostFunctionIdAddress = nullptr; // 0 bit - used to signal that host function is pending or completed
@@ -73,7 +78,7 @@ class HostFunctionStreamer {
std::function<void(GraphicsAllocation &)> downloadAllocationImpl;
std::atomic<uint64_t> nextHostFunctionId{1};
std::atomic<uint32_t> pendingHostFunctions{0};
std::atomic<bool> isBusy{false};
std::atomic<bool> inOrderExecutionInProgress{false};
const bool isTbx = false;
};