Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
thread_pool_common.h File Reference

Go to the source code of this file.

Classes

struct  Halide::Runtime::Internal::halide_cond_with_spinning
 
struct  Halide::Runtime::Internal::work
 
struct  Halide::Runtime::Internal::work_queue_t
 
struct  halide_semaphore_impl_t
 

Namespaces

namespace  Halide
 This file defines the class FunctionDAG, which is our representation of a Halide pipeline, and contains methods to using Halide's bounds tools to query properties of it.
 
namespace  Halide::Runtime
 
namespace  Halide::Runtime::Internal
 

Macros

#define EXTENDED_DEBUG   0
 
#define log_message(stuff)
 
#define print_job(job, indent, prefix)
 
#define dump_job_state()
 

Functions

ALWAYS_INLINE int Halide::Runtime::Internal::clamp_num_threads (int threads)
 
WEAK int Halide::Runtime::Internal::default_desired_num_threads ()
 
WEAK void Halide::Runtime::Internal::worker_thread (void *)
 
WEAK void Halide::Runtime::Internal::worker_thread_already_locked (work *owned_job)
 
WEAK void Halide::Runtime::Internal::enqueue_work_already_locked (int num_jobs, work *jobs, work *task_parent)
 
WEAK int halide_default_do_task (void *user_context, halide_task_t f, int idx, uint8_t *closure)
 
WEAK int halide_default_do_loop_task (void *user_context, halide_loop_task_t f, int min, int extent, uint8_t *closure, void *task_parent)
 
WEAK int halide_default_do_par_for (void *user_context, halide_task_t f, int min, int size, uint8_t *closure)
 The default versions of the parallel runtime functions.
 
WEAK int halide_default_do_parallel_tasks (void *user_context, int num_tasks, struct halide_parallel_task_t *tasks, void *task_parent)
 
WEAK int halide_set_num_threads (int n)
 
WEAK int halide_get_num_threads ()
 Get or set the number of threads used by Halide's thread pool.
 
WEAK void halide_shutdown_thread_pool ()
 
WEAK int halide_default_semaphore_init (halide_semaphore_t *s, int n)
 
WEAK int halide_default_semaphore_release (halide_semaphore_t *s, int n)
 
WEAK bool halide_default_semaphore_try_acquire (halide_semaphore_t *s, int n)
 
WEAK halide_do_task_t halide_set_custom_do_task (halide_do_task_t f)
 
WEAK halide_do_loop_task_t halide_set_custom_do_loop_task (halide_do_loop_task_t f)
 
WEAK halide_do_par_for_t halide_set_custom_do_par_for (halide_do_par_for_t f)
 
WEAK void halide_set_custom_parallel_runtime (halide_do_par_for_t do_par_for, halide_do_task_t do_task, halide_do_loop_task_t do_loop_task, halide_do_parallel_tasks_t do_parallel_tasks, halide_semaphore_init_t semaphore_init, halide_semaphore_try_acquire_t semaphore_try_acquire, halide_semaphore_release_t semaphore_release)
 
WEAK int halide_do_task (void *user_context, halide_task_t f, int idx, uint8_t *closure)
 
WEAK int halide_do_par_for (void *user_context, halide_task_t f, int min, int size, uint8_t *closure)
 
WEAK int halide_do_loop_task (void *user_context, halide_loop_task_t f, int min, int size, uint8_t *closure, void *task_parent)
 
WEAK int halide_do_parallel_tasks (void *user_context, int num_tasks, struct halide_parallel_task_t *tasks, void *task_parent)
 Enqueue some number of the tasks described above and wait for them to complete.
 
WEAK int halide_semaphore_init (struct halide_semaphore_t *sema, int count)
 
WEAK int halide_semaphore_release (struct halide_semaphore_t *sema, int count)
 
WEAK bool halide_semaphore_try_acquire (struct halide_semaphore_t *sema, int count)
 

Variables

WEAK work_queue_t Halide::Runtime::Internal::work_queue = {}
 
WEAK halide_do_task_t Halide::Runtime::Internal::custom_do_task = halide_default_do_task
 
WEAK halide_do_loop_task_t Halide::Runtime::Internal::custom_do_loop_task = halide_default_do_loop_task
 
WEAK halide_do_par_for_t Halide::Runtime::Internal::custom_do_par_for = halide_default_do_par_for
 
WEAK halide_do_parallel_tasks_t Halide::Runtime::Internal::custom_do_parallel_tasks = halide_default_do_parallel_tasks
 
WEAK halide_semaphore_init_t Halide::Runtime::Internal::custom_semaphore_init = halide_default_semaphore_init
 
WEAK halide_semaphore_try_acquire_t Halide::Runtime::Internal::custom_semaphore_try_acquire = halide_default_semaphore_try_acquire
 
