API Reference Manual
1.46.0
|
CPU mask operations.
Data Structures | |
struct | odp_cpumask_t |
CPU mask. More... | |
Macros | |
#define | ODP_CPUMASK_SIZE (sizeof(cpu_set_t) * 8) |
Maximum cpumask size, this definition limits the number of individual CPUs that can be accessed in this system. | |
#define | ODP_CPUMASK_STR_SIZE ((ODP_CPUMASK_SIZE + 3) / 4 + 3) |
The maximum number of characters needed to record any CPU mask as a string (output of odp_cpumask_to_str()). | |
Typedefs | |
typedef struct odp_cpumask_t | odp_cpumask_t |
CPU mask. More... | |
Functions | |
void | odp_cpumask_from_str (odp_cpumask_t *mask, const char *str) |
Add CPU mask bits from a string. More... | |
int32_t | odp_cpumask_to_str (const odp_cpumask_t *mask, char *str, int32_t size) |
Format a string from CPU mask. More... | |
void | odp_cpumask_zero (odp_cpumask_t *mask) |
Clear entire CPU mask. More... | |
void | odp_cpumask_set (odp_cpumask_t *mask, int cpu) |
Add CPU to mask. More... | |
void | odp_cpumask_setall (odp_cpumask_t *mask) |
Set all CPUs in mask. More... | |
void | odp_cpumask_clr (odp_cpumask_t *mask, int cpu) |
Remove CPU from mask. More... | |
int | odp_cpumask_isset (const odp_cpumask_t *mask, int cpu) |
Test if CPU is a member of mask. More... | |
int | odp_cpumask_count (const odp_cpumask_t *mask) |
Count number of CPUs set in mask. More... | |
void | odp_cpumask_and (odp_cpumask_t *dest, const odp_cpumask_t *src1, const odp_cpumask_t *src2) |
Member-wise AND over two CPU masks. More... | |
void | odp_cpumask_or (odp_cpumask_t *dest, const odp_cpumask_t *src1, const odp_cpumask_t *src2) |
Member-wise OR over two CPU masks. More... | |
void | odp_cpumask_xor (odp_cpumask_t *dest, const odp_cpumask_t *src1, const odp_cpumask_t *src2) |
Member-wise XOR over two CPU masks. More... | |
int | odp_cpumask_equal (const odp_cpumask_t *mask1, const odp_cpumask_t *mask2) |
Test if two CPU masks contain the same CPUs. More... | |
void | odp_cpumask_copy (odp_cpumask_t *dest, const odp_cpumask_t *src) |
Copy a CPU mask. More... | |
int | odp_cpumask_first (const odp_cpumask_t *mask) |
Find first set CPU in mask. More... | |
int | odp_cpumask_last (const odp_cpumask_t *mask) |
Find last set CPU in mask. More... | |
int | odp_cpumask_next (const odp_cpumask_t *mask, int cpu) |
Find next set CPU in mask. More... | |
int | odp_cpumask_default_worker (odp_cpumask_t *mask, int num) |
Default CPU mask for worker threads. More... | |
int | odp_cpumask_default_control (odp_cpumask_t *mask, int num) |
Default CPU mask for control threads. More... | |
int | odp_cpumask_all_available (odp_cpumask_t *mask) |
Report all the available CPUs. More... | |
typedef struct odp_cpumask_t odp_cpumask_t |
CPU mask.
Don't access directly, use access functions.
void odp_cpumask_from_str | ( | odp_cpumask_t * | mask, |
const char * | str | ||
) |
Add CPU mask bits from a string.
Each bit set in the string represents a CPU 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). CPU #0 is located at the least significant bit (0x1).
mask | CPU mask to modify |
str | String of hexadecimal digits |
int32_t odp_cpumask_to_str | ( | const odp_cpumask_t * | mask, |
char * | str, | ||
int32_t | size | ||
) |
Format a string from CPU mask.
Output string format is defined in odp_cpumask_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 | CPU mask | |
[out] | str | String pointer for output |
size | Size of output buffer. Buffer size ODP_CPUMASK_STR_SIZE or larger will have enough space for any CPU mask. |
<0 | on failure (e.g. buffer too small) |
void odp_cpumask_zero | ( | odp_cpumask_t * | mask | ) |
Clear entire CPU mask.
mask | CPU mask to clear |
void odp_cpumask_set | ( | odp_cpumask_t * | mask, |
int | cpu | ||
) |
Add CPU to mask.
mask | CPU mask to update |
cpu | CPU number |
void odp_cpumask_setall | ( | odp_cpumask_t * | mask | ) |
Set all CPUs in mask.
Set all possible CPUs in the mask. All CPUs from 0 to odp_cpumask_count() minus one are set, regardless of which CPUs are actually available to the application.
mask | CPU mask to set |
void odp_cpumask_clr | ( | odp_cpumask_t * | mask, |
int | cpu | ||
) |
int odp_cpumask_isset | ( | const odp_cpumask_t * | mask, |
int | cpu | ||
) |
Test if CPU is a member of mask.
mask | CPU mask to test |
cpu | CPU number |
0 | if not set |
int odp_cpumask_count | ( | const odp_cpumask_t * | mask | ) |
Count number of CPUs set in mask.
mask | CPU mask |
void odp_cpumask_and | ( | odp_cpumask_t * | dest, |
const odp_cpumask_t * | src1, | ||
const odp_cpumask_t * | src2 | ||
) |
Member-wise AND over two CPU masks.
dest | Destination CPU mask (may be one of the source masks) |
src1 | Source CPU mask 1 |
src2 | Source CPU mask 2 |
void odp_cpumask_or | ( | odp_cpumask_t * | dest, |
const odp_cpumask_t * | src1, | ||
const odp_cpumask_t * | src2 | ||
) |
Member-wise OR over two CPU masks.
dest | Destination CPU mask (may be one of the source masks) |
src1 | Source CPU mask 1 |
src2 | Source CPU mask 2 |
void odp_cpumask_xor | ( | odp_cpumask_t * | dest, |
const odp_cpumask_t * | src1, | ||
const odp_cpumask_t * | src2 | ||
) |
Member-wise XOR over two CPU masks.
dest | Destination CPU mask (may be one of the source masks) |
src1 | Source CPU mask 1 |
src2 | Source CPU mask 2 |
int odp_cpumask_equal | ( | const odp_cpumask_t * | mask1, |
const odp_cpumask_t * | mask2 | ||
) |
Test if two CPU masks contain the same CPUs.
mask1 | CPU mask 1 |
mask2 | CPU mask 2 |
non-zero | if CPU masks equal |
0 | if CPU masks not equal |
void odp_cpumask_copy | ( | odp_cpumask_t * | dest, |
const odp_cpumask_t * | src | ||
) |
Copy a CPU mask.
dest | Destination CPU mask |
src | Source CPU mask |
int odp_cpumask_first | ( | const odp_cpumask_t * | mask | ) |
Find first set CPU in mask.
mask | CPU mask |
<0 | if no CPU found |
int odp_cpumask_last | ( | const odp_cpumask_t * | mask | ) |
Find last set CPU in mask.
mask | CPU mask |
<0 | if no CPU found |
int odp_cpumask_next | ( | const odp_cpumask_t * | mask, |
int | cpu | ||
) |
Find next set CPU in mask.
Finds the next CPU in the CPU mask, starting at the CPU passed. Use with odp_cpumask_first to traverse a CPU mask, e.g.
int cpu = odp_cpumask_first(&mask); while (0 <= cpu) { ... ... cpu = odp_cpumask_next(&mask, cpu); }
mask | CPU mask |
cpu | CPU to start from |
<0 | if no CPU found |
int odp_cpumask_default_worker | ( | odp_cpumask_t * | mask, |
int | num | ||
) |
Default CPU mask for worker threads.
Initializes CPU mask with the default set of CPUs available for worker threads. It's system specific if other CPUs may be used for worker threads as well. Parameter 'num' defines the maximum number of CPUs to be returned. Use zero for all available CPUs. The mask pointer may be set to NULL when CPU mask is not required.
Returns the number of CPUs selected and written into the CPU mask (when not NULL).
[out] | mask | CPU mask to initialize |
num | Maximum number of CPUs to return. Use zero for all available CPUs. |
int odp_cpumask_default_control | ( | odp_cpumask_t * | mask, |
int | num | ||
) |
Default CPU mask for control threads.
Initializes CPU mask with the default set of CPUs available for control threads. It's system specific if other CPUs may be used for control threads as well. Parameter 'num' defines the maximum number of CPUs to be returned. Use zero for all available CPUs. The mask pointer may be set to NULL when CPU mask is not required.
Returns the number of CPUs selected and written into the CPU mask (when not NULL).
[out] | mask | CPU mask to initialize |
num | Maximum number of CPUs to return. Use zero for all available CPUs. |
int odp_cpumask_all_available | ( | odp_cpumask_t * | mask | ) |
Report all the available CPUs.
All the available CPUs include both worker CPUs and control CPUs
[out] | mask | CPU mask to hold all available CPUs |