Skip to main content
Version: v2506

tuning_component.cpu_affinity

is_hyper_threading

def is_hyper_threading() -> bool

Checks if the system supports hyper-threading.

Returns:

True if hyper-threading is enabled, False otherwise.

get_current_cpu_affinity

def get_current_cpu_affinity() -> List[int]

Gets the current CPU affinity of the current process.

Returns:

A list of CPU core IDs that the process is currently bound to.

get_cpu_affinity_tied_with_device

def get_cpu_affinity_tied_with_device(device_id: int) -> List[int]

Gets the CPU affinity tied to a specific GPU device.

Arguments:

  • device_id - The ID of the GPU device.

Returns:

A list of CPU core IDs that are tied to the specified GPU device.

get_cpu_affinity_tied_with_devices

def get_cpu_affinity_tied_with_devices() -> List[List[int]]

Gets the CPU affinity tied to all available GPU devices.

Returns:

A list of lists, where each inner list contains the CPU core IDs tied to a specific GPU device.

set_cpu_affinity

def set_cpu_affinity(idx_from: int = 0,
idx_to: Optional[int] = None,
verbose: bool = False) -> None

Sets the CPU affinity for the current process.

Arguments:

  • idx_from - The starting index of the CPU cores to bind to.
  • idx_to - The ending index of the CPU cores to bind to.
  • verbose - Whether to print verbose logging information.