编译环境:WSL Ubuntu22.04 GCC10.3.1
RP2040默认频率125MHz,在此频率下实测O3等级跑分235左右,O2等级跑分239左右。
移植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)
133MHz频率跑分:
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 19644
Total time (secs): 19.644000
Iterations/Sec : 254.530645
Iterations : 5000
Compiler version : GCC10.3.1 20210621 (release)
Compiler flags : -O2
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0xbd59
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 254.530645 / GCC10.3.1 20210621 (release) -O2 / STACK
200MHz频率跑分:
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 15664
Total time (secs): 15.664000
Iterations/Sec : 383.043922
Iterations : 6000
Compiler version : GCC10.3.1 20210621 (release)
Compiler flags : -O2
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0xa14c
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 383.043922 / GCC10.3.1 20210621 (release) -O2 / STACK
250MHz频率跑分:
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 10440
Total time (secs): 10.440000
Iterations/Sec : 478.927203
Iterations : 5000
Compiler version : GCC10.3.1 20210621 (release)
Compiler flags : -O2
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0xbd59
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 478.927203 / GCC10.3.1 20210621 (release) -O2 / STACK
280MHz频率跑分:
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 11184
Total time (secs): 11.184000
Iterations/Sec : 536.480687
Iterations : 6000
Compiler version : GCC10.3.1 20210621 (release)
Compiler flags : -O2
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0xa14c
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 536.480687 / GCC10.3.1 20210621 (release) -O2 / STACK
测试得到RelWithDebInfo模式下1.91CoreMark/MHz,手上两块RP2040测出来结果一样,差异性应该不大。