This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] Build and Run Instructions for mathlib, dsplib and fftlib

Part Number: TDA4VH-Q1
Other Parts Discussed in Thread: MATHLIB, FFTLIB

Tool/software:

Hi Team,

How can I build and execute Mathlib,FFTlib and DSPlib kernels on baremetal?

  • Prerequisites:

    1. Install C7x Code Generation Tools(CGT) : https://www.ti.com/tool/C7000-CGT
    2. Set Up Environment : Update the PATH in .bashrc  
    3. Download and Install the PROCESSOR-SDK-RTOS-J784S4 https://www.ti.com/tool/PROCESSOR-SDK-J784S4 
    4. Python3 Setup :The test cases are auto generated by Python scripts included in the library package. Install the following packages:
      sudo apt update
      sudo apt install python3
      sudo apt install python3-pip
      
      //check the versions
      python3 --version
      pip3 --version
      
      numpy : pip3 install numpy
      scipy : pip3 install scipy
      scikit-learn : pip3 install scikit-learn
    5. The libaries utilizes CMake to build, ensure that system has CMake v3.16.0 or higher
    6. Install CCS(Code Composer Studio) to run the executables : https://www.ti.com/tool/CCSTUDIO#downloads

    Cmake Commands:

    mathlib : 

    • To build MATHLIB_sqrt for target on J784S4 and run performance test cases :
      • cmake -B build -DTARGET_PLATFORM="" -DBUILD_TEST="1" -DKERNEL_NAME="MATHLIB_sqrt" -DSOC="j784s4" -DDEVICE="C7120" -DMATHLIB_DEBUGPRINT="0" -DALL_TEST_CASES="1" -DCMAKE_EXPORT_COMPILE_COMMANDS="TRUE" -DCMAKE_BUILD_TYPE="Release"
    • To build MATHLIB_sqrt for host emulation on J784S4 and run example code
      • cmake -B build -DTARGET_PLATFORM="PC" -DBUILD_EXAMPLE="1" -DKERNEL_NAME="MATHLIB_sqrt" -DSOC="j784s4" -DDEVICE="C7120" -DMATHLIB_DEBUGPRINT="0" -DCMAKE_EXPORT_COMPILE_COMMANDS="TRUE" -DCMAKE_BUILD_TYPE="Release"
    • To build MATHLIB_exp for host emulation on J784S4 and run test case 2 with debug print statements
      • cmake -B build -DTARGET_PLATFORM="PC" -DBUILD_TEST="1" -DKERNEL_NAME="MATHLIB_exp" -DSOC="j784s4" -DDEVICE="C7120" -DMATHLIB_DEBUGPRINT="1" -DTEST_CASE="2" -DCMAKE_EXPORT_COMPILE_COMMANDS="TRUE" -DCMAKE_BUILD_TYPE="Release"
    • To build all tests cases and libraries for release for J784S4 for target
      • cmake -B build -DTARGET_PLATFORM="PC" -DBUILD_TEST="1" -DKERNEL_NAME="MATHLIB_exp" -DSOC="j784s4" -DDEVICE="C7120" -DMATHLIB_DEBUGPRINT="1" -DTEST_CASE="2" -DCMAKE_EXPORT_COMPILE_COMMANDS="TRUE" -DCMAKE_BUILD_TYPE="Release"
    • Then run : cmake --build build -j<num_cores>

    Reference : mathlib: build instructions

    dsplib : 

    • To build DSPLIB_add for target on J784S4 and run performance test cases : 
      • cmake -B build -DTARGET_PLATFORM="" -DBUILD_TEST="1" -DKERNEL_NAME="DSPLIB_add" -DSOC="j784s4" -DDEVICE="C7120" -DDSPLIB_DEBUGPRINT="0" -DALL_TEST_CASES="1" -DCMAKE_EXPORT_COMPILE_COMMANDS="TRUE" -DCMAKE_BUILD_TYPE="Release"
    • To build DSPLIB_dotprod for host emulation on J784S4 and run example code
      • cmake -B build -DTARGET_PLATFORM="PC" -DBUILD_EXAMPLE="1" -DKERNEL_NAME="DSPLIB_dotprod" -DSOC="j784s4" -DDEVICE="C7120" -DDSPLIB_DEBUGPRINT="0" -DCMAKE_EXPORT_COMPILE_COMMANDS="TRUE" -DCMAKE_BUILD_TYPE="Release"
    • To build DSPLIB_max for host emulation on J784S4 and run test case 2 with debug print statements
      • cmake -B build -DTARGET_PLATFORM="PC" -DBUILD_TEST="1" -DKERNEL_NAME="DSPLIB_max" -DSOC="j784s4" -DDEVICE="C7120" -DSPLIB_DEBUGPRINT="1" -DTEST_CASE="2" -DCMAKE_EXPORT_COMPILE_COMMANDS="TRUE" -DCMAKE_BUILD_TYPE="Release"
    • To build all tests cases and libraries for release for J784S4 for target
      • cmake -B build -DTARGET_PLATFORM="" -DAUTO_TEST="1" -DSOC="j784s4" -DDEVICE="C7120" -DALL_TEST_CASES="1" -DCMAKE_BUILD_TYPE="Release" -DDSPLIB_DEBUGPRINT="0" 
    • Then run : cmake --build build -j<num_cores>

    Reference : dsplib: build instructions

    fftlib : 

    • To build fft_c7x/FFTLIB_fft1dBatched_i32fc_c32fc_o32fc for target on J784S4 and run performance test cases:
      • cmake -B build -DTARGET_PLATFORM="" -DBUILD_TEST="1" -DKERNEL_NAME="fft_c7x/FFTLIB_fft1dBatched_i32fc_c32fc_o32fc" -DSOC="j784s4" -DDEVICE="C7120" -DFFTLIB_DEBUGPRINT="0" -DALL_TEST_CASES="1" -DCMAKE_EXPORT_COMPILE_COMMANDS="TRUE" -DCMAKE_BUILD_TYPE="Release"
    • To build fft_c7x/FFTLIB_fft1dBatched_i32fc_c32fc_o32fc for host emulation on J784S4 and run test case 2 with debug print statements
      • cmake -B build -DTARGET_PLATFORM="PC" -DBUILD_TEST="1" -DKERNEL_NAME="fft_c7x/FFTLIB_fft1dBatched_i32fc_c32fc_o32fc" -DSOC="j784s4" -DDEVICE="C7120" -DFFTLIB_DEBUGPRINT="1" -DTEST_CASE="2" -DCMAKE_EXPORT_COMPILE_COMMANDS="TRUE"
        -DCMAKE_BUILD_TYPE="Release" 
    • To build all tests cases and libraries for release for J784S4 for target
      • cmake -B build -DTARGET_PLATFORM="" -DAUTO_TEST="1" -DSOC="j784s4" -DDEVICE="C7120" -DALL_TEST_CASES="1" -DCMAKE_BUILD_TYPE="Release" -DFFTLIB_DEBUGPRINT="0"
    • Then run : cmake --build build -j<num_cores>

    Reference : fftlib: build instructions

    Note : To build for J721S2/J722S/J721E, replace the SOC option in the above examples to "j721s2/j722s/j721e" and make sure the corresponding SDK is downloaded and installed. Where, the supported build options are:

    • SOC=AM62A/j721e/j721s2/j784s4/j722s
    • DEVICE=C7504/C7100/C7120/C7524
    • TARGET_PLATFORM=PC/""
    • KERNEL_NAME
    • BUILD_TEST=1 OR BUILD_EXAMPLE=1 OR AUTO_TEST=1
    • DSPLIB_DEBUGPRINT=1/0
    • DSPLIB_TESTPRINT
    • ALL_TEST_CASES=1 OR TEST_CASE=TestCaseID
    • CMAKE_EXPORT_COMPILE_COMMANDS=TRUE
    • CMAKE_BUILD_TYPE=Release/Debug
    • AUTO_TEST=1/0 (builds all test cases and libraries)

    Run : 

    • To run MATHLIB/DSPLIB/FFTLIB kernels on a PC/HE :
      • Release : bin/Release/test_MATHLIB_<kernel_name>_<device>_x86_64/bin/Release/test_DSPLIB_<kernel_name>_<device>_x86_64/bin/Release/test_FFTLIB_<kernel_name>_<device>_x86_64 
      • Debug :  bin/Debug/test_MATHLIB_<kernel_name>_<device>_x86_64/bin/Debug/test_DSPLIB_<kernel_name>_<device>_x86_64/bin/Debug/test_FFTLIB_<kernel_name>_<device>_x86_64

      • Open the scripting console in CCS - Go to the View menu and then select Scripting Console
      • Load the launch.js script as shown below (modify path to match the path on your machine if necessary).: "loadJSFile ("/ti/j7/workarea/pdk/packages/ti/drv/sciclient/tools/ccsLoadDmsc/j784s4/launch.js")"

      • After script completes execution you should see below in Debug window. You can connect to any core and load the corresponding application binaries.

      • Go to the Run menu and then select Load -> Load Program
      • In the Load Program window, browse to application binary you want to load.

      • Go to the Run menu and then select Resume to start executing demo binary.

    Regards,

    Betsy Varughese