13#ifndef LLVM_EXECUTIONENGINE_ORC_TASKDISPATCH_H
14#define LLVM_EXECUTIONENGINE_ORC_TASKDISPATCH_H
16#include "llvm/Config/llvm-config.h"
24#if LLVM_ENABLE_THREADS
25#include <condition_variable>
45 virtual void run() = 0;
48 void anchor()
override;
63 DescBuffer(
std::
move(DescBuffer)) {}
69 void run()
override { Fn(); }
74 std::string DescBuffer;
78template <
typename FnT>
81 return std::make_unique<GenericNamedTaskImpl<FnT>>(std::forward<FnT>(Fn),
86template <
typename FnT>
87std::unique_ptr<GenericNamedTask>
91 return std::make_unique<GenericNamedTaskImpl<FnT>>(std::forward<FnT>(Fn),
110 void dispatch(std::unique_ptr<Task>
T)
override;
114#if LLVM_ENABLE_THREADS
118 DynamicThreadPoolTaskDispatcher(
119 std::optional<size_t> MaxMaterializationThreads)
120 : MaxMaterializationThreads(MaxMaterializationThreads) {}
121 void dispatch(std::unique_ptr<Task>
T)
override;
122 void shutdown()
override;
124 std::mutex DispatchMutex;
126 size_t Outstanding = 0;
127 std::condition_variable OutstandingCV;
129 std::optional<size_t> MaxMaterializationThreads;
130 size_t NumMaterializationThreads = 0;
131 std::deque<std::unique_ptr<Task>> MaterializationTaskQueue;
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 const char * DefaultDescription
Runs all tasks on the current thread.
void shutdown() override
Called by ExecutionSession. Waits until all tasks have completed.
void dispatch(std::unique_ptr< Task > T) override
Run the given task.
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.