1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
/*
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/command_stream/host_function_interface.h"
#include "shared/source/command_stream/host_function_worker_thread_pool.h"
#include "shared/source/utilities/stackvec.h"
#include <functional>
#include <memory>
#include <mutex>
#include <stop_token>
#include <thread>
#include <vector>
namespace NEO {
class GraphicsAllocation;
struct HostFunction;
class HostFunctionStreamer;
class HostFunctionScheduler final : public HostFunctionWorker {
public:
HostFunctionScheduler(bool skipHostFunctionExecution,
int32_t threadsInThreadPoolLimit);
~HostFunctionScheduler() override;
void start(HostFunctionStreamer *streamer) override;
void finish() override;
void submit(uint32_t nHostFunctions) noexcept override;
private:
void scheduleHostFunctionToThreadPool(HostFunctionStreamer *streamer, uint64_t hostFunctionId) noexcept;
void schedulerLoop(std::stop_token st) noexcept;
void registerHostFunctionStreamer(HostFunctionStreamer *streamer);
uint64_t isHostFunctionReadyToExecute(HostFunctionStreamer *streamer);
std::mutex registeredStreamersMutex;
std::once_flag shutdownOnceFlag;
std::counting_semaphore<> semaphore{0};
HostFunctionThreadPool threadPool;
std::vector<HostFunctionStreamer *> registeredStreamers;
};
} // namespace NEO
|