编译环境:WSL Ubuntu22.04 GCC13.2.0
Hazard3 存储库https://github.com/Wren6991/Hazard3/
RP2350默认频率150MHz,编译内核为其RISC-V架构内核,在此频率下实测O3等级跑分453左右,O2等级跑分429左右。
在测试时,当我打开第二个核心后,并且第二个核心只用来控制led灯,此时coremark跑分明显下降,使用arm内核时未出现此现象,rp2040也并未出现此现象。
RP2350内部有两个Cortex-M33核心,两个自研RISC-V核心,虽然一共有四个但是只能选择两个核心使用,本文只使用了一个RISC-V的核心进行测试。
移植coremark,加入TinyUSB虚拟串口打印,主函数如下:
int main(void) {
set_sys_clock_khz(200*1000,true);
clock_configure(clk_peri,0,CLOCKS_CLK_PERI_CTRL_AUXSRC_VALUE_CLKSRC_PLL_SYS,200*MHZ,200*MHZ);
stdio_init_all();
int rc = pico_led_init();
hard_assert(rc == PICO_OK);
struct repeating_timer timer0;
add_repeating_timer_us(-1000,sysTick,NULL,&timer0);
main_core(0,0);
while (true) {
pico_set_led(true);
sleep_ms(LED_DELAY_MS);
printf("Hello, world!\n");
sleep_ms(LED_DELAY_MS);
pico_set_led(false);
sleep_ms(LED_DELAY_MS);
}
}
CMakeList.txt规则如下:
add_executable(blink
blink.c
)
# Release - 添加 -O3 -DNDEBUG 标志
# Debug - 添加 -g 标志
# MinSizeRel - 添加 -Os -DNDEBUG
# RelWithDebInfo - 添加 -O2 -g -DNDEBUG 标志
# pull in common dependencies
add_subdirectory(coremark)
target_link_libraries(blink pico_stdlib coremark )
if (PICO_CYW43_SUPPORTED)
target_link_libraries(blink pico_cyw43_arch_none)
endif()
pico_enable_stdio_usb(blink 1)
pico_enable_stdio_uart(blink 0)
# create map/bin/hex file etc.
pico_add_extra_outputs(blink)
# add url via pico_set_program_url
example_auto_set_url(blink)
coremark目录CMakeList.txt规则:
file(GLOB_RECURSE srcs CONFIGURE_DEPENDS ./*.c ./*.h)
add_library(coremark STATIC ${srcs})
target_link_libraries(coremark PUBLIC pico_stdlib)
target_include_directories(coremark PUBLIC include)
与编译rp2350的arm内核不同,需要risc-v编译器,我使用的是官方推荐的网址https://www.embecosm.com/resources/tool-chain-downloads/#riscv-stable 下载对应的版本
cmake的时候这样输入:
export PICO_SDK_PATH=我的路径
export PICO_RISCV_TOOLCHAIN_PATH=/我的路径/riscv32-embecosm-ubuntu2204-gcc13.2.0
export PICO_TOOLCHAIN_PATH=/我的路径/riscv32-embecosm-ubuntu2204-gcc13.2.0
cmake .. -DCMAKE_BUILD_TYPE=Release -DPICO_PLATFORM=rp2350
150MHz频率跑分:
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 22039
Total time (secs): 22.039000
Iterations/Sec : 453.741095
Iterations : 10000
Compiler version : GCC13.2.0
Compiler flags : -O3
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0x988c
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 453.741095 / GCC13.2.0 -O3 / STACK
250MHz频率跑分:
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 11927
Total time (secs): 11.927000
Iterations/Sec : 838.433806
Iterations : 10000
Compiler version : GCC13.2.0
Compiler flags : -O3
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0x988c
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 838.433806 / GCC13.2.0 -O3 / STACK
320MHz频率跑分:
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 10322
Total time (secs): 10.322000
Iterations/Sec : 968.804495
Iterations : 10000
Compiler version : GCC13.2.0
Compiler flags : -O3
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0x988c
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 968.804495 / GCC13.2.0 -O3 / STACK
当我打开第二核心并只用来闪烁led时,频率320MHz的跑分如下:
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 11298
Total time (secs): 11.298000
Iterations/Sec : 885.112409
Iterations : 10000
Compiler version : GCC13.2.0
Compiler flags : -O3
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0x988c
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 885.112409 / GCC13.2.0 -O3 / STACK
在此条件下,调整到250MHz频率,跑分如下:
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 14515
Total time (secs): 14.515000
Iterations/Sec : 688.942473
Iterations : 10000
Compiler version : GCC13.2.0
Compiler flags : -O3
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0x988c
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 688.942473 / GCC13.2.0 -O3 / STACK
测试得到在不开第二个核心的情况下,Release模式跑分3.00CoreMark/MHz,相对于arm架构内核,有一定提升,但在打开第二个核心后跑分变成了2.75CoreMark/MHz,这一点比较奇怪,因为ARM架构的M33内核并未出现此情况,最后下次看看他们功率情况。
标签:coremark,Hazard3,RISC,编译器,CoreMark,GCC13.2,O3,STACK,Iterations From: https://blog.csdn.net/weixin_49959979/article/details/142661223