HTL_thread_executor_set_affinity
Binds an executor to the target CPU set.
Interface Definition
int HTL_thread_executor_set_affinity(HTL_thread_executor_t executor, int num_cpuids, int *cpuids);
Description
HTL_thread_executor_set_affinity() is used to update the CPUs bound to the executor.
- If num_cpuids is greater than 0, the new executor is bound to the corresponding CPU IDs.
- If num_cpuids is 0, the CPUs bound to the executor are reset.
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
executor |
HTL_thread_executor_t |
Handle to the executor. |
Input |
num_cpuids |
int |
Number of CPUs. |
Input |
cpuids |
int * |
CPU ID. |
Input |
Return Value
- HTL_THREAD_SUCCESS: success.
- Other values: failure. For details, see the error code descriptions.
Example
1 2 3 4 5 6 7 | int *cpuids = (int *)malloc(sizeof(int) * 16); int i; for (i = 0; i < 16; i++) cpuids[i] = i; HTL_thread_executor_t self_executor; ret = HTL_thread_executor_self(&self_executor); ret = HTL_thread_executor_set_affinity(self_executor, 16, cpuids); |
Parent topic: Executor Functions