# Control which HTP device executes a model

Note

This page applies to Auto platforms (SA-series SoCs). For standard
Android/Windows/Linux targets, see the main [Tutorials](https://docs.qualcomm.com/doc/80-63442-10/topic/general_tutorials.html) page.

## With qnn-net-run on HTP Backend

It is possible to control which HTP device (i.e., CDSP/NSP ID) will execute a model.
Execution of models on CDSP1/NSP1 is extended by libQnnHtpNetRunExtensions.so.

The HTP net extension library (libQnnHtpNetRunExtensions.so) and device\_id (CDSP/NSP ID) info can be passed to qnn-net-run through the `--config_file` option via commandline parameter as below:

$ ./qnn-net-run --backend libQnnHtp.so \
            --input_list target_raw_list.txt \
            --retrieve_context Inception_v3_quantized.serialized.bin \
            --profiling_level basic \
            --log_level error \
            --config_file qnn_v2_config.json
    Copy to clipboard

An example HTP backend config JSON file is given below:

**qnn\_v2\_config.json**

// For loading the NetRunExtensions / Config JSON
    {
        "backend_extensions": {
            "shared_library_path" :  "libQnnHtpNetRunExtensions.so",
            "config_file_path" :  "qnn_v2_8mb_vtcm_nsp0.json"
        },
        "context_configs" : {
            "context_priority" :  "normal"
        }
    }
    Copy to clipboard

It refers to a config\_file\_path paramter which another json config used to speficy the device\_id.

To select CDSP 0, follow the config JSON file below:

**qnn\_v2\_8mb\_vtcm\_nsp0.json**

{
      "graphs": {
          "vtcm_mb":8,
          "graph_names":["<network-name>"]
      },
      "devices":[
          {
              "dsp_arch":"v68",
              "pd_session":"unsigned",
              "device_id":0
          }
      ]
    }
    Copy to clipboard

Similarly, we can set device\_id=1 to select CDSP1:

**qnn\_v2\_8mb\_vtcm\_nsp1.json**

{
      "graphs": {
          "vtcm_mb":8,
          "graph_names":["<network-name>"]
      },
      "devices":[
          {
              "dsp_arch":"v68",
              "pd_session":"unsigned",
              "device_id":1
          }
      ]
    }
    Copy to clipboard

Please refer to the following table to select the appropriate DSP architecture (“dsp\_arch”) value.

QNN HTP TARGET CONFIG TABLE

| Target Name | Target dsp\_arch | Target soc\_id |
| --- | --- | --- |
| SA8295 | v68 | 39 |
| SA8540 | v68 | 62 |
| SA8650 | v73 | 52 |
| SA8775 | v73 | 52 |
| SA8255 | v73 | 52 |
| SA8620 | v75 | 67 |
| SA7255 | v75 | 67 |
| SA8797 | v81 | 72 |

Note

If no config file is used with qnn-net-run, the model execution is run on device\_id=0 or CDSP0/NSP0 by default.

## With QNN API on HTP Backend

A QNN API example is shown below:

HTP Device Creation example with CDSP/NSP selection

1// QnnInterface_t is defined in ${QNN_SDK_ROOT}/include/QNN/QnnInterface.h
     2QnnInterface_t qnnInterface;
     3// Init qnn interface ......
     4// See ${QNN_SDK_ROOT}/examples/QNN/SampleApp code
     5// Also, check Sample App Tutorial at ${QNN_SDK_ROOT}/docs/QNN/general/sample_app.html
     6
     7uint32_t deviceId = 0; // This is where QNN application can select which CDSP/NSP ID or deviceId to
     8                      // use for device creation for a model inference
     9QnnDevice_PlatformInfo_t e;
    10const QnnDevice_PlatformInfo_t *platformInfo{nullptr};
    11auto qnnStatus = m_qnnFunctionPointers.qnnInterface.deviceGetPlatformInfo(nullptr, &platformInfo);
    12if (QNN_SUCCESS != qnnStatus) {
    13    // handle errors
    14}
    15
    16//Note a: You need to call <qnnInterface>.deviceFreePlatformInfo() to free up any resources that <qnnInterface>.deviceGetPlatformInfo() might have allocated.
    17//Note b: <qnnInterface>.deviceGetPlatformInfo() is unsupported on x86 Linux.
    18
    19
    20if (platformInfo) {
    21    e.version                   = QNN_DEVICE_PLATFORM_INFO_VERSION_1;
    22    e.v1.numHwDevices           = 1;
    23
    24    QnnDevice_HardwareDeviceInfo_t *hwDeviceInfo = platformInfo->v1.hwDevices;
    25    if (!hwDeviceInfo) {
    26        // handle errors
    27    }
    28
    29    QnnDevice_HardwareDeviceInfo_t *hwDeviceInfoTemp{nullptr};
    30    for (uint32_t temp = 0; temp < platformInfo->v1.numHwDevices; ++temp) {
    31        if (hwDeviceInfo->v1.deviceId == deviceId) {
    32            hwDeviceInfoTemp = hwDeviceInfo;
    33            break;
    34        }
    35        if ((temp + 1) < platformInfo->v1.numHwDevices) {
    36            hwDeviceInfo++;
    37        }
    38    }
    39    if (!hwDeviceInfoTemp) {
    40        // handle errors
    41    }
    42    e.v1.hwDevices = hwDeviceInfoTemp;
    43}
    44
    45QnnDevice_Config_t devConfig;
    46devConfig.option = QNN_DEVICE_CONFIG_OPTION_PLATFORM_INFO;
    47devConfig.hardwareInfo = &e;
    48
    49const QnnDevice_Config_t* devConfigArray[] = {&devConfig, nullptr};
    50
    51auto qnnStatus = m_qnnFunctionPointers.qnnInterface.deviceCreate(m_logHandle, devConfigArray, &m_deviceHandle);
    52if (QNN_SUCCESS != qnnStatus) {
    53  // handle errors
    54}
    Copy to clipboard

Note

If no devConfig is provided with deviceCreate, the model execution is run on device\_id=0 or CDSP0/NSP0 by default.

Last Published: Jun 04, 2026

[Previous Topic
Tutorial: HTP with Custom Ops on SA-series — LV GVM (Rich OS)](https://docs.qualcomm.com/bundle/publicresource/80-63442-10/topics/htp_auto_tutorial_3_lv_gvm.md) [Next Topic
Tutorial: Turning on various optimization on HTP and HTP MCP Backends](https://docs.qualcomm.com/bundle/publicresource/80-63442-10/topics/htp_auto_optimization.md)