MATHLIB User Guide
Ubuntu 22.04 Build Instructions for MATHLIB
Python3 Setup
  • We auto generate test cases via python scripts packaged in the library
  • Please ensure that you have the following python3 packages installed
    • numpy, scipy, and scikit-learn
Environment Setup
  • Run the executables on EVM using CCS (Code composer studio)
  • Setup needed for the compiler for CGT7x
  • Path setup
    • export PATH=${CGT7X_ROOT}/bin:${PATH}
Build
  • MATHLIB utilizes CMake to build, ensure that system has CMake v3.16.0 or higher
  • Build options:
    • 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
    • MATHLIB_DEBUGPRINT=1/0
    • MATHLIB_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)
  • Example CMake commands
    • To build MATHLIB_sqrt for target on J721S2 and run performance test cases:
      • cmake -B build -DTARGET_PLATFORM="" -DBUILD_TEST="1" -DKERNEL_NAME="MATHLIB_sqrt" -DSOC="j721s2" \
        -DDEVICE="C7120" -DMATHLIB_DEBUGPRINT="0" -DALL_TEST_CASES="1" -DCMAKE_EXPORT_COMPILE_COMMANDS="TRUE" \
        -DCMAKE_BUILD_TYPE="Release"
    • To build MATHLIB_div for host emulation on J721S2 and run example code
      • cmake -B build -DTARGET_PLATFORM="PC" -DBUILD_EXAMPLE="1" -DKERNEL_NAME="MATHLIB_div" \
        -DSOC="j721s2" -DDEVICE="C7120" -DMATHLIB_DEBUGPRINT="0" -DCMAKE_EXPORT_COMPILE_COMMANDS="TRUE" \
        -DCMAKE_BUILD_TYPE="Release"
    • To build MATHLIB_exp for host emulation on J721S2 and run test case 2 with debug print statements
      • cmake -B build -DTARGET_PLATFORM="PC" -DBUILD_TEST="1" -DKERNEL_NAME="MATHLIB_exp" -DSOC="j721s2" \
        -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 J721S2 for target
      • cmake -B build -DTARGET_PLATFORM="" -DAUTO_TEST="1" -DSOC="j721s2" -DDEVICE="C7120" \
        -DALL_TEST_CASES="1" -DCMAKE_BUILD_TYPE="Release" -DMATHLIB_DEBUGPRINT="0"
    • Then run:
      • cmake --build build -j<num_cores>
    • To build for J784S4, replace the SOC option in the above examples to "j784s4"
  • MATHLIB can also be built using the Visual Studio Code's build configuration feature
    • Rename vscode/ to .vscode/
    • In the settings.json, change build parameters as needed
    • "Build" and "Run" buttons can be used to build for target/PC and run for PC
  • Note: If changing build configuration options significantly (e.g. changing between target and host emulation builds), delete build folder before rebuilding
Run
  • To run MATHLIB kernels on a PC:
    • bin/Release/test_MATHLIB_<kernel_name>_<device>_x86_64
      OR
      bin/Debug/test_MATHLIB_<kernel_name>_<device>_x86_64
      • Ex:
        bin/Release/test_MATHLIB_tan_C7120_x86_64
  • To run MATHLIB kernels for target
    • To reproduce numbers given in the datasheet, run the .out program on the EVM in No Boot Mode