cuflow/sched.h: SMP Parallelization
[SMP Work Scheduling]

Data Structures

struct  cuflow_exeq_entry
struct  cuflow_exeq

Defines

#define CUFLOW_EXEQ_SIZE   8
#define CUFLOW_EXEQ_MASK   (CUFLOW_EXEQ_SIZE - 1)
#define CUFLOW_PROFILE_SCHED   0
#define CUFLOW_CALLS_BETWEEN_SCHED   1
#define cuflow_exeqpri_succ(pri)   ((cuflow_exeqpri_t)((pri) + 1))

Typedefs

typedef struct cuflow_exeqcuflow_exeq_t
typedef struct cuflow_exeq_entrycuflow_exeq_entry_t

Enumerations

enum  cuflow_exeqpri_t { cuflow_exeqpri_begin = 0, cuflow_exeqpri_normal = 0, cuflow_exeqpri_background = 1, cuflow_exeqpri_end }

Functions

cuflow_exeqpri_t cuflow_sched_priority (void)
cuflow_exeqpri_t cuflow_sched_change_priority (cuflow_exeqpri_t priority)
cuflow_exeq_t cuflow_sched_exeq (void)
void cuflow_sched_call_on (cu_clop0(f, void), AO_t *cdisj, cuflow_exeq_t exeq)
void cuflow_sched_call_at (cu_clop0(f, void), AO_t *cdisj, cuflow_exeqpri_t pri)
void cuflow_sched_call (cu_clop0(f, void), AO_t *cdisj)
void cuflow_sched_call_sub1_on (cu_clop0(f, void), AO_t *cdisj, cuflow_exeq_t exeq)
void cuflow_sched_call_sub1_at (cu_clop0(f, void), AO_t *cdisj, cuflow_exeqpri_t pri)
void cuflow_sched_call_sub1 (cu_clop0(f, void), AO_t *cdisj)
cu_bool_t cuflow_exeqpri_prioreq (cuflow_exeqpri_t pri0, cuflow_exeqpri_t pri1)
cu_bool_t cuflow_exeqpri_prior (cuflow_exeqpri_t pri0, cuflow_exeqpri_t pri1)

Detailed Description

This provides an efficient mechanism for sharing work across multiple CPUs or cores on an SMP system. Before use, start some worker threads with cuflow_workers_spawn_at_least or cuflow_workers_spawn. To parallelize a task, initialise a local cuflow_cdisj_t guard to zero and request the subtasks with cuflow_sched_call passing a reference to guard. Then use cuflow_cdisj_wait_while to wait for the subtasks to finish.


Enumeration Type Documentation

A type to hold the priority of scheduled work.


Function Documentation

cu_bool_t cuflow_exeqpri_prior ( cuflow_exeqpri_t  pri0,
cuflow_exeqpri_t  pri1 
)

True iff pri0 is a higher priority than pri1.

cu_bool_t cuflow_exeqpri_prioreq ( cuflow_exeqpri_t  pri0,
cuflow_exeqpri_t  pri1 
)

True iff pri0 is at least as high a priority as pri1.

void cuflow_sched_call ( cu_clop0(f, void)  ,
AO_t *  cdisj 
)

Same as cuflow_sched_call_on with the current thread-local execution queue passed as the last argument.

void cuflow_sched_call_at ( cu_clop0(f, void)  ,
AO_t *  cdisj,
cuflow_exeqpri_t  pri 
)

Same as cuflow_sched_call with the current priority temporarily set to pri.

void cuflow_sched_call_on ( cu_clop0(f, void)  ,
AO_t *  cdisj,
cuflow_exeq_t  exeq 
)

If exeq queue is full, calls f and exits, else increments cdisj and schedules f for later execution, possibly by another thread. In the latter case, *cdisj is decremented after f has been called.

This function does not alter the priority of the current thread. It's main purpose is as an optimisation of successive calls to cuflow_sched_call by letting the client fetch the thread-local exeq with cuflow_sched_exeq once and pass it.

void cuflow_sched_call_sub1 ( cu_clop0(f, void)  ,
AO_t *  cdisj 
)

Same as cuflow_sched_call_sub1_on with the current thread-local execution queue passed as the last argument.

void cuflow_sched_call_sub1_at ( cu_clop0(f, void)  ,
AO_t *  cdisj,
cuflow_exeqpri_t  pri 
)

Same as cuflow_sched_call_sub1 with the current priority temporarily set to pri.

void cuflow_sched_call_sub1_on ( cu_clop0(f, void)  ,
AO_t *  cdisj,
cuflow_exeq_t  exeq 
)

Same as cuflow_sched_call, except that after f has been called, cdisj will be decremented by one. Use this variant if you initialise cdisj in advance to the number of pending calls.

cuflow_exeqpri_t cuflow_sched_change_priority ( cuflow_exeqpri_t  priority  ) 

Set the priority at which to run work scheduled by the current thread, and return the old priority.

cuflow_exeq_t cuflow_sched_exeq ( void   ) 

The current current execution queue on which work will be scheduled.

cuflow_exeqpri_t cuflow_sched_priority ( void   ) 

The priority at which to run work scheduled by the current thread.

Generated 2009-11-23 for culibs-0.25 using Doxygen. Maintained by Petter Urkedal.