#include <threadpool.h>
|
static void | Schedule (ThreadPool *tp, std::function< void()> fn) |
|
static void | TryParallelFor (ThreadPool *tp, std::ptrdiff_t total, double cost_per_unit, const std::function< void(std::ptrdiff_t first, std::ptrdiff_t last)> &fn) |
|
static void | TryParallelFor (ThreadPool *tp, std::ptrdiff_t total, const TensorOpCost &cost_per_unit, const std::function< void(std::ptrdiff_t first, std::ptrdiff_t last)> &fn) |
|
static void | TrySimpleParallelFor (ThreadPool *tp, std::ptrdiff_t total, const std::function< void(std::ptrdiff_t)> &fn) |
|
template<typename F > |
static void | TryBatchParallelFor (ThreadPool *tp, std::ptrdiff_t total, F &&fn, std::ptrdiff_t num_batches) |
|
static constexpr WorkInfo | PartitionWork (std::ptrdiff_t batch_idx, std::ptrdiff_t num_batches, std::ptrdiff_t total_work) |
|
static bool | ShouldParallelize (const ThreadPool *tp) |
|
static int | DegreeOfParallelism (const ThreadPool *tp) |
|
static void | StartProfiling (concurrency::ThreadPool *tp) |
|
static std::string | StopProfiling (concurrency::ThreadPool *tp) |
|
Definition at line 139 of file threadpool.h.
onnxruntime::concurrency::ThreadPool::ThreadPool |
( |
Env * |
env, |
|
|
const ThreadOptions & |
thread_options, |
|
|
const NAME_CHAR_TYPE * |
name, |
|
|
int |
degree_of_parallelism, |
|
|
bool |
low_latency_hint, |
|
|
bool |
force_hybrid = false |
|
) |
| |
onnxruntime::concurrency::ThreadPool::~ThreadPool |
( |
| ) |
|
static int onnxruntime::concurrency::ThreadPool::DegreeOfParallelism |
( |
const ThreadPool * |
tp | ) |
|
|
static |
void onnxruntime::concurrency::ThreadPool::DisableSpinning |
( |
| ) |
|
void onnxruntime::concurrency::ThreadPool::EnableSpinning |
( |
| ) |
|
onnxruntime::concurrency::ThreadPool::ORT_DISALLOW_COPY_AND_ASSIGNMENT |
( |
ThreadPool |
| ) |
|
static constexpr WorkInfo onnxruntime::concurrency::ThreadPool::PartitionWork |
( |
std::ptrdiff_t |
batch_idx, |
|
|
std::ptrdiff_t |
num_batches, |
|
|
std::ptrdiff_t |
total_work |
|
) |
| |
|
inlinestatic |
Calculate the start and end offsets for a batch.
Definition at line 326 of file threadpool.h.
static void onnxruntime::concurrency::ThreadPool::Schedule |
( |
ThreadPool * |
tp, |
|
|
std::function< void()> |
fn |
|
) |
| |
|
inlinestatic |
static bool onnxruntime::concurrency::ThreadPool::ShouldParallelize |
( |
const ThreadPool * |
tp | ) |
|
|
static |
template<typename F >
static void onnxruntime::concurrency::ThreadPool::TryBatchParallelFor |
( |
ThreadPool * |
tp, |
|
|
std::ptrdiff_t |
total, |
|
|
F && |
fn, |
|
|
std::ptrdiff_t |
num_batches |
|
) |
| |
|
inlinestatic |
Tries to call the given function in parallel, with calls split into (num_batches) batches.
- Parameters
-
num_batches | If it is zero, it will be replaced to the value of DegreeOfParallelism(). |
fn | A std::function or STL style functor with signature of "void f(std::ptrdiff_t);" Pitfall: Caller should cap num_batches to a reasonable value based on the cost of fn and the value of total . For example, if fn is as simple as: int sum=0; fn = [&](int i){sum +=i;} and total is 100, then num_batches should be just 1. |
```
Definition at line 283 of file threadpool.h.
static void onnxruntime::concurrency::ThreadPool::TryParallelFor |
( |
ThreadPool * |
tp, |
|
|
std::ptrdiff_t |
total, |
|
|
double |
cost_per_unit, |
|
|
const std::function< void(std::ptrdiff_t first, std::ptrdiff_t last)> & |
fn |
|
) |
| |
|
inlinestatic |
static void onnxruntime::concurrency::ThreadPool::TryParallelFor |
( |
ThreadPool * |
tp, |
|
|
std::ptrdiff_t |
total, |
|
|
const TensorOpCost & |
cost_per_unit, |
|
|
const std::function< void(std::ptrdiff_t first, std::ptrdiff_t last)> & |
fn |
|
) |
| |
|
static |
static void onnxruntime::concurrency::ThreadPool::TrySimpleParallelFor |
( |
ThreadPool * |
tp, |
|
|
std::ptrdiff_t |
total, |
|
|
const std::function< void(std::ptrdiff_t)> & |
fn |
|
) |
| |
|
inlinestatic |
The documentation for this class was generated from the following file: