API Reference Manual
1.46.0
|
Thread types, masks and IDs.
Thread mask operations.
Data Structures | |
struct | odp_thrmask_t |
Thread mask. More... | |
Macros | |
#define | ODP_THREAD_COUNT_MAX 256 |
Maximum number of threads supported in build time. More... | |
#define | ODP_THRMASK_STR_SIZE ODP_CPUMASK_STR_SIZE |
Minimum size of output buffer for odp_thrmask_to_str() More... | |
Typedefs | |
typedef struct odp_thrmask_t | odp_thrmask_t |
Thread mask. More... | |
typedef enum odp_thread_type_e | odp_thread_type_t |
Thread type. | |
Enumerations | |
enum | odp_thread_type_e { ODP_THREAD_WORKER = 0 , ODP_THREAD_CONTROL } |
Thread type. More... | |
Functions | |
int | odp_thread_id (void) |
Get thread identifier. More... | |
int | odp_thread_count (void) |
Thread count. More... | |
int | odp_thread_control_count (void) |
Control thread count. More... | |
int | odp_thread_worker_count (void) |
Worker thread count. More... | |
int | odp_thread_count_max (void) |
Maximum thread count. More... | |
int | odp_thread_control_count_max (void) |
Maximum control thread count. More... | |
int | odp_thread_worker_count_max (void) |
Maximum worker thread count. More... | |
odp_thread_type_t | odp_thread_type (void) |
Thread type. More... | |
void | odp_thrmask_from_str (odp_thrmask_t *mask, const char *str) |
Add thread mask bits from a string. More... | |
int32_t | odp_thrmask_to_str (const odp_thrmask_t *mask, char *str, int32_t size) |
Format a string from thread mask. More... | |
void | odp_thrmask_zero (odp_thrmask_t *mask) |
Clear entire thread mask. More... | |
void | odp_thrmask_set (odp_thrmask_t *mask, int thr) |
Add thread to mask. More... | |
void | odp_thrmask_setall (odp_thrmask_t *mask) |
Set all threads in mask. More... | |
void | odp_thrmask_clr (odp_thrmask_t *mask, int thr) |
Remove thread from mask. More... | |
int | odp_thrmask_isset (const odp_thrmask_t *mask, int thr) |
Test if thread is a member of mask. More... | |
int | odp_thrmask_count (const odp_thrmask_t *mask) |
Count number of threads set in mask. More... | |
void | odp_thrmask_and (odp_thrmask_t *dest, const odp_thrmask_t *src1, const odp_thrmask_t *src2) |
Member-wise AND over two thread masks. More... | |
void | odp_thrmask_or (odp_thrmask_t *dest, const odp_thrmask_t *src1, const odp_thrmask_t *src2) |
Member-wise OR over two thread masks. More... | |
void | odp_thrmask_xor (odp_thrmask_t *dest, const odp_thrmask_t *src1, const odp_thrmask_t *src2) |
Member-wise XOR over two thread masks. More... | |
int | odp_thrmask_equal (const odp_thrmask_t *mask1, const odp_thrmask_t *mask2) |
Test if two thread masks contain the same threads. More... | |
void | odp_thrmask_copy (odp_thrmask_t *dest, const odp_thrmask_t *src) |
Copy a thread mask. More... | |
int | odp_thrmask_first (const odp_thrmask_t *mask) |
Find first set thread in mask. More... | |
int | odp_thrmask_last (const odp_thrmask_t *mask) |
Find last set thread in mask. More... | |
int | odp_thrmask_next (const odp_thrmask_t *mask, int thr) |
Find next set thread in mask. More... | |
int | odp_thrmask_worker (odp_thrmask_t *mask) |
Worker thread mask. More... | |
int | odp_thrmask_control (odp_thrmask_t *mask) |
Control thread mask. More... | |
#define ODP_THREAD_COUNT_MAX 256 |
Maximum number of threads supported in build time.
Use odp_thread_count_max() for maximum number of threads supported in run time, which depends on system configuration and may be lower than this number.
#define ODP_THRMASK_STR_SIZE ODP_CPUMASK_STR_SIZE |
Minimum size of output buffer for odp_thrmask_to_str()
The maximum number of characters needed to record any thread mask as a string (output of odp_thrmask_to_str()).
typedef struct odp_thrmask_t odp_thrmask_t |
Thread mask.
Don't access directly, use access functions.
enum odp_thread_type_e |
Thread type.
Definition at line 32 of file api/spec/thread_types.h.
int odp_thread_id | ( | void | ) |
Get thread identifier.
Returns the ODP thread identifier of current thread. Thread IDs range from 0 to odp_thread_count_max() - 1 and are unique within an ODP instance.
Thread IDs are assigned by odp_init_local() and freed by odp_term_local(). IDs are assigned sequentially starting from 0 in the same order threads call odp_init_local(). Thread IDs freed by odp_term_local() may be reused by following odp_init_local() calls.
int odp_thread_count | ( | void | ) |
Thread count.
Returns the current ODP thread count. This is the number of active threads of any type running in the ODP instance. Each odp_init_local() call increments and each odp_term_local() call decrements the count. The count is always between 1 and odp_thread_count_max().
int odp_thread_control_count | ( | void | ) |
Control thread count.
Otherwise like odp_thread_count(), but returns the number of active threads of type ODP_THREAD_CONTROL. The count is always between 0 and odp_thread_control_count_max().
int odp_thread_worker_count | ( | void | ) |
Worker thread count.
Otherwise like odp_thread_count(), but returns the number of active threads of type ODP_THREAD_WORKER. The count is always between 0 and odp_thread_worker_count_max().
int odp_thread_count_max | ( | void | ) |
Maximum thread count.
Returns the maximum number of threads of any type. This is a constant value and set in ODP initialization phase. The value may be lower than ODP_THREAD_COUNT_MAX.
int odp_thread_control_count_max | ( | void | ) |
Maximum control thread count.
Otherwise like odp_thread_count_max(), but returns the maximum number of control threads (ODP_THREAD_CONTROL). The returned value is always <= odp_thread_count_max().
int odp_thread_worker_count_max | ( | void | ) |
Maximum worker thread count.
Otherwise like odp_thread_count_max(), but returns the maximum number of worker threads (ODP_THREAD_WORKER). The returned value is always <= odp_thread_count_max().
odp_thread_type_t odp_thread_type | ( | void | ) |
Thread type.
Returns the thread type of the current thread.
void odp_thrmask_from_str | ( | odp_thrmask_t * | mask, |
const char * | str | ||
) |
Add thread mask bits from a string.
Each bit set in the string represents a thread ID to be added into the mask. The string is null terminated and consists of hexadecimal digits. It may be prepended with '0x' and may contain leading zeros (e.g. 0x0001, 0x1 or 1). Thread ID zero is located at the least significant bit (0x1).
mask | Thread mask to modify |
str | String of hexadecimal digits |
int32_t odp_thrmask_to_str | ( | const odp_thrmask_t * | mask, |
char * | str, | ||
int32_t | size | ||
) |
Format a string from thread mask.
Output string format is defined in odp_thrmask_from_str() documentation, except that the string is always prepended with '0x' and does not have any leading zeros (e.g. outputs always 0x1 instead of 0x0001 or 1).
mask | Thread mask | |
[out] | str | String pointer for output |
size | Size of output buffer. Buffer size ODP_THRMASK_STR_SIZE or larger will have enough space for any thread mask. |
<0 | on failure (e.g. buffer too small) |
void odp_thrmask_zero | ( | odp_thrmask_t * | mask | ) |
Clear entire thread mask.
mask | Thread mask to clear |
void odp_thrmask_set | ( | odp_thrmask_t * | mask, |
int | thr | ||
) |
Add thread to mask.
mask | Thread mask to update |
thr | Thread ID |
void odp_thrmask_setall | ( | odp_thrmask_t * | mask | ) |
Set all threads in mask.
Set all possible threads in the mask. All threads from 0 to odp_thread_count_max() minus one are set, regardless of which threads are actually active.
mask | Thread mask to set |
void odp_thrmask_clr | ( | odp_thrmask_t * | mask, |
int | thr | ||
) |
Remove thread from mask.
mask | Thread mask to update |
thr | Thread ID |
int odp_thrmask_isset | ( | const odp_thrmask_t * | mask, |
int | thr | ||
) |
Test if thread is a member of mask.
mask | Thread mask to test |
thr | Thread ID |
0 | if not set |
int odp_thrmask_count | ( | const odp_thrmask_t * | mask | ) |
Count number of threads set in mask.
mask | Thread mask |
void odp_thrmask_and | ( | odp_thrmask_t * | dest, |
const odp_thrmask_t * | src1, | ||
const odp_thrmask_t * | src2 | ||
) |
Member-wise AND over two thread masks.
dest | Destination thread mask (may be one of the source masks) |
src1 | Source thread mask 1 |
src2 | Source thread mask 2 |
void odp_thrmask_or | ( | odp_thrmask_t * | dest, |
const odp_thrmask_t * | src1, | ||
const odp_thrmask_t * | src2 | ||
) |
Member-wise OR over two thread masks.
dest | Destination thread mask (may be one of the source masks) |
src1 | Source thread mask 1 |
src2 | Source thread mask 2 |
void odp_thrmask_xor | ( | odp_thrmask_t * | dest, |
const odp_thrmask_t * | src1, | ||
const odp_thrmask_t * | src2 | ||
) |
Member-wise XOR over two thread masks.
dest | Destination thread mask (may be one of the source masks) |
src1 | Source thread mask 1 |
src2 | Source thread mask 2 |
int odp_thrmask_equal | ( | const odp_thrmask_t * | mask1, |
const odp_thrmask_t * | mask2 | ||
) |
Test if two thread masks contain the same threads.
mask1 | Thread mask 1 |
mask2 | Thread mask 2 |
non-zero | if thread masks equal |
0 | if thread masks not equal |
void odp_thrmask_copy | ( | odp_thrmask_t * | dest, |
const odp_thrmask_t * | src | ||
) |
Copy a thread mask.
dest | Destination thread mask |
src | Source thread mask |
int odp_thrmask_first | ( | const odp_thrmask_t * | mask | ) |
Find first set thread in mask.
mask | thread mask |
<0 | if no thread found |
int odp_thrmask_last | ( | const odp_thrmask_t * | mask | ) |
Find last set thread in mask.
mask | Thread mask |
<0 | if no thread found |
int odp_thrmask_next | ( | const odp_thrmask_t * | mask, |
int | thr | ||
) |
Find next set thread in mask.
Finds the next thread in the thread mask, starting at the thread passed. Use with odp_thrmask_first to traverse a thread mask, e.g.
int thr = odp_thrmask_first(&mask); while (0 <= thr) { ... ... thr = odp_thrmask_next(&mask, thr); }
mask | Thread mask |
thr | Thread to start from |
<0 | if no thread found |
int odp_thrmask_worker | ( | odp_thrmask_t * | mask | ) |
Worker thread mask.
Initializes thread mask with current worker threads and returns the count set.
[out] | mask | Thread mask to initialize |
int odp_thrmask_control | ( | odp_thrmask_t * | mask | ) |
Control thread mask.
Initializes thread mask with current control threads and returns the count set.
[out] | mask | Thread mask to initialize |