From e67e1e21ccbf6d52b6b1e698d4cbaebadd84addf Mon Sep 17 00:00:00 2001 From: Christopher Kormanyos Date: Sat, 3 Feb 2024 04:24:42 +0100 Subject: [PATCH] Update syntax and separate benchmarks CI --- .../workflows/real-time-cpp-benchmarks.yml | 240 ++++++++++++++ .github/workflows/real-time-cpp.yml | 293 ------------------ readme.md | 16 +- ref_app/ref_app.sln | 3 +- ref_app/src/app/benchmark/app_benchmark.h | 8 +- .../app_benchmark_trapezoid_integral.cpp | 71 +++-- ref_app/src/app/benchmark/readme.md | 22 +- ref_app/target/app/make/app_rules.gmk | 8 +- 8 files changed, 305 insertions(+), 356 deletions(-) create mode 100644 .github/workflows/real-time-cpp-benchmarks.yml diff --git a/.github/workflows/real-time-cpp-benchmarks.yml b/.github/workflows/real-time-cpp-benchmarks.yml new file mode 100644 index 000000000..e23966a21 --- /dev/null +++ b/.github/workflows/real-time-cpp-benchmarks.yml @@ -0,0 +1,240 @@ +############################################################################## +# Copyright Christopher Kormanyos 2021 - 2024. +# Distributed under the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt +# or copy at http://www.boost.org/LICENSE_1_0.txt) + +name: real-time-cpp-benchmarks +on: + push: + branches: + - '**' + pull_request: + schedule: + - cron: '51 23 * * *' # run at 11:51 PM UTC +jobs: + benchmark_gcc-clang: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + compiler: [ g++, clang++ ] + standard: [ c++14, c++17, c++20 ] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: clone-submods-bootstrap-headers-boost-develop + run: | + git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root + cd ../boost-root + git submodule update --init tools + git submodule update --init libs/config + git submodule update --init libs/math + git submodule update --init libs/multiprecision + ./bootstrap.sh + ./b2 headers + working-directory: ./ + - name: clone-cppalliance-decimal + run: | + git clone -b develop --depth 1 https://github.com/cppalliance/decimal.git ../cppalliance-decimal-root + working-directory: ./ + - name: benchmark_gcc-clang + run: ./target/build/test_app_benchmarks.sh ${{ matrix.compiler }} ${{ matrix.standard }} + working-directory: ./ref_app/ + benchmark_apple-clang: + runs-on: macos-latest + strategy: + fail-fast: false + matrix: + compiler: [ g++, clang++ ] + standard: [ c++14, c++17, c++20 ] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: clone-submods-bootstrap-headers-boost-develop + run: | + git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root + cd ../boost-root + git submodule update --init tools + git submodule update --init libs/config + git submodule update --init libs/math + git submodule update --init libs/multiprecision + ./bootstrap.sh + ./b2 headers + working-directory: ./ + - name: clone-cppalliance-decimal + run: | + git clone -b develop --depth 1 https://github.com/cppalliance/decimal.git ../cppalliance-decimal-root + working-directory: ./ + - name: benchmark_apple-clang + run: ./target/build/test_app_benchmarks.sh ${{ matrix.compiler }} ${{ matrix.standard }} + working-directory: ./ref_app/ + benchmark_builds-avr: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + standard: [ c++14 ] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: update-tools + run: sudo apt install gcc-avr avr-libc + - name: benchmark_builds-avr + run: ./target/build/test_app_benchmarks_avr.sh ${{ matrix.standard }} + working-directory: ./ref_app/ + benchmark_builds-stm32f446: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + standard: [ c++14, c++17, c++2a ] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: update-tools + run: sudo apt install gcc-arm-none-eabi + - name: clone-submods-bootstrap-headers-boost-develop + run: | + git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root + cd ../boost-root + git submodule update --init tools + git submodule update --init libs/config + git submodule update --init libs/math + git submodule update --init libs/multiprecision + ./bootstrap.sh + ./b2 headers + working-directory: ./ + - name: clone-cppalliance-decimal + run: | + git clone -b develop --depth 1 https://github.com/cppalliance/decimal.git ../cppalliance-decimal-root + working-directory: ./ + - name: benchmark_builds-stm32f446 + run: ./target/build/test_app_benchmarks_stm32f446.sh ${{ matrix.standard }} + working-directory: ./ref_app/ + benchmark_single-stm32f446: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: update-tools + run: sudo apt install gcc-arm-none-eabi + - name: benchmark_single-stm32f446 + run: | + mkdir -p bin + arm-none-eabi-g++ -std=c++14 -Wall -Wextra -pedantic -O2 -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=32 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I./src/mcal/stm32f446 -I./src -DAPP_BENCHMARK_TYPE=APP_BENCHMARK_TYPE_CRC -DAPP_BENCHMARK_STANDALONE_MAIN ./src/app/benchmark/app_benchmark_crc.cpp ./target/micros/stm32f446/make/single/crt.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_crc.map -T ./target/micros/stm32f446/make/stm32f446.ld -o ./bin/app_benchmark_crc.elf + arm-none-eabi-objcopy ./bin/app_benchmark_crc.elf -O ihex ./bin/app_benchmark_crc.hex + ls -la ./bin/app_benchmark_crc.elf ./bin/app_benchmark_crc.hex ./bin/app_benchmark_crc.map + working-directory: ./ref_app/ + benchmark_single-cnl: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + compiler: [ g++, clang++ ] + standard: [ c++20 ] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: benchmark_single-cnl + run: | + git clone -b main --depth 1 https://github.com/johnmcfarlane/cnl.git ../cnl-root + mkdir -p bin + ${{ matrix.compiler }} -std=${{ matrix.standard }} -Wall -Werror -O3 -march=native -fsanitize=address -I./src -I../cnl-root/include -DAPP_BENCHMARK_TYPE=APP_BENCHMARK_TYPE_CNL_SCALED_INTEGER -DAPP_BENCHMARK_STANDALONE_MAIN ./src/app/benchmark/app_benchmark_cnl_scaled_integer.cpp -o ./bin/app_benchmark_cnl_scaled_integer.exe + ls -la ./bin/app_benchmark_cnl_scaled_integer.exe + ./bin/app_benchmark_cnl_scaled_integer.exe + working-directory: ./ref_app/ + benchmark_single-stm32f429-qemu-cnl: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: update-tools + run: | + sudo apt install libncurses5 libpython2.7 + mkdir -p emu_env && cd emu_env + wget --no-check-certificate https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 + tar -xvf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 + wget --no-check-certificate https://github.com/xpack-dev-tools/qemu-arm-xpack/releases/download/v7.1.0-1/xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz + tar -xvzf xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz + working-directory: ./ref_app/ + - name: benchmark_single-stm32f429-qemu-cnl + run: | + git clone -b main --depth 1 https://github.com/johnmcfarlane/cnl.git ../cnl-root + mkdir -p bin + ./emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-g++ -std=c++20 -Wall -Wextra -pedantic -O2 -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=128 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I./src/mcal/stm32f429 -I./src -I../cnl-root/include -DAPP_BENCHMARK_TYPE=APP_BENCHMARK_TYPE_CNL_SCALED_INTEGER -DAPP_BENCHMARK_STANDALONE_MAIN ./src/app/benchmark/app_benchmark_cnl_scaled_integer.cpp ./target/micros/stm32f429/make/single/crt.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_cnl_scaled_integer.map -T ./target/micros/stm32f429/make/stm32f429.ld -o ./bin/app_benchmark_cnl_scaled_integer.elf + ./emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-objcopy ./bin/app_benchmark_cnl_scaled_integer.elf -O ihex ./bin/app_benchmark_cnl_scaled_integer.hex + ls -la ./bin/app_benchmark_cnl_scaled_integer.elf ./bin/app_benchmark_cnl_scaled_integer.hex ./bin/app_benchmark_cnl_scaled_integer.map + working-directory: ./ref_app/ + - name: emulate-target stm32f429 + run: | + ./emu_env/xpack-qemu-arm-7.1.0-1/bin/qemu-system-gnuarmeclipse --verbose --mcu STM32F429ZI --nographic --gdb tcp::9999 -d unimp,guest_errors & + working-directory: ./ref_app/ + - name: run-test-on-target + run: | + ./emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb-py ./bin/app_benchmark_cnl_scaled_integer.elf -x ./target/build/test_app_benchmarks_emulator.py + qemu_result=$? + echo "qemu_result" "$qemu_result" + echo "qemu_result" "$qemu_result" | grep 'qemu_result 0' + working-directory: ./ref_app/ + benchmark_single-stm32f429-qemu: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: update-tools + run: | + sudo apt install libncurses5 libpython2.7 + mkdir -p emu_env && cd emu_env + wget --no-check-certificate https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 + tar -xvf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 + wget --no-check-certificate https://github.com/xpack-dev-tools/qemu-arm-xpack/releases/download/v7.1.0-1/xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz + tar -xvzf xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz + working-directory: ./ref_app/ + - name: build benchmark_single-stm32f429 + run: | + mkdir -p bin + emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-g++ -std=c++20 -Wall -Wextra -pedantic -O0 -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=32 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I./src/mcal/stm32f429 -I./src -DAPP_BENCHMARK_TYPE=APP_BENCHMARK_TYPE_CRC -DAPP_BENCHMARK_STANDALONE_MAIN ./src/app/benchmark/app_benchmark_crc.cpp ./target/micros/stm32f429/make/single/crt.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_crc.map -T ./target/micros/stm32f429/make/stm32f429.ld --specs=nano.specs --specs=nosys.specs -o ./bin/app_benchmark_crc.elf + emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-objcopy ./bin/app_benchmark_crc.elf -O ihex ./bin/app_benchmark_crc.hex + ls -la ./bin/app_benchmark_crc.elf ./bin/app_benchmark_crc.hex ./bin/app_benchmark_crc.map + working-directory: ./ref_app/ + - name: emulate-target stm32f429 + run: | + ./emu_env/xpack-qemu-arm-7.1.0-1/bin/qemu-system-gnuarmeclipse --verbose --mcu STM32F429ZI --nographic --gdb tcp::9999 -d unimp,guest_errors & + working-directory: ./ref_app/ + - name: run-test-on-target + run: | + ./emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb-py ./bin/app_benchmark_crc.elf -x ./target/build/test_app_benchmarks_emulator.py + qemu_result=$? + echo "qemu_result" "$qemu_result" + echo "qemu_result" "$qemu_result" | grep 'qemu_result 0' + working-directory: ./ref_app/ diff --git a/.github/workflows/real-time-cpp.yml b/.github/workflows/real-time-cpp.yml index fc14bd57e..9bbd8d554 100644 --- a/.github/workflows/real-time-cpp.yml +++ b/.github/workflows/real-time-cpp.yml @@ -277,296 +277,3 @@ jobs: MSBuild -m ref_app.sln -p:Configuration=${{ matrix.suite }} -p:Platform=x64 /t:Rebuild dir .\tmp\${{ matrix.suite }}\ref_app.exe working-directory: ./ref_app/ - benchmark_gcc-clang: - runs-on: ubuntu-latest - defaults: - run: - shell: bash - strategy: - fail-fast: false - matrix: - compiler: [ g++, clang++ ] - standard: [ c++14, c++17, c++2a ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: clone-submods-bootstrap-headers-boost-develop - run: | - git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root - cd ../boost-root - git submodule update --init tools - git submodule update --init libs/config - git submodule update --init libs/math - git submodule update --init libs/multiprecision - ./bootstrap.sh - ./b2 headers - working-directory: ./ - - name: clone-cppalliance-decimal - run: | - git clone -b develop --depth 1 https://github.com/cppalliance/decimal.git ../cppalliance-decimal-root - working-directory: ./ - - name: benchmark_gcc-clang - run: ./target/build/test_app_benchmarks.sh ${{ matrix.compiler }} ${{ matrix.standard }} - working-directory: ./ref_app/ - benchmark_gcc-clang-8-9: - runs-on: ubuntu-20.04 - defaults: - run: - shell: bash - strategy: - fail-fast: false - matrix: - compiler: [ g++-8, g++-9, clang++-8, clang++-9 ] - standard: [ c++14, c++17 ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: update-tools - run: sudo apt install g++-8 g++-9 clang-8 clang-9 - - name: clone-submods-bootstrap-headers-boost-develop - run: | - git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root - cd ../boost-root - git submodule update --init tools - git submodule update --init libs/config - git submodule update --init libs/math - git submodule update --init libs/multiprecision - ./bootstrap.sh - ./b2 headers - working-directory: ./ - - name: clone-cppalliance-decimal - run: | - git clone -b develop --depth 1 https://github.com/cppalliance/decimal.git ../cppalliance-decimal-root - working-directory: ./ - - name: benchmark_gcc-clang-8-9 - run: ./target/build/test_app_benchmarks.sh ${{ matrix.compiler }} ${{ matrix.standard }} - working-directory: ./ref_app/ - benchmark_gcc-clang-10: - runs-on: ubuntu-20.04 - defaults: - run: - shell: bash - strategy: - fail-fast: false - matrix: - compiler: [ g++-10, clang++-10 ] - standard: [ c++14, c++17, c++20 ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: update-tools - run: sudo apt install gcc-10 clang-10 - - name: clone-submods-bootstrap-headers-boost-develop - run: | - git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root - cd ../boost-root - git submodule update --init tools - git submodule update --init libs/config - git submodule update --init libs/math - git submodule update --init libs/multiprecision - ./bootstrap.sh - ./b2 headers - working-directory: ./ - - name: clone-cppalliance-decimal - run: | - git clone -b develop --depth 1 https://github.com/cppalliance/decimal.git ../cppalliance-decimal-root - working-directory: ./ - - name: benchmark_gcc-clang-10 - run: ./target/build/test_app_benchmarks.sh ${{ matrix.compiler }} ${{ matrix.standard }} - working-directory: ./ref_app/ - benchmark_apple-clang: - runs-on: macos-latest - strategy: - fail-fast: false - matrix: - compiler: [ g++, clang++ ] - standard: [ c++14, c++17, c++2a ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: clone-submods-bootstrap-headers-boost-develop - run: | - git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root - cd ../boost-root - git submodule update --init tools - git submodule update --init libs/config - git submodule update --init libs/math - git submodule update --init libs/multiprecision - ./bootstrap.sh - ./b2 headers - working-directory: ./ - - name: clone-cppalliance-decimal - run: | - git clone -b develop --depth 1 https://github.com/cppalliance/decimal.git ../cppalliance-decimal-root - working-directory: ./ - - name: benchmark_apple-clang - run: ./target/build/test_app_benchmarks.sh ${{ matrix.compiler }} ${{ matrix.standard }} - working-directory: ./ref_app/ - benchmark_builds-avr: - runs-on: ubuntu-latest - defaults: - run: - shell: bash - strategy: - fail-fast: false - matrix: - standard: [ c++14 ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: update-tools - run: sudo apt install gcc-avr avr-libc - - name: benchmark_builds-avr - run: ./target/build/test_app_benchmarks_avr.sh ${{ matrix.standard }} - working-directory: ./ref_app/ - benchmark_builds-stm32f446: - runs-on: ubuntu-latest - defaults: - run: - shell: bash - strategy: - fail-fast: false - matrix: - standard: [ c++14, c++17, c++2a ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: update-tools - run: sudo apt install gcc-arm-none-eabi - - name: clone-submods-bootstrap-headers-boost-develop - run: | - git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root - cd ../boost-root - git submodule update --init tools - git submodule update --init libs/config - git submodule update --init libs/math - git submodule update --init libs/multiprecision - ./bootstrap.sh - ./b2 headers - working-directory: ./ - - name: clone-cppalliance-decimal - run: | - git clone -b develop --depth 1 https://github.com/cppalliance/decimal.git ../cppalliance-decimal-root - working-directory: ./ - - name: benchmark_builds-stm32f446 - run: ./target/build/test_app_benchmarks_stm32f446.sh ${{ matrix.standard }} - working-directory: ./ref_app/ - benchmark_single-stm32f446: - runs-on: ubuntu-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: update-tools - run: sudo apt install gcc-arm-none-eabi - - name: benchmark_single-stm32f446 - run: | - mkdir -p bin - arm-none-eabi-g++ -std=c++14 -Wall -Wextra -pedantic -O2 -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=32 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I./src/mcal/stm32f446 -I./src -DAPP_BENCHMARK_TYPE=APP_BENCHMARK_TYPE_CRC -DAPP_BENCHMARK_STANDALONE_MAIN ./src/app/benchmark/app_benchmark_crc.cpp ./target/micros/stm32f446/make/single/crt.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_crc.map -T ./target/micros/stm32f446/make/stm32f446.ld -o ./bin/app_benchmark_crc.elf - arm-none-eabi-objcopy ./bin/app_benchmark_crc.elf -O ihex ./bin/app_benchmark_crc.hex - ls -la ./bin/app_benchmark_crc.elf ./bin/app_benchmark_crc.hex ./bin/app_benchmark_crc.map - working-directory: ./ref_app/ - benchmark_single-cnl: - runs-on: ubuntu-latest - defaults: - run: - shell: bash - strategy: - fail-fast: false - matrix: - compiler: [ g++, clang++ ] - standard: [ c++20 ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: benchmark_single-cnl - run: | - git clone -b main --depth 1 https://github.com/johnmcfarlane/cnl.git ../cnl-root - mkdir -p bin - ${{ matrix.compiler }} -std=${{ matrix.standard }} -Wall -Werror -O3 -march=native -fsanitize=address -I./src -I../cnl-root/include -DAPP_BENCHMARK_TYPE=APP_BENCHMARK_TYPE_CNL_SCALED_INTEGER -DAPP_BENCHMARK_STANDALONE_MAIN ./src/app/benchmark/app_benchmark_cnl_scaled_integer.cpp -o ./bin/app_benchmark_cnl_scaled_integer.exe - ls -la ./bin/app_benchmark_cnl_scaled_integer.exe - ./bin/app_benchmark_cnl_scaled_integer.exe - working-directory: ./ref_app/ - benchmark_single-stm32f429-qemu-cnl: - runs-on: ubuntu-22.04 - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: update-tools - run: | - sudo apt install libncurses5 libpython2.7 - mkdir -p emu_env && cd emu_env - wget --no-check-certificate https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 - tar -xvf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 - wget --no-check-certificate https://github.com/xpack-dev-tools/qemu-arm-xpack/releases/download/v7.1.0-1/xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz - tar -xvzf xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz - working-directory: ./ref_app/ - - name: benchmark_single-stm32f429-qemu-cnl - run: | - git clone -b main --depth 1 https://github.com/johnmcfarlane/cnl.git ../cnl-root - mkdir -p bin - ./emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-g++ -std=c++20 -Wall -Wextra -pedantic -O2 -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=128 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I./src/mcal/stm32f429 -I./src -I../cnl-root/include -DAPP_BENCHMARK_TYPE=APP_BENCHMARK_TYPE_CNL_SCALED_INTEGER -DAPP_BENCHMARK_STANDALONE_MAIN ./src/app/benchmark/app_benchmark_cnl_scaled_integer.cpp ./target/micros/stm32f429/make/single/crt.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_cnl_scaled_integer.map -T ./target/micros/stm32f429/make/stm32f429.ld -o ./bin/app_benchmark_cnl_scaled_integer.elf - ./emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-objcopy ./bin/app_benchmark_cnl_scaled_integer.elf -O ihex ./bin/app_benchmark_cnl_scaled_integer.hex - ls -la ./bin/app_benchmark_cnl_scaled_integer.elf ./bin/app_benchmark_cnl_scaled_integer.hex ./bin/app_benchmark_cnl_scaled_integer.map - working-directory: ./ref_app/ - - name: emulate-target stm32f429 - run: | - ./emu_env/xpack-qemu-arm-7.1.0-1/bin/qemu-system-gnuarmeclipse --verbose --mcu STM32F429ZI --nographic --gdb tcp::9999 -d unimp,guest_errors & - working-directory: ./ref_app/ - - name: run-test-on-target - run: | - ./emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb-py ./bin/app_benchmark_cnl_scaled_integer.elf -x ./target/build/test_app_benchmarks_emulator.py - qemu_result=$? - echo "qemu_result" "$qemu_result" - echo "qemu_result" "$qemu_result" | grep 'qemu_result 0' - working-directory: ./ref_app/ - benchmark_single-stm32f429-qemu: - runs-on: ubuntu-22.04 - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - name: update-tools - run: | - sudo apt install libncurses5 libpython2.7 - mkdir -p emu_env && cd emu_env - wget --no-check-certificate https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 - tar -xvf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 - wget --no-check-certificate https://github.com/xpack-dev-tools/qemu-arm-xpack/releases/download/v7.1.0-1/xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz - tar -xvzf xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz - working-directory: ./ref_app/ - - name: build benchmark_single-stm32f429 - run: | - mkdir -p bin - emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-g++ -std=c++20 -Wall -Wextra -pedantic -O0 -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=32 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I./src/mcal/stm32f429 -I./src -DAPP_BENCHMARK_TYPE=APP_BENCHMARK_TYPE_CRC -DAPP_BENCHMARK_STANDALONE_MAIN ./src/app/benchmark/app_benchmark_crc.cpp ./target/micros/stm32f429/make/single/crt.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_crc.map -T ./target/micros/stm32f429/make/stm32f429.ld --specs=nano.specs --specs=nosys.specs -o ./bin/app_benchmark_crc.elf - emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-objcopy ./bin/app_benchmark_crc.elf -O ihex ./bin/app_benchmark_crc.hex - ls -la ./bin/app_benchmark_crc.elf ./bin/app_benchmark_crc.hex ./bin/app_benchmark_crc.map - working-directory: ./ref_app/ - - name: emulate-target stm32f429 - run: | - ./emu_env/xpack-qemu-arm-7.1.0-1/bin/qemu-system-gnuarmeclipse --verbose --mcu STM32F429ZI --nographic --gdb tcp::9999 -d unimp,guest_errors & - working-directory: ./ref_app/ - - name: run-test-on-target - run: | - ./emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb-py ./bin/app_benchmark_crc.elf -x ./target/build/test_app_benchmarks_emulator.py - qemu_result=$? - echo "qemu_result" "$qemu_result" - echo "qemu_result" "$qemu_result" | grep 'qemu_result 0' - working-directory: ./ref_app/ diff --git a/readme.md b/readme.md index 5a7d570cf..8e02dffdc 100644 --- a/readme.md +++ b/readme.md @@ -8,6 +8,8 @@ Build Examples Build Snippets + + Build Benchmarks Issues @@ -102,7 +104,7 @@ The reference application supports the following targets: It is easiest to get started with the reference application using one of the supported boards, such as Arduino or RaspberryPi ZERO or BeagleBone, etc. The reference application can be found -in the directory [./ref_app](./ref_app) and its +in the directory [ref_app](./ref_app) and its subdirectories. The reference application uses cross-development based on @@ -118,9 +120,9 @@ are available in the `bin` directory. ### Build with Bash Shell Script and GNU make To get started with the reference application on `*nix` - - Open a terminal in the directory [./ref_app](./ref_app). - - The terminal should be located directly in [./ref_app](./ref_app) for the paths to work out (be found by the upcoming build). - - Identify the Bash shell script [./ref_app/target/build/build.sh](./ref_app/target/build/build.sh). + - Open a terminal in the directory [ref_app](./ref_app). + - The terminal should be located directly in [ref_app](./ref_app) for the paths to work out (be found by the upcoming build). + - Identify the Bash shell script [ref_app/target/build/build.sh](./ref_app/target/build/build.sh). - Consider which configuration (such as `target avr`) you would like to build. - Execute `build.sh` with the command: `./target/build/build.sh avr rebuild`. - This shell script calls GNU make with parameters `avr rebuild` which subsequently rebuilds the entire solution for `target avr`. @@ -242,7 +244,7 @@ To get started with the reference application on `Win*` - Clone or get the [ckormanyos/real-time-cpp](https://github.com/ckormanyos/real-time-cpp) repository. - Get and setup (from the [ckormanyos/real-time-cpp-toolchains](https://github.com/ckormanyos/real-time-cpp-toolchains) repository) any needed GNU/GCC cross compilers running on `Win*`, as described in detail a few paragraphs below. - Start Visual Studio(R) 2019 (or later, Community Edition is OK) - - Open the solution `ref_app.sln` in the [./ref_app](./ref_app) directory. + - Open the solution `ref_app.sln` in the [ref_app](./ref_app) directory. - Select the desired configuration. - Then rebuild the entire solution. @@ -332,7 +334,7 @@ make -j ref_app There is also a workspace solution for ATMEL(R) AtmelStudio(R) 7. It is called `ref_app.atsln` and is also located -in the [./ref_app](./ref_app) directory. +in the [ref_app](./ref_app) directory. There are ATMEL Studio projects for both the reference application as well as for each of the examples. ATMEL Studio projects in this repository support @@ -346,7 +348,7 @@ during the standard installation of ATMEL Studio). ## Target Details Target details including startup code and linker definition files can -be found in the [./ref_app/target](./ref_app/target) directory +be found in the [ref_app/target](./ref_app/target) directory and its subdirectories. There are individual subdirectories for each supported target microcontroller system. diff --git a/ref_app/ref_app.sln b/ref_app/ref_app.sln index a9a97f821..6e18c336e 100644 --- a/ref_app/ref_app.sln +++ b/ref_app/ref_app.sln @@ -11,7 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{FF08 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{05C8F17D-422D-4E38-BC39-07809736C953}" ProjectSection(SolutionItems) = preProject - ..\.github\workflows\CodeQL.yml = ..\.github\workflows\CodeQL.yml + ..\.github\workflows\codeql.yml = ..\.github\workflows\codeql.yml + ..\.github\workflows\real-time-cpp-benchmarks.yml = ..\.github\workflows\real-time-cpp-benchmarks.yml ..\.github\workflows\real-time-cpp-examples.yml = ..\.github\workflows\real-time-cpp-examples.yml ..\.github\workflows\real-time-cpp-snippets.yml = ..\.github\workflows\real-time-cpp-snippets.yml ..\.github\workflows\real-time-cpp-sonar.yml = ..\.github\workflows\real-time-cpp-sonar.yml diff --git a/ref_app/src/app/benchmark/app_benchmark.h b/ref_app/src/app/benchmark/app_benchmark.h index cd7b5ceab..720f55101 100644 --- a/ref_app/src/app/benchmark/app_benchmark.h +++ b/ref_app/src/app/benchmark/app_benchmark.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2023. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef APP_BENCHMARK_2018_10_02_H_ - #define APP_BENCHMARK_2018_10_02_H_ +#ifndef APP_BENCHMARK_2018_10_02_H + #define APP_BENCHMARK_2018_10_02_H #define APP_BENCHMARK_TYPE_NONE 0 #define APP_BENCHMARK_TYPE_COMPLEX 1 @@ -110,4 +110,4 @@ } } // namespace app:::benchmark -#endif // APP_BENCHMARK_2018_10_02_H_ +#endif // APP_BENCHMARK_2018_10_02_H diff --git a/ref_app/src/app/benchmark/app_benchmark_trapezoid_integral.cpp b/ref_app/src/app/benchmark/app_benchmark_trapezoid_integral.cpp index 6a9b71f41..770c3b99d 100644 --- a/ref_app/src/app/benchmark/app_benchmark_trapezoid_integral.cpp +++ b/ref_app/src/app/benchmark/app_benchmark_trapezoid_integral.cpp @@ -1,4 +1,4 @@ -/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // Copyright Christopher Kormanyos 2021 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt @@ -9,54 +9,60 @@ #if(APP_BENCHMARK_TYPE == APP_BENCHMARK_TYPE_TRAPEZOID_INTEGRAL) -// See also: https://godbolt.org/z/j4aM9vzr9 +// See also: https://godbolt.org/z/8ahv5Ghx5 #include #if (defined(__has_include) && (__has_include())) #include + namespace app { namespace benchmark { #if (defined(__STDCPP_FLOAT64_T__) && (__STDCPP_FLOAT64_T__ == 1)) using my_float_type = std::float64_t; #else using my_float_type = float; -#endif + #endif + } } // namespace app::benchmark #else #include + namespace app { namespace benchmark { using my_float_type = std::floatmax_t; + } } // namespace app::benchmark #endif #include -#include #include #include namespace { template - FloatingPointType cyl_bessel_j(const std::uint_fast8_t n, - const FloatingPointType& x) + auto cyl_bessel_j(const std::uint_fast8_t n, const FloatingPointType& x) -> FloatingPointType { using local_float_type = FloatingPointType; - constexpr local_float_type epsilon = std::numeric_limits::epsilon(); + constexpr auto epsilon = std::numeric_limits::epsilon(); - using std::cos; - using std::sin; using std::sqrt; - const local_float_type tol = sqrt(epsilon); - - const local_float_type integration_result = math::integral(static_cast(0), - math::constants::pi(), - tol, - [&x, &n](const local_float_type& t) noexcept -> local_float_type - { - return cos(x * sin(t) - (t * static_cast(n))); - }); - - const local_float_type jn = integration_result / math::constants::pi(); - - return jn; + const auto tol = sqrt(epsilon); + + const auto integration_result = + math::integral(static_cast(0), + math::constants::pi(), + tol, + [&x, &n](const local_float_type& t) noexcept + { + using std::cos; + using std::sin; + + return + static_cast + ( + cos(x * sin(t) - (t * static_cast(n))) + ); + }); + + return integration_result / math::constants::pi(); } } @@ -65,7 +71,7 @@ auto app::benchmark::run_trapezoid_integral() -> bool static_assert((std::numeric_limits::digits >= 24), "Error: Incorrect my_float_type type definition"); - constexpr my_float_type app_benchmark_tolerance = + constexpr auto app_benchmark_tolerance = static_cast ( std::numeric_limits::epsilon() @@ -74,12 +80,7 @@ auto app::benchmark::run_trapezoid_integral() -> bool // Compute y = cyl_bessel_j(2, 1.23) = 0.16636938378681407351267852431513159437103348245333 // N[BesselJ[2, 123/100], 50] - const my_float_type j2 = - cyl_bessel_j - ( - UINT8_C(2), - static_cast(1.23L) - ); + const auto j2 = cyl_bessel_j(static_cast(UINT8_C(2)), static_cast(1.23L)); const bool app_benchmark_result_is_ok = detail::is_close_fraction @@ -93,18 +94,16 @@ auto app::benchmark::run_trapezoid_integral() -> bool } #if defined(APP_BENCHMARK_STANDALONE_MAIN) -int main() +auto main() -> int { - // g++ -Wall -O3 -march=native -I./ref_app/src/mcal/host -I./ref_app/src -DAPP_BENCHMARK_TYPE=APP_BENCHMARK_TYPE_TRAPEZOID_INTEGRAL -DAPP_BENCHMARK_STANDALONE_MAIN ./ref_app/src/app/benchmark/app_benchmark_trapezoid_integral.cpp -o ./ref_app/bin/app_benchmark_trapezoid_integral.exe - - bool result_is_ok = true; + bool result_is_ok { true }; - for(unsigned i = 0U; i < 64U; ++i) + for(auto i = static_cast(UINT8_C(0)); i < static_cast(UINT8_C(64)); ++i) { - result_is_ok &= app::benchmark::run_trapezoid_integral(); + result_is_ok = (app::benchmark::run_trapezoid_integral() && result_is_ok); } - return result_is_ok ? 0 : -1; + return (result_is_ok ? 0 : -1); } #endif diff --git a/ref_app/src/app/benchmark/readme.md b/ref_app/src/app/benchmark/readme.md index 829d7af27..b21aa504f 100644 --- a/ref_app/src/app/benchmark/readme.md +++ b/ref_app/src/app/benchmark/readme.md @@ -3,10 +3,10 @@

