Blender  V3.3
Classes
BLI_task.h File Reference
#include <string.h>
#include "BLI_threads.h"
#include "BLI_utildefines.h"

Go to the source code of this file.

Classes

struct  TaskParallelTLS
 
struct  TaskParallelSettings
 
struct  TaskParallelIteratorStateShared
 

Functions

Task Scheduler

Central scheduler that holds running threads ready to execute tasks. A single queue holds the task from all pools.

Initialize/exit must be called before/after any task pools are created/freed, and must be called from the main threads. All other scheduler and pool functions are thread-safe.

void BLI_task_scheduler_init (void)
 
void BLI_task_scheduler_exit (void)
 
int BLI_task_scheduler_num_threads (void)
 
Task Isolation

Task isolation helps avoid unexpected task scheduling decisions that can lead to bugs if wrong assumptions were made. Typically that happens when doing "nested threading", i.e. one thread schedules a bunch of main-tasks and those spawn new sub-tasks.

What can happen is that when a main-task waits for its sub-tasks to complete on other threads, another main-task is scheduled within the already running main-task. Generally, this is good, because it leads to better performance. However, sometimes code (often unintentionally) makes the assumption that at most one main-task runs on a thread at a time.

The bugs often show themselves in two ways:

  • Deadlock, when a main-task holds a mutex while waiting for its sub-tasks to complete.
  • Data corruption, when a main-task makes wrong assumptions about a thread-local variable.

Task isolation can avoid these bugs by making sure that a main-task does not start executing another main-task while waiting for its sub-tasks. More precisely, a function that runs in an isolated region is only allowed to run sub-tasks that were spawned in the same isolated region.

Unfortunately, incorrect use of task isolation can lead to deadlocks itself. This can happen when threading primitives are used that separate spawning tasks from executing them. The problem occurs when a task is spawned in one isolated region while the tasks are waited for in another isolated region. In this setup, the thread that is waiting for the spawned tasks to complete cannot run the tasks itself. On a single thread, that causes a deadlock already. When there are multiple threads, another thread will typically run the task and avoid the deadlock. However, if this situation happens on all threads at the same time, all threads will deadlock. This happened in T88598.

void BLI_task_isolate (void(*func)(void *userdata), void *userdata)
 

Task Pool

Pool of tasks that will be executed by the central task scheduler. For each pool, we can wait for all tasks to be done, or cancel them before they are done.

Running tasks may spawn new tasks.

Pools may be nested, i.e. a thread running a task can create another task pool with smaller tasks. When other threads are busy they will continue working on their own tasks, if not they will join in, no new threads will be launched.

enum  eTaskPriority { TASK_PRIORITY_LOW , TASK_PRIORITY_HIGH }
 
typedef enum eTaskPriority eTaskPriority
 
typedef struct TaskPool TaskPool
 
typedef void(* TaskRunFunction) (TaskPool *__restrict pool, void *taskdata)
 
typedef void(* TaskFreeFunction) (TaskPool *__restrict pool, void *taskdata)
 
TaskPoolBLI_task_pool_create (void *userdata, eTaskPriority priority)
 
TaskPoolBLI_task_pool_create_background (void *userdata, eTaskPriority priority)
 
TaskPoolBLI_task_pool_create_background_serial (void *userdata, eTaskPriority priority)
 
TaskPoolBLI_task_pool_create_suspended (void *userdata, eTaskPriority priority)
 
TaskPoolBLI_task_pool_create_no_threads (void *userdata)
 
void BLI_task_pool_free (TaskPool *pool)
 
void BLI_task_pool_push (TaskPool *pool, TaskRunFunction run, void *taskdata, bool free_taskdata, TaskFreeFunction freedata)
 
void BLI_task_pool_work_and_wait (TaskPool *pool)
 
void BLI_task_pool_cancel (TaskPool *pool)
 
bool BLI_task_pool_current_canceled (TaskPool *pool)
 
voidBLI_task_pool_user_data (TaskPool *pool)
 
ThreadMutexBLI_task_pool_user_mutex (TaskPool *pool)
 

Parallel for Routines

typedef struct TaskParallelTLS TaskParallelTLS
 
typedef void(* TaskParallelRangeFunc) (void *__restrict userdata, int iter, const TaskParallelTLS *__restrict tls)
 
typedef void(* TaskParallelInitFunc) (const void *__restrict userdata, void *__restrict chunk)
 
typedef void(* TaskParallelReduceFunc) (const void *__restrict userdata, void *__restrict chunk_join, void *__restrict chunk)
 
typedef void(* TaskParallelFreeFunc) (const void *__restrict userdata, void *__restrict chunk)
 
typedef struct TaskParallelSettings TaskParallelSettings
 
typedef struct TaskParallelIteratorStateShared TaskParallelIteratorStateShared
 
typedef void(* TaskParallelIteratorIterFunc) (void *__restrict userdata, const TaskParallelTLS *__restrict tls, void **r_next_item, int *r_next_index, bool *r_do_abort)
 
typedef void(* TaskParallelIteratorFunc) (void *__restrict userdata, void *item, int index, const TaskParallelTLS *__restrict tls)
 
typedef struct MempoolIterData MempoolIterData
 
typedef void(* TaskParallelMempoolFunc) (void *userdata, MempoolIterData *iter, const TaskParallelTLS *__restrict tls)
 
BLI_INLINE void BLI_parallel_range_settings_defaults (TaskParallelSettings *settings)
 
void BLI_task_parallel_range (int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
 
void BLI_task_parallel_iterator (void *userdata, TaskParallelIteratorIterFunc iter_func, void *init_item, int init_index, int items_num, TaskParallelIteratorFunc func, const TaskParallelSettings *settings)
 
void BLI_task_parallel_listbase (struct ListBase *listbase, void *userdata, TaskParallelIteratorFunc func, const TaskParallelSettings *settings)
 
void BLI_task_parallel_mempool (struct BLI_mempool *mempool, void *userdata, TaskParallelMempoolFunc func, const TaskParallelSettings *settings)
 
BLI_INLINE void BLI_parallel_mempool_settings_defaults (TaskParallelSettings *settings)
 
int BLI_task_parallel_thread_id (const TaskParallelTLS *tls)
 

Task Graph Scheduling

Task Graphs can be used to create a forest of directional trees and schedule work to any tree. The nodes in the graph can be run in separate threads.

+---- [root] ----+
| |
v v
[node_1] +---- [node_2] ----+
| |
v v
[node_3] [node_4]
TaskNode *root = BLI_task_graph_node_create(task_graph, root_exec, NULL, NULL);
void BLI_task_graph_edge_create(struct TaskNode *from_node, struct TaskNode *to_node)
Definition: task_graph.cc:139
struct TaskGraph * BLI_task_graph_create(void)
Definition: task_graph.cc:98
struct TaskNode * BLI_task_graph_node_create(struct TaskGraph *task_graph, TaskGraphNodeRunFunction run, void *user_data, TaskGraphNodeFreeFunction free_func)
Definition: task_graph.cc:117
static void node_exec(GeoNodeExecParams params)

Any node can be triggered to start a chain of tasks. Normally you would trigger a root node but it is supported to start the chain of tasks anywhere in the forest or tree. When a node completes, the execution flow is forwarded via the created edges. When a child node has multiple parents the child node will be triggered once for each parent.

BLI_task_graph_node_push_work(root);

In this example After root is finished, node_1 and node_2 will be started. Only after node_2 is finished node_3 and node_4 will be started.

After scheduling work we need to wait until all the tasks have been finished.

BLI_task_graph_work_and_wait();

When finished you can clean up all the resources by freeing the task_graph. Nodes are owned by the graph and are freed task_data will only be freed if a free_func was given.

BLI_task_graph_free(task_graph);

Work can enter a tree on any node. Normally this would be the root_node. A task_graph can be reused, but the caller needs to make sure the task_data is reset.

Task-Data

Typically you want give a task data to work on. Task data can be shared with other nodes, but be careful not to free the data multiple times. Task data is freed when calling BLI_task_graph_free.

MyData *task_data = MEM_callocN(sizeof(MyData), __func__);
TaskNode *root = BLI_task_graph_node_create(task_graph, root_exec, task_data, MEM_freeN);
TaskNode *node_1 = BLI_task_graph_node_create(task_graph, node_exec, task_data, NULL);
TaskNode *node_2 = BLI_task_graph_node_create(task_graph, node_exec, task_data, NULL);
TaskNode *node_3 = BLI_task_graph_node_create(task_graph, node_exec, task_data, NULL);
TaskNode *node_4 = BLI_task_graph_node_create(task_graph, node_exec, task_data, NULL);
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
typedef void(* TaskGraphNodeRunFunction) (void *__restrict task_data)
 
typedef void(* TaskGraphNodeFreeFunction) (void *task_data)
 
struct TaskGraphBLI_task_graph_create (void)
 
void BLI_task_graph_work_and_wait (struct TaskGraph *task_graph)
 
void BLI_task_graph_free (struct TaskGraph *task_graph)
 
struct TaskNodeBLI_task_graph_node_create (struct TaskGraph *task_graph, TaskGraphNodeRunFunction run, void *user_data, TaskGraphNodeFreeFunction free_func)
 
bool BLI_task_graph_node_push_work (struct TaskNode *task_node)
 
void BLI_task_graph_edge_create (struct TaskNode *from_node, struct TaskNode *to_node)
 

Typedef Documentation

◆ eTaskPriority

◆ MempoolIterData

Definition at line 267 of file BLI_task.h.

◆ TaskFreeFunction

typedef void(* TaskFreeFunction) (TaskPool *__restrict pool, void *taskdata)

Definition at line 62 of file BLI_task.h.

◆ TaskGraphNodeFreeFunction

typedef void(* TaskGraphNodeFreeFunction) (void *task_data)

Definition at line 388 of file BLI_task.h.

◆ TaskGraphNodeRunFunction

typedef void(* TaskGraphNodeRunFunction) (void *__restrict task_data)

Definition at line 387 of file BLI_task.h.

◆ TaskParallelFreeFunc

typedef void(* TaskParallelFreeFunc) (const void *__restrict userdata, void *__restrict chunk)

Definition at line 155 of file BLI_task.h.

◆ TaskParallelInitFunc

typedef void(* TaskParallelInitFunc) (const void *__restrict userdata, void *__restrict chunk)

Definition at line 149 of file BLI_task.h.

◆ TaskParallelIteratorFunc

typedef void(* TaskParallelIteratorFunc) (void *__restrict userdata, void *item, int index, const TaskParallelTLS *__restrict tls)

Definition at line 229 of file BLI_task.h.

◆ TaskParallelIteratorIterFunc

typedef void(* TaskParallelIteratorIterFunc) (void *__restrict userdata, const TaskParallelTLS *__restrict tls, void **r_next_item, int *r_next_index, bool *r_do_abort)

Definition at line 223 of file BLI_task.h.

◆ TaskParallelIteratorStateShared

This data is shared between all tasks, its access needs thread lock or similar protection.

◆ TaskParallelMempoolFunc

typedef void(* TaskParallelMempoolFunc) (void *userdata, MempoolIterData *iter, const TaskParallelTLS *__restrict tls)

Definition at line 274 of file BLI_task.h.

◆ TaskParallelRangeFunc

typedef void(* TaskParallelRangeFunc) (void *__restrict userdata, int iter, const TaskParallelTLS *__restrict tls)

Definition at line 145 of file BLI_task.h.

◆ TaskParallelReduceFunc

typedef void(* TaskParallelReduceFunc) (const void *__restrict userdata, void *__restrict chunk_join, void *__restrict chunk)

Definition at line 151 of file BLI_task.h.

◆ TaskParallelSettings

◆ TaskParallelTLS

Per-thread specific data passed to the callback.

◆ TaskPool

typedef struct TaskPool TaskPool

Definition at line 36 of file BLI_task.h.

◆ TaskRunFunction

typedef void(* TaskRunFunction) (TaskPool *__restrict pool, void *taskdata)

Definition at line 61 of file BLI_task.h.

Enumeration Type Documentation

◆ eTaskPriority

Enumerator
TASK_PRIORITY_LOW 
TASK_PRIORITY_HIGH 

Definition at line 55 of file BLI_task.h.

Function Documentation

◆ BLI_parallel_mempool_settings_defaults()

BLI_INLINE void BLI_parallel_mempool_settings_defaults ( TaskParallelSettings settings)

◆ BLI_parallel_range_settings_defaults()

BLI_INLINE void BLI_parallel_range_settings_defaults ( TaskParallelSettings settings)

TODO(sergey): Think of a better place for this.

Definition at line 293 of file BLI_task.h.

References TaskParallelSettings::min_iter_per_thread, and TaskParallelSettings::use_threading.

Referenced by applyBevelWeight(), applyCrease(), applyPushPull(), applyResize(), applyRotationValue(), applyShear(), applyShrinkFatten(), applySkinResize(), applyToSphere(), applyTrackballValue(), applyTranslationValue(), armature_deform_coords_impl(), Bend(), BKE_autotrack_context_step(), BKE_maskrasterize_buffer(), BKE_mesh_calc_normals_poly(), BKE_mesh_calc_normals_poly_and_vertex(), BKE_scopes_update(), BKE_subdiv_ccg_average_grids(), BKE_subdiv_ccg_average_stitch_faces(), BKE_subdiv_foreach_subdiv_geometry(), BKE_tracking_stabilize_frame(), BLI_bvhtree_overlap_ex(), BLI_covariance_m_vn_ex(), BM_loop_interp_multires_ex(), bm_mesh_calc_tessellation_with_partial__multi_threaded(), BM_mesh_normals_update_with_partial_ex(), bm_mesh_select_mode_flush_edge_to_face(), bm_mesh_select_mode_flush_vert_to_edge(), brush_add(), ccgDM_copyFinalLoopArray(), ccgSubSurf__calcSubdivLevel(), ccgSubSurf__calcVertNormals(), cloth_bvh_objcollisions_nearcheck(), cloth_bvh_selfcollisions_nearcheck(), displaceModifier_do(), dynamicPaint_applySurfaceDisplace(), dynamicPaint_brushMeshCalculateVelocity(), dynamicPaint_createUVSurface(), dynamicPaint_doBorderStep(), dynamicPaint_doEffectStep(), dynamicPaint_doStep(), dynamicPaint_doWaveStep(), dynamicPaint_generateBakeData(), dynamicPaint_Modifier_apply(), dynamicPaint_outputSurfaceImage(), dynamicPaint_paintMesh(), dynamicPaint_paintParticles(), dynamicPaint_paintSinglePoint(), dynamicPaint_prepareAdjacencyData(), dynamicPaint_prepareEffectStep(), dynamicPaint_setInitialColor(), dynamics_step(), blender::draw::extract_task_range_run(), foreach_grid_coordinate(), foreach_mouse_hit_key(), foreach_toplevel_grid_coord(), get_vert2geom_distance(), IMB_processor_apply_threaded_scanlines(), lattice_deform_coords_impl(), lineart_build_edge_neighbor(), lineart_geometry_object_load(), lineart_main_transform_and_add_shadow(), load_tex(), load_tex_cursor(), make_histogram_view_from_ibuf_byte(), make_histogram_view_from_ibuf_float(), mesh_recalc_looptri__multi_threaded(), mesh_render_data_mat_tri_len_build_threaded(), meshdeformModifier_do(), modifyMesh(), multiresModifier_disp_run(), non_recursive_bvh_div_nodes(), paint_2d_op(), PE_apply_lengths(), pe_deflect_emitter(), pe_iterate_lengths(), precompute_weight_values(), psys_cache_edit_paths(), RE_point_density_sample(), recount_totsel(), sculpt_color_filter_modal(), set_face_varying_data_from_uv(), shrinkwrap_calc_nearest_surface_point(), shrinkwrap_calc_nearest_vertex(), shrinkwrap_calc_normal_projection(), SimpleDeformModifier_do(), subdiv_ccg_average_boundaries(), subdiv_ccg_average_corners(), subdiv_ccg_evaluate_grids(), subdiv_ccg_recalc_inner_grid_normals(), subdiv_ccg_recalc_modified_inner_grid_normals(), surfacedeformBind(), surfacedeformModifier_do(), surfaceGenerateGrid(), task_listbase_test_do(), and TEST().

◆ BLI_task_graph_create()

struct TaskGraph* BLI_task_graph_create ( void  )

Definition at line 98 of file task_graph.cc.

Referenced by DRW_draw_depth_object(), drw_task_graph_init(), and TEST().

◆ BLI_task_graph_edge_create()

void BLI_task_graph_edge_create ( struct TaskNode from_node,
struct TaskNode to_node 
)

◆ BLI_task_graph_free()

void BLI_task_graph_free ( struct TaskGraph task_graph)

Definition at line 103 of file task_graph.cc.

Referenced by DRW_draw_depth_object(), drw_task_graph_deinit(), and TEST().

◆ BLI_task_graph_node_create()

struct TaskNode* BLI_task_graph_node_create ( struct TaskGraph task_graph,
TaskGraphNodeRunFunction  run,
void user_data,
TaskGraphNodeFreeFunction  free_func 
)

◆ BLI_task_graph_node_push_work()

bool BLI_task_graph_node_push_work ( struct TaskNode task_node)

◆ BLI_task_graph_work_and_wait()

void BLI_task_graph_work_and_wait ( struct TaskGraph task_graph)

◆ BLI_task_isolate()

void BLI_task_isolate ( void(*)(void *userdata)  func,
void userdata 
)

◆ BLI_task_parallel_iterator()

void BLI_task_parallel_iterator ( void userdata,
TaskParallelIteratorIterFunc  iter_func,
void init_item,
int  init_index,
int  items_num,
TaskParallelIteratorFunc  func,
const TaskParallelSettings settings 
)

This function allows to parallelize for loops using a generic iterator.

Parameters
userdataCommon userdata passed to all instances of func.
iter_funcCallback function used to generate chunks of items.
init_itemThe initial item, if necessary (may be NULL if unused).
init_indexThe initial index.
items_numThe total amount of items to iterate over (if unknown, set it to a negative number).
funcCallback function.
settingsSee public API doc of TaskParallelSettings for description of all settings.
Note
Static scheduling is only available when items_num is >= 0.

Definition at line 263 of file task_iterator.c.

References state, and task_parallel_iterator_do().

◆ BLI_task_parallel_listbase()

void BLI_task_parallel_listbase ( struct ListBase listbase,
void userdata,
TaskParallelIteratorFunc  func,
const TaskParallelSettings settings 
)

This function allows to parallelize for loops over ListBase items.

Parameters
listbaseThe double linked list to loop over.
userdataCommon userdata passed to all instances of func.
funcCallback function.
settingsSee public API doc of ParallelRangeSettings for description of all settings.
Note
There is no static scheduling here, since it would need another full loop over items to count them.

Definition at line 306 of file task_iterator.c.

References BLI_listbase_count(), BLI_listbase_is_empty(), ListBase::first, state, task_parallel_iterator_do(), and task_parallel_listbase_get().

Referenced by task_listbase_test_do(), and TEST().

◆ BLI_task_parallel_mempool()

void BLI_task_parallel_mempool ( struct BLI_mempool mempool,
void userdata,
TaskParallelMempoolFunc  func,
const TaskParallelSettings settings 
)

◆ BLI_task_parallel_range()

void BLI_task_parallel_range ( int  start,
int  stop,
void userdata,
TaskParallelRangeFunc  func,
const TaskParallelSettings settings 
)

Definition at line 94 of file task_range.cc.

References BLI_task_scheduler_num_threads(), TaskParallelSettings::func_free, TaskParallelSettings::func_reduce, MAX2, TaskParallelSettings::min_iter_per_thread, blender::threading::parallel_for(), blender::threading::parallel_reduce(), blender::compositor::task, TaskParallelSettings::use_threading, TaskParallelTLS::userdata_chunk, TaskParallelSettings::userdata_chunk, and TaskParallelSettings::userdata_chunk_size.

Referenced by applyBevelWeight(), applyCrease(), applyPushPull(), applyResize(), applyRotationValue(), applyShear(), applyShrinkFatten(), applySkinResize(), applyToSphere(), applyTrackballValue(), applyTranslationValue(), armature_deform_coords_impl(), Bend(), BKE_autotrack_context_step(), BKE_maskrasterize_buffer(), BKE_mesh_calc_normals_poly(), BKE_mesh_calc_normals_poly_and_vertex(), BKE_scopes_update(), BKE_subdiv_ccg_average_grids(), BKE_subdiv_ccg_average_stitch_faces(), BKE_subdiv_foreach_subdiv_geometry(), BKE_tracking_stabilize_frame(), BLI_bvhtree_overlap_ex(), BLI_covariance_m_vn_ex(), BM_loop_interp_multires_ex(), bm_mesh_calc_tessellation_with_partial__multi_threaded(), BM_mesh_normals_update_with_partial_ex(), brush_add(), calculate_average_weight(), ccgDM_copyFinalLoopArray(), ccgSubSurf__calcSubdivLevel(), ccgSubSurf__calcVertNormals(), cloth_brush_apply_brush_foces(), cloth_bvh_objcollisions_nearcheck(), cloth_bvh_selfcollisions_nearcheck(), displaceModifier_do(), do_brush_action(), do_gravity(), dynamicPaint_applySurfaceDisplace(), dynamicPaint_brushMeshCalculateVelocity(), dynamicPaint_createUVSurface(), dynamicPaint_doBorderStep(), dynamicPaint_doEffectStep(), dynamicPaint_doStep(), dynamicPaint_doWaveStep(), dynamicPaint_generateBakeData(), dynamicPaint_Modifier_apply(), dynamicPaint_outputSurfaceImage(), dynamicPaint_paintMesh(), dynamicPaint_paintParticles(), dynamicPaint_paintSinglePoint(), dynamicPaint_prepareAdjacencyData(), dynamicPaint_prepareEffectStep(), dynamicPaint_setInitialColor(), dynamics_step(), blender::draw::extract_task_range_run_iter(), foreach_grid_coordinate(), foreach_mouse_hit_key(), foreach_toplevel_grid_coord(), get_vert2geom_distance(), IMB_processor_apply_threaded_scanlines(), lattice_deform_coords_impl(), lineart_build_edge_neighbor(), lineart_geometry_object_load(), lineart_main_transform_and_add_shadow(), load_tex(), load_tex_cursor(), make_histogram_view_from_ibuf_byte(), make_histogram_view_from_ibuf_float(), mask_flood_fill_exec(), mesh_recalc_looptri__multi_threaded(), mesh_render_data_mat_tri_len_build_threaded(), meshdeformModifier_do(), modifyMesh(), multiresModifier_disp_run(), non_recursive_bvh_div_nodes(), paint_2d_op(), paint_mesh_restore_co(), pbvh_faces_update_normals(), pbvh_update_BB_redraw(), pbvh_update_draw_buffers(), pbvh_update_mask_redraw(), pbvh_update_visibility(), pbvh_update_visibility_redraw(), PE_apply_lengths(), pe_deflect_emitter(), pe_iterate_lengths(), precompute_weight_values(), psys_cache_edit_paths(), RE_point_density_sample(), SCULPT_bmesh_topology_rake(), SCULPT_calc_area_center(), SCULPT_calc_area_normal_and_center(), SCULPT_cloth_brush_do_simulation_step(), SCULPT_cloth_brush_ensure_nodes_constraints(), sculpt_cloth_filter_modal(), sculpt_color_filter_modal(), sculpt_combine_proxies(), SCULPT_combine_transform_proxies(), sculpt_dirty_mask_exec(), SCULPT_do_boundary_brush(), SCULPT_do_clay_brush(), SCULPT_do_clay_strips_brush(), SCULPT_do_clay_thumb_brush(), SCULPT_do_crease_brush(), SCULPT_do_displacement_eraser_brush(), SCULPT_do_displacement_smear_brush(), SCULPT_do_draw_brush(), SCULPT_do_draw_face_sets_brush(), SCULPT_do_draw_sharp_brush(), SCULPT_do_elastic_deform_brush(), SCULPT_do_fill_brush(), SCULPT_do_flatten_brush(), SCULPT_do_grab_brush(), SCULPT_do_inflate_brush(), SCULPT_do_layer_brush(), SCULPT_do_mask_brush_draw(), SCULPT_do_multiplane_scrape_brush(), SCULPT_do_nudge_brush(), SCULPT_do_paint_brush(), SCULPT_do_paint_brush_image(), SCULPT_do_pinch_brush(), SCULPT_do_pose_brush(), SCULPT_do_rotate_brush(), SCULPT_do_scrape_brush(), SCULPT_do_slide_relax_brush(), SCULPT_do_smear_brush(), SCULPT_do_snake_hook_brush(), SCULPT_do_surface_smooth_brush(), SCULPT_do_thumb_brush(), SCULPT_enhance_details_brush(), sculpt_expand_update_for_vertex(), SCULPT_fake_neighbor_search(), SCULPT_filter_cache_init(), SCULPT_flush_stroke_deform(), sculpt_gesture_face_set_apply_for_symmetry_pass(), sculpt_gesture_mask_apply_for_symmetry_pass(), sculpt_gesture_project_apply_for_symmetry_pass(), sculpt_mask_by_color_contiguous(), sculpt_mask_by_color_full_mesh(), sculpt_mask_expand_invoke(), sculpt_mask_expand_modal(), sculpt_mask_filter_exec(), SCULPT_mask_filter_smooth_apply(), sculpt_mask_init_exec(), sculpt_mesh_filter_modal(), SCULPT_nearest_vertex_get(), SCULPT_pbvh_calc_area_normal(), SCULPT_pose_brush_init(), sculpt_pose_grow_pose_factor(), SCULPT_smooth(), sculpt_transform_all_vertices(), sculpt_transform_radius_elastic(), sculpt_undo_bmesh_restore_generic(), set_face_varying_data_from_uv(), shrinkwrap_calc_nearest_surface_point(), shrinkwrap_calc_nearest_vertex(), shrinkwrap_calc_normal_projection(), SimpleDeformModifier_do(), subdiv_ccg_average_boundaries(), subdiv_ccg_average_corners(), subdiv_ccg_evaluate_grids(), subdiv_ccg_recalc_inner_grid_normals(), subdiv_ccg_recalc_modified_inner_grid_normals(), surfacedeformBind(), surfacedeformModifier_do(), surfaceGenerateGrid(), TEST(), blender::bke::pbvh::pixels::update_pixels(), and wpaint_paint_leaves().

◆ BLI_task_parallel_thread_id()

int BLI_task_parallel_thread_id ( const TaskParallelTLS tls)

Don't use this, store any thread specific data in tls->userdata_chunk instead. Only here for code to be removed.

Referenced by brush_add_count_iter(), calc_multiplane_scrape_surface_task_cb(), do_clay_brush_task_cb_ex(), do_clay_strips_brush_task_cb_ex(), do_clay_thumb_brush_task_cb_ex(), do_cloth_brush_apply_forces_task_cb_ex(), do_color_smooth_task_cb_exec(), do_crease_brush_task_cb_ex(), do_displacement_eraser_brush_task_cb_ex(), do_displacement_smear_brush_task_cb_ex(), do_draw_brush_task_cb_ex(), do_draw_face_sets_brush_task_cb_ex(), do_draw_sharp_brush_task_cb_ex(), do_enhance_details_brush_task_cb_ex(), do_fill_brush_task_cb_ex(), do_flatten_brush_task_cb_ex(), do_grab_brush_task_cb_ex(), do_gravity_task_cb_ex(), do_inflate_brush_task_cb_ex(), do_layer_brush_task_cb_ex(), do_mask_brush_draw_task_cb_ex(), do_multiplane_scrape_brush_task_cb_ex(), do_nudge_brush_task_cb_ex(), do_paint_brush_task_cb_ex(), blender::ed::sculpt_paint::paint::image::do_paint_pixels(), do_pinch_brush_task_cb_ex(), do_relax_face_sets_brush_task_cb_ex(), do_rotate_brush_task_cb_ex(), do_scrape_brush_task_cb_ex(), do_smear_brush_task_cb_exec(), do_smooth_brush_task_cb_ex(), do_snake_hook_brush_task_cb_ex(), do_thumb_brush_task_cb_ex(), do_topology_rake_bmesh_task_cb_ex(), do_topology_relax_task_cb_ex(), do_topology_slide_task_cb_ex(), load_tex_task_cb_ex(), SCULPT_do_surface_smooth_brush_displace_task_cb_ex(), SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex(), and blender::compositor::threading_model_task_execute().

◆ BLI_task_pool_cancel()

void BLI_task_pool_cancel ( TaskPool pool)

◆ BLI_task_pool_create()

TaskPool* BLI_task_pool_create ( void userdata,
eTaskPriority  priority 
)

◆ BLI_task_pool_create_background()

TaskPool* BLI_task_pool_create_background ( void userdata,
eTaskPriority  priority 
)

Background: always run tasks in a background thread, never immediately execute them. For running background jobs.

Create a background task pool. In multi-threaded context, there is no differences with BLI_task_pool_create(), but in single-threaded case it is ensured to have at least one worker thread to run on (i.e. you don't have to call BLI_task_pool_work_and_wait on it to be sure it will be processed).

Note
Background pools are non-recursive (that is, you should not create other background pools in tasks assigned to a background pool, they could end never being executed, since the 'fallback' background thread is already busy with parent task in single-threaded context).

Definition at line 407 of file task_pool.cc.

References TASK_POOL_BACKGROUND, and task_pool_create_ex().

Referenced by filelist_cache_preview_ensure_running().

◆ BLI_task_pool_create_background_serial()

TaskPool* BLI_task_pool_create_background_serial ( void userdata,
eTaskPriority  priority 
)

Background Serial: run tasks one after the other in the background, without parallelization between the tasks.

Task pool that executes one task after the other, possibly on different threads but never in parallel.

Definition at line 435 of file task_pool.cc.

References TASK_POOL_BACKGROUND_SERIAL, and task_pool_create_ex().

Referenced by screen_opengl_render_init().

◆ BLI_task_pool_create_no_threads()

TaskPool* BLI_task_pool_create_no_threads ( void userdata)

No threads: immediately executes tasks on the same thread. For debugging.

Single threaded task pool that executes pushed task immediately, for debugging purposes.

Definition at line 426 of file task_pool.cc.

References task_pool_create_ex(), TASK_POOL_NO_THREADS, and TASK_PRIORITY_HIGH.

◆ BLI_task_pool_create_suspended()

TaskPool* BLI_task_pool_create_suspended ( void userdata,
eTaskPriority  priority 
)

Suspended: don't execute tasks until work_and_wait is called. This is slower as threads can't immediately start working. But it can be used if the data structures the threads operate on are not fully initialized until all tasks are created.

Similar to BLI_task_pool_create() but does not schedule any tasks for execution for until BLI_task_pool_work_and_wait() is called. This helps reducing threading overhead when pushing huge amount of small initial tasks from the main thread.

Definition at line 417 of file task_pool.cc.

References task_pool_create_ex(), and TASK_POOL_TBB_SUSPENDED.

Referenced by project_paint_op(), and TEST().

◆ BLI_task_pool_current_canceled()

bool BLI_task_pool_current_canceled ( TaskPool pool)

For worker threads, test if current task pool canceled. this function may only be called from worker threads and pool must be the task pool that the thread is currently executing a task from.

Definition at line 510 of file task_pool.cc.

References background_task_pool_canceled(), BLI_assert_msg, blender::compositor::pool, TASK_POOL_BACKGROUND, TASK_POOL_BACKGROUND_SERIAL, TASK_POOL_NO_THREADS, TASK_POOL_TBB, TASK_POOL_TBB_SUSPENDED, tbb_task_pool_canceled(), and TaskPool::type.

◆ BLI_task_pool_free()

void BLI_task_pool_free ( TaskPool pool)

◆ BLI_task_pool_push()

void BLI_task_pool_push ( TaskPool pool,
TaskRunFunction  run,
void taskdata,
bool  free_taskdata,
TaskFreeFunction  freedata 
)

◆ BLI_task_pool_user_data()

void* BLI_task_pool_user_data ( TaskPool pool)

◆ BLI_task_pool_user_mutex()

ThreadMutex* BLI_task_pool_user_mutex ( TaskPool pool)

Optional mutex to use from run function.

Definition at line 530 of file task_pool.cc.

References blender::compositor::pool, and TaskPool::user_mutex.

◆ BLI_task_pool_work_and_wait()

void BLI_task_pool_work_and_wait ( TaskPool pool)

◆ BLI_task_scheduler_exit()

void BLI_task_scheduler_exit ( void  )

Definition at line 55 of file task_scheduler.cc.

Referenced by WM_exit_ex().

◆ BLI_task_scheduler_init()

void BLI_task_scheduler_init ( void  )

◆ BLI_task_scheduler_num_threads()

int BLI_task_scheduler_num_threads ( void  )