-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff0c6df
commit ae56059
Showing
10 changed files
with
852 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright Matt Borland 2023 - 2024. | ||
# Copyright Christopher Kormanyos 2023 - 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: metal | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
- feature/** | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
jobs: | ||
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 -xf 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 -xzf xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz | ||
working-directory: ./test/metal/ | ||
- 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 -Wpedantic -Os -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 -fno-inline-functions -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I../../include -DBOOST_CRYPT_DISABLE_IOSTREAM -DAPP_BENCHMARK_STANDALONE_MAIN app_benchmark_hasher.cpp ./target/micros/stm32f429/make/single/crt.cpp ./target/micros/stm32f429/make/single/mcal_gcc_cxx_completion_with_stdlib.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_hasher.map -T ./target/micros/stm32f429/make/stm32f429.ld --specs=nano.specs --specs=nosys.specs -Wl,--print-memory-usage -o ./bin/app_benchmark_hasher.elf | ||
emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-objcopy ./bin/app_benchmark_hasher.elf -O ihex ./bin/app_benchmark_hasher.hex | ||
ls -la ./bin/app_benchmark_hasher.elf ./bin/app_benchmark_hasher.hex ./bin/app_benchmark_hasher.map | ||
working-directory: ./test/metal/ | ||
- 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: ./test/metal/ | ||
- 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_hasher.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: ./test/metal/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2024 Matt Borland | ||
// Copyright 2024 Christopher Kormanyos | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
|
||
#ifndef BOOST_CRYPT_UTILITIES_ALGORITHM_HPP | ||
#define BOOST_CRYPT_UTILITIES_ALGORITHM_HPP | ||
|
||
#include <boost/crypt/utility/config.hpp> | ||
|
||
namespace boost { namespace crypt { | ||
|
||
template<class InputIt1, class InputIt2> | ||
BOOST_CRYPT_GPU_ENABLED constexpr auto equal(InputIt1 first1, InputIt1 last1, InputIt2 first2) -> bool | ||
{ | ||
while(first1 != last1) | ||
{ | ||
if(!(*first1 == *first2)) | ||
{ | ||
return false; | ||
} | ||
|
||
++first1; | ||
++first2; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
template<class InputIt1, class InputIt2> | ||
BOOST_CRYPT_GPU_ENABLED constexpr auto lexicographical_compare(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) -> bool | ||
{ | ||
while((first1 != last1) && (first2 != last2)) | ||
{ | ||
if(*first1 < *first2) | ||
{ | ||
return true; | ||
} | ||
|
||
if(*first2 < *first1) | ||
{ | ||
return false; | ||
} | ||
|
||
++first1; | ||
++first2; | ||
} | ||
|
||
return ((first1 == last1) && (first2 != last2)); | ||
} | ||
|
||
} // namespace crypt | ||
} // namespace boost | ||
|
||
#endif // BOOST_CRYPT_UTILITIES_ALGORITHM_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// Copyright Christopher Kormanyos 2023. | ||
// 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) | ||
// | ||
|
||
#if defined(__GNUC__) | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable" | ||
#endif | ||
|
||
// cd /mnt/c/ChrisGitRepos/cppalliance/crypt/test/metal | ||
// mkdir -p bin | ||
// arm-none-eabi-g++ -std=c++17 -Wall -Wextra -Wpedantic -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=128 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I../../include -DBOOST_DECIMAL_DISABLE_CLIB -DAPP_BENCHMARK_STANDALONE_MAIN app_benchmark_hasher.cpp ./target/micros/stm32f429/make/single/crt.cpp ./target/micros/stm32f429/make/single/mcal_gcc_cxx_completion_with_stdlib.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_hasher.map -T ./target/micros/stm32f429/make/stm32f429.ld --specs=nano.specs --specs=nosys.specs -Wl,--print-memory-usage -o ./bin/app_benchmark_hasher.elf | ||
// arm-none-eabi-objcopy ./bin/app_benchmark_hasher.elf -O ihex ./bin/app_benchmark_hasher.hex | ||
// ls -la ./bin/app_benchmark_hasher.elf ./bin/app_benchmark_hasher.hex ./bin/app_benchmark_hasher.map | ||
|
||
#if !defined(BOOST_CRYPT_STANDALONE) | ||
#define BOOST_DECIMAL_STANDALONE | ||
#endif | ||
|
||
#include <boost/crypt/hash/sha256.hpp> | ||
|
||
namespace app { namespace benchmark { | ||
|
||
namespace detail { | ||
|
||
} // namespace detail | ||
|
||
auto run_hasher() -> bool; | ||
|
||
} // namespace benchmark | ||
} // namespace app | ||
|
||
namespace local | ||
{ | ||
|
||
using hasher_type = boost::crypt::sha256_hasher; | ||
|
||
} // namespace local | ||
|
||
auto app::benchmark::run_hasher() -> bool | ||
{ | ||
auto app_benchmark_result_is_ok = true; | ||
|
||
// "abc" | ||
const std::array<std::uint8_t, 3U> message = | ||
{{ | ||
0x61U, 0x62U, 0x63U | ||
}}; | ||
|
||
using local_hasher_type = local::hasher_type; | ||
using local_result_type = typename local_hasher_type::return_type; | ||
|
||
const local_result_type control = | ||
{{ | ||
0xBAU, 0x78U, 0x16U, 0xBFU, 0x8FU, 0x01U, 0xCFU, 0xEAU, | ||
0x41U, 0x41U, 0x40U, 0xDEU, 0x5DU, 0xAEU, 0x22U, 0x23U, | ||
0xB0U, 0x03U, 0x61U, 0xA3U, 0x96U, 0x17U, 0x7AU, 0x9CU, | ||
0xB4U, 0x10U, 0xFFU, 0x61U, 0xF2U, 0x00U, 0x15U, 0xADU, | ||
}}; | ||
|
||
local_hasher_type my_hasher { }; | ||
|
||
my_hasher.init(); | ||
|
||
my_hasher.process_bytes(message.data(), message.size()); | ||
|
||
const local_result_type result = my_hasher.get_digest(); | ||
|
||
const bool result_hash_is_ok { result == control }; | ||
|
||
app_benchmark_result_is_ok = (result_hash_is_ok && app_benchmark_result_is_ok); | ||
|
||
return app_benchmark_result_is_ok; | ||
} | ||
|
||
#if defined(APP_BENCHMARK_STANDALONE_MAIN) | ||
constexpr auto app_benchmark_standalone_foodcafe = static_cast<std::uint32_t>(UINT32_C(0xF00DCAFE)); | ||
|
||
extern "C" | ||
{ | ||
extern volatile std::uint32_t app_benchmark_standalone_result; | ||
|
||
auto app_benchmark_run_standalone (void) -> bool; | ||
auto app_benchmark_get_standalone_result(void) -> bool; | ||
|
||
auto app_benchmark_run_standalone(void) -> bool | ||
{ | ||
auto result_is_ok = true; | ||
|
||
for(unsigned i = 0U; i < 64U; ++i) | ||
{ | ||
result_is_ok &= app::benchmark::run_hasher(); | ||
} | ||
|
||
app_benchmark_standalone_result = | ||
static_cast<std::uint32_t> | ||
( | ||
result_is_ok ? app_benchmark_standalone_foodcafe : static_cast<std::uint32_t>(UINT32_C(0xFFFFFFFF)) | ||
); | ||
|
||
return result_is_ok; | ||
} | ||
|
||
auto app_benchmark_get_standalone_result(void) -> bool | ||
{ | ||
volatile auto result_is_ok = (app_benchmark_standalone_result == static_cast<std::uint32_t>(UINT32_C(0xF00DCAFE))); | ||
|
||
return result_is_ok; | ||
} | ||
} | ||
|
||
auto main() -> int | ||
{ | ||
auto result_is_ok = true; | ||
|
||
result_is_ok = (::app_benchmark_run_standalone () && result_is_ok); | ||
result_is_ok = (::app_benchmark_get_standalone_result() && result_is_ok); | ||
|
||
return (result_is_ok ? 0 : -1); | ||
} | ||
|
||
extern "C" | ||
{ | ||
volatile std::uint32_t app_benchmark_standalone_result; | ||
} | ||
#endif // APP_BENCHMARK_STANDALONE_MAIN | ||
|
||
#if defined(__GNUC__) | ||
#pragma GCC diagnostic pop | ||
#endif |
Oops, something went wrong.