13#ifndef LLVM_EXECUTIONENGINE_ORC_TASKDISPATCH_H
14#define LLVM_EXECUTIONENGINE_ORC_TASKDISPATCH_H
16#include "llvm/Config/llvm-config.h"
25#if LLVM_ENABLE_THREADS
26#include <condition_variable>
46 virtual void run() = 0;
49 void anchor()
override;
64 DescBuffer(
std::
move(DescBuffer)) {}
70 void run()
override { Fn(); }
75 std::string DescBuffer;
79template <
typename FnT>
82 return std::make_unique<GenericNamedTaskImpl<FnT>>(std::forward<FnT>(Fn),
87template <
typename FnT>
88std::unique_ptr<GenericNamedTask>
92 return std::make_unique<GenericNamedTaskImpl<FnT>>(std::forward<FnT>(Fn),
103 void anchor()
override;
121 void dispatch(std::unique_ptr<Task>
T)
override;
122 void shutdown()
override;
125#if LLVM_ENABLE_THREADS
129 DynamicThreadPoolTaskDispatcher(
130 std::optional<size_t> MaxMaterializationThreads)
131 : MaxMaterializationThreads(MaxMaterializationThreads) {}
133 void dispatch(std::unique_ptr<Task>
T)
override;
134 void shutdown()
override;
136 bool canRunMaterializationTaskNow();
137 bool canRunIdleTaskNow();
139 std::mutex DispatchMutex;
140 bool Shutdown =
false;
141 size_t Outstanding = 0;
142 std::condition_variable OutstandingCV;
144 std::optional<size_t> MaxMaterializationThreads;
145 size_t NumMaterializationThreads = 0;
146 std::deque<std::unique_ptr<Task>> MaterializationTaskQueue;
147 std::deque<std::unique_ptr<Task>> IdleTaskQueue;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Inheritance utility for extensible RTTI.
Generic task implementation.
GenericNamedTaskImpl(FnT &&Fn, const char *Desc)
GenericNamedTaskImpl(FnT &&Fn, std::string DescBuffer)
void printDescription(raw_ostream &OS) override
Base class for generic tasks.
static LLVM_ABI const char * DefaultDescription
IdleTask can be used as the basis for low-priority tasks, e.g.
Runs all tasks on the current thread.
Abstract base for classes that dispatch ORC Tasks.
virtual void shutdown()=0
Called by ExecutionSession. Waits until all tasks have completed.
virtual void dispatch(std::unique_ptr< Task > T)=0
Run the given task.
virtual ~TaskDispatcher()
Represents an abstract task for ORC to run.
virtual void run()=0
Run the task.
virtual void printDescription(raw_ostream &OS)=0
Description of the task to be performed. Used for logging.
This class implements an extremely fast bulk output stream that can only output to a stream.
std::unique_ptr< GenericNamedTask > makeGenericNamedTask(FnT &&Fn, std::string Desc)
Create a generic named task from a std::string description.
This is an optimization pass for GlobalISel generic memory operations.
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
Description of the encoding of one expression Op.