WEAK halide_semaphore_release_t Halide::Runtime::Internal::custom_semaphore_release = halide_default_semaphore_release
 

Macro Definition Documentation

◆ EXTENDED_DEBUG

#define EXTENDED_DEBUG   0

Definition at line 1 of file thread_pool_common.h.

◆ log_message

#define log_message ( stuff)

◆ print_job

#define print_job ( job,
indent,
prefix )
Value:
do { /*nothing*/ } while (0)

Definition at line 248 of file thread_pool_common.h.

Referenced by Halide::Runtime::Internal::worker_thread_already_locked().

◆ dump_job_state

#define dump_job_state ( )
Value:
do { /*nothing*/ } while (0)

Definition at line 249 of file thread_pool_common.h.

Referenced by Halide::Runtime::Internal::worker_thread_already_locked().

Function Documentation

◆ halide_default_do_task()

WEAK int halide_default_do_task ( void * user_context,
halide_task_t f,
int idx,
uint8_t * closure )

Definition at line 630 of file thread_pool_common.h.

References user_context.

◆ halide_default_do_loop_task()

WEAK int halide_default_do_loop_task ( void * user_context,
halide_loop_task_t f,
int min,
int extent,
uint8_t * closure,
void * task_parent )

Definition at line 635 of file thread_pool_common.h.

References user_context.

◆ halide_default_do_par_for()

◆ halide_default_do_parallel_tasks()

◆ halide_set_num_threads()

◆ halide_get_num_threads()

WEAK int halide_get_num_threads ( )

Get or set the number of threads used by Halide's thread pool.

Set returns the old number.

n < 0 : error condition n == 0 : use a reasonable system default (typically, number of cpus online). n == 1 : use exactly one thread; this will always enforce serial execution n > 1 : use a pool of exactly n threads.

(Note that this is only guaranteed when using the default implementations of halide_do_par_for(); custom implementations may completely ignore values passed to halide_set_num_threads().)

Definition at line 730 of file thread_pool_common.h.

References Halide::Runtime::Internal::work_queue_t::desired_threads_working, halide_mutex_lock(), halide_mutex_unlock(), Halide::Runtime::Internal::work_queue_t::mutex, and Halide::Runtime::Internal::work_queue.

◆ halide_shutdown_thread_pool()

◆ halide_default_semaphore_init()

WEAK int halide_default_semaphore_init ( halide_semaphore_t * s,
int n )

Definition at line 763 of file thread_pool_common.h.

References halide_semaphore_impl_t::value.

◆ halide_default_semaphore_release()

◆ halide_default_semaphore_try_acquire()

WEAK bool halide_default_semaphore_try_acquire ( halide_semaphore_t * s,
int n )

◆ halide_set_custom_do_task()

WEAK halide_do_task_t halide_set_custom_do_task ( halide_do_task_t f)

Definition at line 799 of file thread_pool_common.h.

References Halide::Runtime::Internal::custom_do_task.

◆ halide_set_custom_do_loop_task()

WEAK halide_do_loop_task_t halide_set_custom_do_loop_task ( halide_do_loop_task_t f)

◆ halide_set_custom_do_par_for()

WEAK halide_do_par_for_t halide_set_custom_do_par_for ( halide_do_par_for_t f)

◆ halide_set_custom_parallel_runtime()

◆ halide_do_task()

WEAK int halide_do_task ( void * user_context,
halide_task_t f,
int idx,
uint8_t * closure )

◆ halide_do_par_for()

WEAK int halide_do_par_for ( void * user_context,
halide_task_t f,
int min,
int size,
uint8_t * closure )

◆ halide_do_loop_task()

WEAK int halide_do_loop_task ( void * user_context,
halide_loop_task_t f,
int min,
int size,
uint8_t * closure,
void * task_parent )

◆ halide_do_parallel_tasks()

WEAK int halide_do_parallel_tasks ( void * user_context,
int num_tasks,
struct halide_parallel_task_t * tasks,
void * task_parent )

Enqueue some number of the tasks described above and wait for them to complete.

While waiting, the calling threads assists with either the tasks enqueued, or other non-blocking tasks in the task system. Note that task_parent should be NULL for top-level calls and the pass through argument if this call is being made from another task.

Definition at line 850 of file thread_pool_common.h.

References Halide::Runtime::Internal::custom_do_parallel_tasks, and user_context.

◆ halide_semaphore_init()

WEAK int halide_semaphore_init ( struct halide_semaphore_t * sema,
int count )

◆ halide_semaphore_release()

WEAK int halide_semaphore_release ( struct halide_semaphore_t * sema,
int count )

◆ halide_semaphore_try_acquire()

WEAK bool halide_semaphore_try_acquire ( struct halide_semaphore_t * sema,
int count )