diff --git a/.github/workflows/runcpptest.yaml b/.github/workflows/runcpptest.yaml new file mode 100644 index 00000000..2bf5572b --- /dev/null +++ b/.github/workflows/runcpptest.yaml @@ -0,0 +1,108 @@ +name: Compile and Run +on: + workflow_dispatch: + pull_request: + branches: [main] + push: + branches: [main] + +permissions: + actions: read + security-events: write + +jobs: + CI_cpp_test_run: + strategy: + fail-fast: false + matrix: + # GCC currently has too many problems with the C++ API + compiler: [AC6, CLANG] + core: [M0, M4, M55] + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: 'pip' + cache-dependency-path: Testing/requirements.txt + + - name: Install system packages + run: | + sudo add-apt-repository ppa:deadsnakes/ppa + sudo apt-get install libpython3.9 libtinfo5 + + - name: Cache packs + uses: actions/cache@v4 + with: + key: packs-cmsis-dsp + restore-keys: | + packs- + path: /home/runner/.cache/arm/packs + + - name: Activate vcpkg + uses: ARM-software/cmsis-actions/vcpkg@v1 + with: + cache: "-cmsis_dsp_vcpkg" + + - name: Activate Arm tool license + uses: ARM-software/cmsis-actions/armlm@v1 + + - name: Cache boost + id: cache-boost + uses: actions/cache@v4 + with: + key: boost-cmsis-dsp + restore-keys: | + boost-cmsis-dsp + path: ${{ github.workspace }}/boost_1_84_0 + + - name: Install boost + if: steps.cache-boost.outputs.cache-hit != 'true' + run: | + echo "Install boost" + curl -o boost.tar.gz https://archives.boost.io/release/1.84.0/source/boost_1_84_0.tar.gz + tar -xf boost.tar.gz + + - name: Prepare framework + run: | + cd dsppp + echo "Create missing folders" + mkdir AC6_results + mkdir CLANG_results + mkdir GCC_results + + echo "Install missing python packages" + pip install -r ../Testing/requirements.txt + + echo "Load missing pack" + csolution list packs -s test.csolution.yml -m > required_packs.txt + + cat required_packs.txt + cpackget add -a -f required_packs.txt + + + - name: Execute + run: | + cd dsppp + echo "Running tests" + + python run_all.py -t -g ${{ matrix.compiler }} -c ${{ matrix.core }} -avh $AVH_FVP_PLUGINS/../bin + + - name: Upload test report + uses: actions/upload-artifact@v4 + with: + name: test-cpp-report_${{ matrix.compiler }}_${{ matrix.core }} + path: dsppp/${{ matrix.compiler }}_results/errors_${{ matrix.core }}.txt + + + - name: Check error + run: | + cd dsppp + + echo "Checking output..." + test "$(cat ${{ matrix.compiler }}_results/errors_${{ matrix.core }}.txt | wc -l)" -eq 0 diff --git a/.github/workflows/runtest.yaml b/.github/workflows/runtest.yaml index 2ffa1df2..6887be85 100644 --- a/.github/workflows/runtest.yaml +++ b/.github/workflows/runtest.yaml @@ -11,7 +11,7 @@ permissions: security-events: write jobs: - CI_test_run: + CI_c_test_run: strategy: fail-fast: false matrix: @@ -25,17 +25,27 @@ jobs: - name: Setup Python 3.10 uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.10' + cache: 'pip' + cache-dependency-path: Testing/requirements.txt - name: Install system packages run: | sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get install libpython3.9 libtinfo5 + - name: Cache packs + uses: actions/cache@v4 + with: + key: packs-cmsis-dsp + restore-keys: | + packs- + path: /home/runner/.cache/arm/packs + - name: Activate vcpkg uses: ARM-software/cmsis-actions/vcpkg@v1 with: - cache: "-${{ matrix.compiler }}" + cache: "-cmsis_dsp_vcpkg" - name: Activate Arm tool license uses: ARM-software/cmsis-actions/armlm@v1 diff --git a/.gitignore b/.gitignore index 8b14c092..1e2db8a2 100644 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,7 @@ PythonWrapper/build_linux/Makefile PythonWrapper/build_linux/bin_dsp/ PythonWrapper/build_linux/build.sh PythonWrapper/build_linux/cmake_install.cmake - +boost_1_84_0/ # Output of the linkchecker tool diff --git a/dsppp/.gitignore b/dsppp/.gitignore index 0cd7f9a8..fb43d9d3 100644 --- a/dsppp/.gitignore +++ b/dsppp/.gitignore @@ -11,3 +11,6 @@ run_*.bat ac6_results/ gcc_results/ clang_results/ +AC6_results/ +GCC_results/ +CLANG_results/ diff --git a/dsppp/RTE/_Release_VHT-Corstone-300/RTE_Components.h b/dsppp/RTE/_Release_VHT-Corstone-300/RTE_Components.h index c326941f..f63182ac 100644 --- a/dsppp/RTE/_Release_VHT-Corstone-300/RTE_Components.h +++ b/dsppp/RTE/_Release_VHT-Corstone-300/RTE_Components.h @@ -1,6 +1,6 @@ /* * CSOLUTION generated file: DO NOT EDIT! - * Generated by: csolution version 2.2.1 + * Generated by: csolution version 2.4.0 * * Project: 'test.Release+VHT-Corstone-300' * Target: 'Release+VHT-Corstone-300' diff --git a/dsppp/RTE/_Release_VHT-M0P/RTE_Components.h b/dsppp/RTE/_Release_VHT-M0P/RTE_Components.h index 8a0db96b..dcc02aa5 100644 --- a/dsppp/RTE/_Release_VHT-M0P/RTE_Components.h +++ b/dsppp/RTE/_Release_VHT-M0P/RTE_Components.h @@ -1,6 +1,6 @@ /* * CSOLUTION generated file: DO NOT EDIT! - * Generated by: csolution version 2.2.1 + * Generated by: csolution version 2.4.0 * * Project: 'test.Release+VHT-M0P' * Target: 'Release+VHT-M0P' diff --git a/dsppp/RTE/_Release_VHT-M4/RTE_Components.h b/dsppp/RTE/_Release_VHT-M4/RTE_Components.h index 4c34863c..bd61c6bb 100644 --- a/dsppp/RTE/_Release_VHT-M4/RTE_Components.h +++ b/dsppp/RTE/_Release_VHT-M4/RTE_Components.h @@ -1,6 +1,6 @@ /* * CSOLUTION generated file: DO NOT EDIT! - * Generated by: csolution version 2.2.1 + * Generated by: csolution version 2.4.0 * * Project: 'test.Release+VHT-M4' * Target: 'Release+VHT-M4' diff --git a/dsppp/allocator.cpp b/dsppp/allocator.cpp index aaf61cc5..0027ab7c 100644 --- a/dsppp/allocator.cpp +++ b/dsppp/allocator.cpp @@ -1,5 +1,7 @@ #include "allocator.h" +#if !defined(TESTMODE) + #define ALLOC_POOL(BYTES,NB) \ MemoryPool vecPool_##BYTES(NB); @@ -11,11 +13,13 @@ std::map current_stats; std::map max_stats; std::map current_dyn_stats; +#endif + void print_map(std::string comment) { std::cout << comment << "\r\n"; -#if !defined(POOL_ALLOCATOR) +#if !defined(POOL_ALLOCATOR) && !defined(TESTMODE) std::size_t total_static=0; std::size_t total_dynamic=0; @@ -64,6 +68,8 @@ void print_map(std::string comment) #endif } +#if !defined(TESTMODE) + void reset_current_stats() { #if !defined(POOL_ALLOCATOR) @@ -96,3 +102,4 @@ void check_current_stats() #endif } +#endif diff --git a/dsppp/allocator.h b/dsppp/allocator.h index 61e95006..71772478 100644 --- a/dsppp/allocator.h +++ b/dsppp/allocator.h @@ -8,11 +8,14 @@ // Allocator for temporaries +// But when in test mode (like in github action), malloc allocator is used instead +#if !defined(TESTMODE) #if defined(POOL_ALLOCATOR) #define TMP_ALLOC pool_allocator #else #define TMP_ALLOC stat_allocator #endif +#endif #include @@ -57,6 +60,7 @@ struct pool_allocator { }; +#if !defined(TESTMODE) #if defined(POOL_ALLOCATOR) #include "allocation/all.h" #endif @@ -119,6 +123,10 @@ struct stat_allocator { }; -extern void print_map(std::string comment); extern void check_current_stats(); extern void reset_current_stats(); + +#endif + +extern void print_map(std::string comment); + diff --git a/dsppp/cdefault.yml b/dsppp/cdefault.yml index 0ede69af..876ee2c2 100644 --- a/dsppp/cdefault.yml +++ b/dsppp/cdefault.yml @@ -10,7 +10,6 @@ default: - -DNDEBUG - -Wall - -Wextra - - -Werror - -std=c11 - -Ofast - -ffast-math @@ -28,8 +27,6 @@ default: - -Wno-parentheses-equality - -Wno-reserved-identifier - -ffunction-sections - - -Wno-nan-infinity-disabled - - -DARM_MATH_LOOPUNROLL CPP: - -fno-rtti - -fno-exceptions @@ -58,8 +55,7 @@ default: - -Wdouble-promotion - -DNDEBUG - -Wall - - -Wextra - - -Werror + - -Wextra - -std=c11 - -Ofast - -ffast-math @@ -69,11 +65,11 @@ default: - -Wno-sign-conversion - -Wno-unused-macros - -ffunction-sections - - -DARM_MATH_LOOPUNROLL - -flax-vector-conversions - -Wno-maybe-uninitialized - -fdata-sections - -fno-unroll-loops + - -mfp16-format=ieee CPP: - -fno-rtti - -fno-exceptions @@ -88,6 +84,7 @@ default: - -fdata-sections - -Wno-psabi - -fno-unroll-loops + - -mfp16-format=ieee ASM: - -masm=auto Link: @@ -106,7 +103,6 @@ default: - -DNDEBUG - -Wall - -Wextra - - -Werror - -std=c11 - -Ofast - -ffast-math @@ -123,7 +119,6 @@ default: - -Wno-parentheses-equality - -Wno-reserved-identifier - -ffunction-sections - - -DARM_MATH_LOOPUNROLL CPP: - -fno-rtti - -fno-exceptions diff --git a/dsppp/run_all.py b/dsppp/run_all.py index 50299044..49cae16d 100644 --- a/dsppp/run_all.py +++ b/dsppp/run_all.py @@ -4,22 +4,22 @@ import itertools import subprocess import sys -import mps3run +from os import environ from colorama import init,Fore, Back, Style try: - os.mkdir("ac6_results") + os.mkdir("AC6_results") except: pass try: - os.mkdir("gcc_results") + os.mkdir("GCC_results") except: pass try: - os.mkdir("clang_results") + os.mkdir("CLANG_results") except: pass @@ -91,9 +91,19 @@ def run(args,mustPrint=False,dumpStdErr=True,timeout=20,printCmd=False): parser.add_argument('-d', action='store_true', help="Dry run") parser.add_argument('-g', nargs='?',type = str, default="AC6",help="AC6 / CLANG / GCC") parser.add_argument('-u', nargs='?',type = str, default="L85986697A",help="Debug UUID") +parser.add_argument('-t', action='store_true', help="Enable test mode") +parser.add_argument('-avh', nargs='?',type = str, default="C:/Keil_v5/ARM/avh-fvp/bin/models", help="AVH folder") args = parser.parse_args() +GHACTION = False + +if "AVH_FVP_PLUGINS" in os.environ: + GHACTION = True + +if not GHACTION: + import mps3run + init() if args.a: @@ -111,13 +121,13 @@ def run(args,mustPrint=False,dumpStdErr=True,timeout=20,printCmd=False): def results(): if args.g == "AC6": - return("ac6_results") + return("AC6_results") if args.g == "GCC": - return("gcc_results") + return("GCC_results") if args.g == "CLANG": - return("clang_results") + return("CLANG_results") print(f"Compiler {args.g} not known") exit(1) @@ -144,9 +154,15 @@ def cmd_args(): else: ext = ".elf" -fvp = {"M55":"C:\\Keil_v5\\ARM\\VHT\\VHT_Corstone_SSE-300_Ethos-U55.exe", - "M4":"C:\\Keil_v5\\ARM\\VHT\\VHT_MPS2_Cortex-M4.exe", - "M0":"C:\\Keil_v5\\ARM\\VHT\\VHT_MPS2_Cortex-M0plus.exe"} +fvpWin = {"M55":"FVP_Corstone_SSE-300_Ethos-U55.exe", + "M4":"FVP_MPS2_Cortex-M4.exe", + "M0":"FVP_MPS2_Cortex-M0plus.exe"} + +fvpUnix = {"M55":"FVP_Corstone_SSE-300_Ethos-U55", + "M4":"FVP_MPS2_Cortex-M4", + "M0":"FVP_MPS2_Cortex-M0plus"} + +AVHROOT = args.avh TESTS=["DOT_TEST", "VECTOR_TEST", @@ -184,8 +200,8 @@ def is_only_test(n,i): ] # Restricted tests for debugging -#TESTS=["DOT_TEST","VECTOR_TEST"] -#DATATYPES=["F32_DT"] +#TESTS=["FUSION_TEST"] +#DATATYPES=["Q15_DT"] #MODE = ["STATIC_TEST"] all_tests = list(itertools.product(TESTS,DATATYPES,MODE)) @@ -193,6 +209,10 @@ def is_only_test(n,i): ALLOC = "#define POOL_ALLOCATOR" +TESTMODE = "" +if args.t: + TESTMODE = "#define TESTMODE" + if args.a: # Stat allocator enabled and we do stats on VHT CS300 only ALLOC = "//#define POOL_ALLOCATOR" @@ -206,6 +226,7 @@ def is_only_test(n,i): HEADER = f"""#ifndef TEST_CONFIG_H #define TEST_CONFIG_H +{TESTMODE} {ALLOC} {BENCH} @@ -295,7 +316,19 @@ def runVHT(test_name,test,err,subtest): exe = "cpu0=" + out_path() else: exe = out_path() - res=run([fvp[core],"-f",config,"-a",exe]) + + if AVHROOT: + avhAttempt = os.path.join(AVHROOT,fvpWin[core]) + if os.path.exists(avhAttempt): + avh = avhAttempt + + avhAttempt = os.path.join(AVHROOT,fvpUnix[core]) + if os.path.exists(avhAttempt): + avh = avhAttempt + else: + avh = avhUnixExe[core] + + res=run([avh,"-f",config,"-a",exe],printCmd=True) if not is_error(res,test_name,err): process_result(test_name,test,res.msg,subtest) @@ -340,7 +373,7 @@ def runATest(test,file_err,nb,NB_MAX,current_nb_axf,nb_axf,first=True,subtest=No nb_axf = nb_axf + 1 print(f"Number of axf to test = {nb_axf}") -with open(os.path.join(results(),"errors.txt"),"w") as err: +with open(os.path.join(results(),f"errors_{args.c}.txt"),"w") as err: # Generate include for allocations if args.a or args.i: with open(os.path.join("allocation","all.h"),"w") as fh: @@ -382,10 +415,11 @@ def runATest(test,file_err,nb,NB_MAX,current_nb_axf,nb_axf,first=True,subtest=No nb = nb + 1 -if ERROR_OCCURED: - printError("Error in tests:") - for n in all_errors: - printError(n) - sys.exit("Error occurred") -else: - sys.exit(0) +if not GHACTION: + if ERROR_OCCURED: + printError("Error in tests:") + for n in all_errors: + printError(n) + sys.exit("Error occurred") + else: + sys.exit(0) diff --git a/dsppp/test.cbuild-pack.yml b/dsppp/test.cbuild-pack.yml index 0f3c7dcf..4ffc655f 100644 --- a/dsppp/test.cbuild-pack.yml +++ b/dsppp/test.cbuild-pack.yml @@ -1,17 +1,17 @@ cbuild-pack: resolved-packs: - resolved-pack: ARM::CMSIS@6.0.0 - selected-by: + selected-by-pack: - ARM::CMSIS@6.0.0 - resolved-pack: ARM::CMSIS-Compiler@2.0.0 - selected-by: + selected-by-pack: - ARM::CMSIS-Compiler@2.0.0 - resolved-pack: ARM::CMSIS-DSP@1.15.0 - selected-by: + selected-by-pack: - ARM::CMSIS-DSP@1.15.0 - resolved-pack: ARM::Cortex_DFP@1.0.0 - selected-by: + selected-by-pack: - ARM::Cortex_DFP@1.0.0 - resolved-pack: ARM::V2M_MPS3_SSE_300_BSP@1.4.0 - selected-by: + selected-by-pack: - ARM::V2M_MPS3_SSE_300_BSP@1.4.0 diff --git a/dsppp/test.cproject.yml b/dsppp/test.cproject.yml index 2538d62c..a6f3828e 100644 --- a/dsppp/test.cproject.yml +++ b/dsppp/test.cproject.yml @@ -25,13 +25,15 @@ project: - file: allocator.cpp add-path: - Include - - ../../../boost_1_84_0 + - ../boost_1_84_0 - . - tests + layers: + - layer: ../Testing/cmsis_build/dsp.clayer.yml + components: - component: ARM::CMSIS:CORE - - component: ARM::CMSIS:DSP@1.15.0 - component: ARM::Device:Startup&C Startup for-context: - +VHT-Corstone-300 diff --git a/dsppp/test.csolution.yml b/dsppp/test.csolution.yml index 028759a7..91e7e46b 100644 --- a/dsppp/test.csolution.yml +++ b/dsppp/test.csolution.yml @@ -1,5 +1,5 @@ solution: - compiler: AC6@6.22.0 + compiler: AC6 language-C: c11 language-CPP: c++17 @@ -7,7 +7,6 @@ solution: packs: - pack: ARM::CMSIS@6.0.0 - - pack: ARM::CMSIS-DSP@1.15.0 - pack: ARM::V2M_MPS3_SSE_300_BSP@1.4.0 - pack: ARM::CMSIS-Compiler@2.0.0 - pack: ARM::Cortex_DFP@1.0.0 diff --git a/dsppp/test_config.h b/dsppp/test_config.h index 9349fbb8..d57c65b1 100644 --- a/dsppp/test_config.h +++ b/dsppp/test_config.h @@ -1,12 +1,13 @@ #ifndef TEST_CONFIG_H #define TEST_CONFIG_H + #define POOL_ALLOCATOR //#define ONLY_BENCHMARKS -#define VECTOR_TEST +#define DOT_TEST #define F32_DT -#define STATIC_TEST +#define DYNAMIC_TEST #endif diff --git a/dsppp/tests/bench.h b/dsppp/tests/bench.h index b045ddee..db038336 100644 --- a/dsppp/tests/bench.h +++ b/dsppp/tests/bench.h @@ -23,10 +23,14 @@ extern uint32_t start_time; extern uint32_t stop_time; extern uint32_t cycle_count; -#if defined(HOST) +#if defined(HOST) || defined(TESTMODE) #define INIT_SYSTICK -#define START_CYCLE_MEASUREMENT -#define STOP_CYCLE_MEASUREMENT +#define START_CYCLE_MEASUREMENT \ + start_time = 0; +#define STOP_CYCLE_MEASUREMENT \ + stop_time = 0; \ + cycle_count = start_time - stop_time; \ + printf ("Cycle count = %d\r\n",(int)cycle_count); #else #define INIT_SYSTICK \ SysTick->CTRL=0; \ diff --git a/dsppp/tests/common_tests.h b/dsppp/tests/common_tests.h index 2db59ade..7c6c9d19 100644 --- a/dsppp/tests/common_tests.h +++ b/dsppp/tests/common_tests.h @@ -25,7 +25,14 @@ using namespace arm_cmsis_dsp; * */ +#if defined(TESTMODE) + template + using PVector = Vector; + + template + using PMat = Matrix; +#else #if defined(POOL_ALLOCATOR) template @@ -43,6 +50,7 @@ using namespace arm_cmsis_dsp; using PMat = Matrix; #endif +#endif template using PView = VectorView; diff --git a/dsppp/tests/fusion_test.cpp b/dsppp/tests/fusion_test.cpp index 0711cd1b..7bafe707 100644 --- a/dsppp/tests/fusion_test.cpp +++ b/dsppp/tests/fusion_test.cpp @@ -5,6 +5,7 @@ extern "C" { #include "allocator.h" #include +#include #include #include @@ -211,6 +212,9 @@ void all_fusion_test() test2(); test2(); + + + title("Unroll Fusion"); test3(); @@ -219,10 +223,21 @@ void all_fusion_test() test3(); test3(); test3(); + } void fusion_test() { + /* + +gcc has some issues with this code. +FVP is freezing when trying to run it. +Since those kind of fusion are not really used in the library +(because performance is not good) we can disable those tests +to at least be able to test other parts of the library with gcc. + + */ + #if !defined(GCC_COMPILER) #if defined(FUSION_TEST) #if defined(F64_DT) all_fusion_test(); @@ -243,5 +258,6 @@ void fusion_test() all_fusion_test(); #endif #endif + #endif } \ No newline at end of file