Rate This Document
Findability
Accuracy
Completeness
Readability

Performing Core Binding

This section describes how to bind the main process, AscendCL threads, and NPU interrupts to cores.

NPU interrupts are categorized into two types:

  • dev*_sq_send_wq: processes interrupt tasks of the sending queue.
  • dev*_sq_fair_wq: processes interrupts for tasks that require fair scheduling.

The asterisk (*) indicates the NPU ID. For example, dev2_sq_send_wq and dev2_sq_fair_wq indicate the two interrupt queues of NPU 2.

cpumask is a mask value in hexadecimal format. Each bit value in the binary representation indicates a CPU core (from low to high: CPU core 0, CPU core 1, and so on). For example:

  • 3 (0011 in binary): indicates that the interrupt is bound to CPU cores 0 and 1.
  • f (1111 in binary): indicates that the interrupt is bound to CPU cores 0 to 3.

Core binding commands:

  • Run the following commands to bind an interrupt to cores on the physical machine (for example, bind an interrupt of NPU 2 to CPU cores 80 and 81).
    echo "00000000,00000000,00000000,00000000,00000000,00000000,00000000,00010000,00000000,00000000" > /sys/devices/virtual/workqueue/dev2_sq_send_wq/cpumask
    echo "00000000,00000000,00000000,00000000,00000000,00000000,00000000,00020000,00000000,00000000" > /sys/devices/virtual/workqueue/dev2_sq_fair_wq/cpumask
  • Run the following commands to bind the main process to cores on the physical machine (for example, bind the main process to CPU cores 82 and 83). If the inference service is executed in a container, run the following commands in the container:
    for THREAD_ID in ${ THREADS[@]}
    do
        taskset -acp 82-83 ${THREAD_ID}
    done
  • Run the following commands to bind AscendCL threads to cores on the physical machine (for example, bind AscendCL threads to CPU cores 84 and 85). If the inference service is executed in a container, run the following commands in the container:
    for THREAD_ID in ${ THREADS[@]}
    do
        ACL=`ps -Te | grep ${THREAD_ID} | grep acl_thread | grep -v grep | awk '!a[$1]++' | awk '{print $2}'`
        taskset -acp 84-85 ${ACL}
    done