- Build Status + Build Benchmarks Boost Software License 1.0 - +

@@ -23,18 +23,18 @@ ## Executing the benchmarks Executing the benchmarks is straightforward. Select the desired benchmark and -activate its corresponding flag in [app_benchmark.h](https://github.com/ckormanyos/real-time-cpp/blob/master/ref_app/src/app/benchmark/app_benchmark_none.h) +activate its corresponding flag in +[app_benchmark.h](https://github.com/ckormanyos/real-time-cpp/blob/master/ref_app/src/app/benchmark/app_benchmark_none.h) Compile the reference application and run on the target. -The benchmark timing will be reflected on microcontroller-mcal's corresponding -benchmark port pin. +The benchmark timing will be reflected on microcontroller's corresponding +benchmark port pin (in its MCAL). -Individual benchmarks can also be run standalone on any C++ cplatform. +Individual benchmarks can also be run standalone on any C++ platform. In the following [short link](https://godbolt.org/z/j4aM9vzr9) -to [godbolt](https://godbolt.org), we have adapted the +to [godbolt](https://godbolt.org), for instance, we have adapted the `APP_BENCHMARK_TYPE_TRAPEZOID_INTEGRAL` benchmark for standalone use. -Note also that the presence of the `main()` subroutine is activated with -the compiler definition `APP_BENCHMARK_STANDALONE_MAIN`. - +The `main()` subroutine in the benchmark source files is activated +with the compiler definition `APP_BENCHMARK_STANDALONE_MAIN`. ## Individual benchmarks @@ -61,7 +61,7 @@ the compiler definition `APP_BENCHMARK_STANDALONE_MAIN`. - ![app_benchmark_ecc_generic_ecc.cpp](https://github.com/ckormanyos/real-time-cpp/blob/master/ref_app/src/app/benchmark/app_benchmark_ecc_generic_ecc.cpp) via `#define APP_BENCHMARK_TYPE_ECC_GENERIC_ECC` provides an intuitive view on elliptic-curve algebra, depicting a well-known $256$-bit cryptographic key-gen/sign/verify method. This benchmark is actually too lengthy to run on most of our embedded targets (other than BBB or RPI-zero) and adaptions of OS/watchdog are required in order to run this benchmark on the metal. - ![app_benchmark_non_std_decimal.cpp](https://github.com/ckormanyos/real-time-cpp/blob/master/ref_app/src/app/benchmark/app_benchmark_non_std_decimal.cpp) via `#define APP_BENCHMARK_TYPE_NON_STD_DECIMAL` carries out a $64$-bit decimal-floating-point calculation of the exponential function using the contemporary [cpplliance/decimal](https://github.com/cppalliance/decimal) library. This benchmark does not, at the moment, run on the AVR target, but requires a larger microcontroller such as one of the $32$-bit ARM(R) devices. -## Benchmarks and performance classes +## Performance classes Most of the benchmarks run on each supported target system. Experience with runs on the individual target systems reveal diff --git a/ref_app/target/app/make/app_rules.gmk b/ref_app/target/app/make/app_rules.gmk index 563688dbd..4a7bca584 100644 --- a/ref_app/target/app/make/app_rules.gmk +++ b/ref_app/target/app/make/app_rules.gmk @@ -1,5 +1,5 @@ # -# Copyright Christopher Kormanyos 2007 - 2023. +# Copyright Christopher Kormanyos 2007 - 2024. # Distributed under the Boost Software License, # Version 1.0. (See accompanying file LICENSE_1_0.txt # or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -38,7 +38,7 @@ $(PATH_OBJ)/%.o : %.cpp # ...and generate a dependency file (using the -MM flag), # ...and be sure to include the path in the dependency file. @-$(CC) $(CXXFLAGS) $(C_INCLUDES) $(DEP_FLAGS) $< -c -o $(PATH_OBJ)/$(basename $(@F)).o 2> $(PATH_ERR)/$(basename $(@F)).err - @-$(SED) -e 's|.h:\([0-9]*\),|.h(\1) :|' -e 's|:\([0-9]*\):|(\1) :|' $(PATH_ERR)/$(basename $(@F)).err + @-$(SED) -e 's|.h:\([0-9]*\),|.h(\1) :|' -e 's|.hpp:\([0-9]*\),|.hpp(\1) :|' -e 's|.cpp:\([0-9]*\),|.cpp(\1) :|' $(PATH_ERR)/$(basename $(@F)).err ifneq ($(findstr risc,$(GCC_TARGET)),) @-$(OBJDUMP) -S $(PATH_OBJ)/$(basename $(@F)).o > $(PATH_LST)/$(basename $(@F)).lst endif @@ -56,7 +56,7 @@ $(PATH_OBJ)/%.o : %.cc # ...and generate a dependency file (using the -MM flag), # ...and be sure to include the path in the dependency file. @-$(CC) $(CXXFLAGS) $(C_INCLUDES) $(DEP_FLAGS) $< -c -o $(PATH_OBJ)/$(basename $(@F)).o 2> $(PATH_ERR)/$(basename $(@F)).err - @-$(SED) -e 's|.h:\([0-9]*\),|.h(\1) :|' -e 's|:\([0-9]*\):|(\1) :|' $(PATH_ERR)/$(basename $(@F)).err + @-$(SED) -e 's|.h:\([0-9]*\),|.h(\1) :|' -e 's|.hpp:\([0-9]*\),|.hpp(\1) :|' -e 's|.cc:\([0-9]*\),|.cc(\1) :|' $(PATH_ERR)/$(basename $(@F)).err ifneq ($(findstr risc,$(GCC_TARGET)),) @-$(OBJDUMP) -S $(PATH_OBJ)/$(basename $(@F)).o > $(PATH_LST)/$(basename $(@F)).lst endif @@ -74,7 +74,7 @@ $(PATH_OBJ)/%.o : %.c # ...and generate a dependency file (using the -MM flag), # ...and be sure to include the path in the dependency file. @-$(CC) $(CFLAGS) $(C_INCLUDES) $(DEP_FLAGS) $< -c -o $(PATH_OBJ)/$(basename $(@F)).o 2> $(PATH_ERR)/$(basename $(@F)).err - @-$(SED) -e 's|.h:\([0-9]*\),|.h(\1) :|' -e 's|:\([0-9]*\):|(\1) :|' $(PATH_ERR)/$(basename $(@F)).err + @-$(SED) -e 's|.h:\([0-9]*\),|.h(\1) :|' -e 's|.c:\([0-9]*\),|.c(\1) :|' $(PATH_ERR)/$(basename $(@F)).err @-$(OBJDUMP) -S $(PATH_OBJ)/$(basename $(@F)).o > $(PATH_LST)/$(basename $(@F)).lst