Snapdragon Neural Processing Engine SDK
Reference Guide
DSP Runtime Environment

ADSP_LIBRARY_PATH Environment - for both ADSP and CDSP

The DSP runtime is a dynamically loaded module, needed for using the AIP and DSP runtimes. This module is found in :

  • $SNPE_ROOT/lib/dsp/libsnpe_dsp_v65_domains_v2_skel (for v65 targets)
  • $SNPE_ROOT/lib/dsp/libsnpe_dsp_v66_domains_v2_skel (for v66 targets)

This module runs on the ADSP or the CDSP, depending on the target. Please refer to the Snapdragon Device Support Matrix table in the Overview section to determine SNPE support of DSP on various Snapdragon devices. SNPE automatically detects the appropriate DSP.

The DSP loader requires the environment variable ADSP_LIBRARY_PATH to be set to the directory where the shared libraries are stored. This environment variable is used for both ADSP and CDSP.

For command line executables

A typical setting of ADSP_LIBRARY_PATH looks like:

export ADSP_LIBRARY_PATH="<path_to_dsp_skel>;/system/lib/rfsa/adsp;/system/vendor/lib/rfsa/adsp;/dsp"

Where <path_to_dsp_skel> is the path where $SNPE_ROOT/lib/dsp/libsnpe_dsp_v65_domains_v2_skel.so and/or other skel files (libsnpe_dsp_*_skel.so) have been pushed. Do not include the file name of the skel in the path.

Example:

Assuming the appropriate dsp skel has been pushed to /data/local/tmp/snpeexample/dsp/lib, then the following command for setting ADSP_LIBRARY_PATH would be used.

export ADSP_LIBRARY_PATH="/data/local/tmp/snpeexample/dsp/lib;/system/lib/rfsa/adsp;/system/vendor/lib/rfsa/adsp;/dsp"

Key points to note when setting the ADSP_LIBRARY_PATH:

Unlike LD_LIBRARY_PATH the path must be contained within quotations. Additionally unlike LD_LIBRARY_PATH, the directory separator is a semi-colon, not a colon.

For Android and most embeded linux systems, the 3 paths below MUST be part of ADSP_LIBRARY_PATH. If any of these are missing the DSP runtime may fail.

  • /system/lib/rfsa/adsp
  • /system/vendor/lib/rfsa/adsp
  • /dsp

For embeded linux automotive system, the following DSP paths are required.

  • /usr/lib/rfsa/adsp
  • /dsp

For Android APKs

ADSP_LIBRARY_PATH must be set for Android APKs as well, and it cannot be done using an "export" command. It must be done within code running in the APK.

The SNPE Android Java APIs automatically sets the ADSP_LIBRARY_PATH. The supplied SNPE Java AAR library automatically sets up the DSP environment for your Android application.

Android applications that do not use the SNPE Java AAR must set the ADSP_LIBRARY_PATH explicitly in native code. An example is provided below.

bool SetAdspLibraryPath(std::string nativeLibPath) {
std::stringstream path;
path << nativeLibPath << ";/system/lib/rfsa/adsp;/system/vendor/lib/rfsa/adsp;/dsp";
return setenv("ADSP_LIBRARY_PATH", path.str().c_str(), 1 /*override*/) == 0;
}

Assuming that the DSP loadable module (libsnpe_dsp_v65_domains_v2_skel.so and/or libsnpe_dsp_v66_domains_v2_skel.so) is placed in the same location as libSNPE.so in the Android application, the "nativeLibPath" input passed to the above method should be the string returned by the the following Android API:

application.getApplicationInfo().nativeLibraryDir