本帖最后由 across往事 于 2026-2-12 10:23 编辑
上一篇利用AT32_Work_Bench+MDK进行了快速开发,体验确实不一般,非常容易而且代码仅需要编写业务逻辑即可,底层代码基本就是拿来就用,好不舒适。今天准备继续利用AT32_Work_Bench配置,实现coremark跑分,看看AT32F457开发板的性能究竟如何?敬请期待~ 打开AT32_Work_Bench,由于coremark的使用需要一个基准时钟,这里我是用tmr1配置一个输出1ms的计时器,也就是将频率设置为100Hz,配置如图1所示。 图1 AT32_Work_Bench配置AT32F457定时器界面 然后配置好USART和printf,这里上一期已经配置过了,请看图2和图3,这里简单的略过。 图2 AT32_Work_Bench配置AT32F457USART界面
图3 AT32_Work_Bench配置AT32F457delay基准源于串口打印配置界面 以上都配置好之后就可以输出代码工程了,输出之后即可拿MDK打开,接下来就需要下载coremark源码了。源码链接如下:https://github.com/eembc/coremark 当下载好源码之后,将所需要的文件复制出来,这里需要以下几个文件。并且添加到工程之中。 图4 coremark所需文件 图5 创建好的工程,添加coremark 图6 修改好的coremark工程 - int main(void)
- {
- /* add user code begin 1 */
- /* add user code end 1 */
- /* system clock config. */
- wk_system_clock_config();
- /* config periph clock. */
- wk_periph_clock_config();
- /* nvic config. */
- wk_nvic_config();
- /* timebase config for
- void wk_delay_us(uint32_t delay);
- void wk_delay_ms(uint32_t delay); */
- wk_timebase_init();
- /* init gpio function. */
- wk_gpio_config();
- /* init usart1 function. */
- wk_usart1_init();
- /* init tmr1 function. */
- wk_tmr1_init();
- int CoreMark_Main(int argc, char *argv[]);
- /* add user code begin 2 */
- CoreMark_Main(0, 0);
- /* add user code end 2 */
- while(1)
- {
- /* add user code begin 3 */
- /* add user code end 3 */
- }
- }
- volatile uint32_t uwTick = 0;
core portme.c
- /*
- Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- Original Author: Shay Gal-on
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include "coremark.h"
- #include "wk_system.h"
- #include "at32f45x_wk_config.h"
- #include "wk_usart.h"
- #include "wk_system.h"
- #include "wk_usart.h"
- #include "at32f45x_int.h"
- #if VALIDATION_RUN
- volatile ee_s32 seed1_volatile = 0x3415;
- volatile ee_s32 seed2_volatile = 0x3415;
- volatile ee_s32 seed3_volatile = 0x66;
- #endif
- #if PERFORMANCE_RUN
- volatile ee_s32 seed1_volatile = 0x0;
- volatile ee_s32 seed2_volatile = 0x0;
- volatile ee_s32 seed3_volatile = 0x66;
- #endif
- #if PROFILE_RUN
- volatile ee_s32 seed1_volatile = 0x8;
- volatile ee_s32 seed2_volatile = 0x8;
- volatile ee_s32 seed3_volatile = 0x8;
- #endif
- volatile ee_s32 seed4_volatile = ITERATIONS;
- volatile ee_s32 seed5_volatile = 0;
- /* Porting : Timing functions
- How to capture time and convert to seconds must be ported to whatever is
- supported by the platform. e.g. Read value from on board RTC, read value from
- cpu clock cycles performance counter etc. Sample implementation for standard
- time.h and windows.h definitions included.
- */
- /* Define : TIMER_RES_DIVIDER
- Divider to trade off timer resolution and total time that can be
- measured.
- Use lower values to increase resolution, but make sure that overflow
- does not occur. If there are issues with the return value overflowing,
- increase this value.
- */
- //#define NSECS_PER_SEC CLOCKS_PER_SEC
- //#define CORETIMETYPE clock_t
- //#define GETMYTIME(_t) (*_t = clock())
- //#define MYTIMEDIFF(fin, ini) ((fin) - (ini))
- //#define TIMER_RES_DIVIDER 1
- //#define SAMPLE_TIME_IMPLEMENTATION 1
- //#define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
- #define EE_TICKS_PER_SEC 1000
- #define SysTick_Counter_Disable ((uint32_t)0xFFFFFFFE)
- #define SysTick_Counter_Enable ((uint32_t)0x00000001)
- #define SysTick_Counter_Clear ((uint32_t)0x00000000)
- extern volatile uint32_t uwTick;
-
- uint32_t Tick;
- __IO uint32_t Ticks;
- /** Define Host specific (POSIX), or target specific global time variables. */
- //static CORETIMETYPE start_time_val, stop_time_val;
- /* Function : start_time
- This function will be called right before starting the timed portion of
- the benchmark.
- Implementation may be capturing a system timer (as implemented in the
- example code) or zeroing some system parameters - e.g. setting the cpu clocks
- cycles to 0.
- */
- void
- start_time(void)
- {
- // GETMYTIME(&start_time_val);
- Tick = HAL_GetTick();
- // systick_interrupt_config(1000);//1ms中断
- }
- /* Function : stop_time
- This function will be called right after ending the timed portion of the
- benchmark.
- Implementation may be capturing a system timer (as implemented in the
- example code) or other system parameters - e.g. reading the current value of
- cpu cycles counter.
- */
- void
- stop_time(void)
- {
- //GETMYTIME(&stop_time_val);
- /* Stop the Timer and get the encoding time */
- // SysTick->CTRL &=SysTick_Counter_Disable;
- // /* Clear the SysTick Counter */
- // SysTick->VAL = SysTick_Counter_Clear;
- }
- /* Function : get_time
- Return an abstract "ticks" number that signifies time on the system.
- Actual value returned may be cpu cycles, milliseconds or any other
- value, as long as it can be converted to seconds by <time_in_secs>. This
- methodology is taken to accommodate any hardware or simulated platform. The
- sample implementation returns millisecs by default, and the resolution is
- controlled by <TIMER_RES_DIVIDER>
- */
- CORE_TICKS
- get_time(void)
- {
- CORE_TICKS elapsed = (CORE_TICKS)(HAL_GetTick()-Tick);
- return elapsed;
- }
- /* Function : time_in_secs
- Convert the value returned by get_time to seconds.
- The <secs_ret> type is used to accommodate systems with no support for
- floating point. Default implementation implemented by the EE_TICKS_PER_SEC
- macro above.
- */
- secs_ret
- time_in_secs(CORE_TICKS ticks)
- {
- secs_ret retval=((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
- return retval;
- }
- ee_u32 default_num_contexts = 1;
- /* Function : portable_init
- Target specific initialization code
- Test for some common mistakes.
- */
- void portable_init(core_portable *p, int *argc, char *argv[])
- {
- //ee_printf("CoreMark run on AT32F437ZMT7 <a href="home.php?mod=space&uid=72445" target="_blank">@</a> %luHz\r\n", crm_clocks_freq_struct.sclk_freq);
-
- if (sizeof(ee_ptr_int) != sizeof(ee_u8*)) {
- ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\r\n");
- }
- if (sizeof(ee_u32) != 4) {
- ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\r\n");
- }
- p->portable_id = 1;
- }
- /* Function : portable_fini
- Target specific final code
- */
- void
- portable_fini(core_portable *p)
- {
- p->portable_id = 0;
- }
core portme.h
- /*
- Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- Original Author: Shay Gal-on
- */
- /* Topic : Description
- This file contains configuration constants required to execute on
- different platforms
- */
- #ifndef CORE_PORTME_H
- #define CORE_PORTME_H
- /************************/
- /* Data types and settings */
- /************************/
- /* Configuration : HAS_FLOAT
- Define to 1 if the platform supports floating point.
- */
- #ifndef HAS_FLOAT
- #define HAS_FLOAT 1
- #endif
- /* Configuration : HAS_TIME_H
- Define to 1 if platform has the time.h header file,
- and implementation of functions thereof.
- */
- #ifndef HAS_TIME_H
- #define HAS_TIME_H 1
- #endif
- /* Configuration : USE_CLOCK
- Define to 1 if platform has the time.h header file,
- and implementation of functions thereof.
- */
- #ifndef USE_CLOCK
- #define USE_CLOCK 1
- #endif
- /* Configuration : HAS_STDIO
- Define to 1 if the platform has stdio.h.
- */
- #ifndef HAS_STDIO
- #define HAS_STDIO 1
- #endif
- /* Configuration : HAS_PRINTF
- Define to 1 if the platform has stdio.h and implements the printf
- function.
- */
- #ifndef HAS_PRINTF
- #define HAS_PRINTF 1
- #endif
- /* Configuration : CORE_TICKS
- Define type of return from the timing functions.
- */
- #include <time.h>
- typedef clock_t CORE_TICKS;
- /* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION
- Initialize these strings per platform
- */
- #ifndef COMPILER_VERSION
- #ifdef __GNUC__
- #define COMPILER_VERSION "GCC"__VERSION__
- #else
- #define COMPILER_VERSION "MDK-ARM Plus Version: 5.39.0.0"
- #endif
- #endif
- #ifndef COMPILER_FLAGS
- #define COMPILER_FLAGS "Optimization: Level 3 (-03)" /* "Please put compiler flags here (e.g. -o3)" */
- #endif
- #ifndef MEM_LOCATION
- #define MEM_LOCATION "STACK"
- #endif
- #define ITERATIONS 10000;
- /* Data Types :
- To avoid compiler issues, define the data types that need ot be used for
- 8b, 16b and 32b in <core_portme.h>.
- *Imprtant* :
- ee_ptr_int needs to be the data type used to hold pointers, otherwise
- coremark may fail!!!
- */
- typedef signed short ee_s16;
- typedef unsigned short ee_u16;
- typedef signed int ee_s32;
- typedef double ee_f32;
- typedef unsigned char ee_u8;
- typedef unsigned int ee_u32;
- typedef ee_u32 ee_ptr_int;
- typedef size_t ee_size_t;
- /* align_mem :
- This macro is used to align an offset to point to a 32b value. It is
- used in the Matrix algorithm to initialize the input memory blocks.
- */
- #define align_mem(x) (void *)(4 + (((ee_ptr_int)(x)-1) & ~3))
- /* Configuration : SEED_METHOD
- Defines method to get seed values that cannot be computed at compile
- time.
- Valid values :
- SEED_ARG - from command line.
- SEED_FUNC - from a system function.
- SEED_VOLATILE - from volatile variables.
- */
- #ifndef SEED_METHOD
- #define SEED_METHOD SEED_VOLATILE
- #endif
- /* Configuration : MEM_METHOD
- Defines method to get a block of memry.
- Valid values :
- MEM_MALLOC - for platforms that implement malloc and have malloc.h.
- MEM_STATIC - to use a static memory array.
- MEM_STACK - to allocate the data block on the stack (NYI).
- */
- #ifndef MEM_METHOD
- #define MEM_METHOD MEM_STACK
- #endif
- /* Configuration : MULTITHREAD
- Define for parallel execution
- Valid values :
- 1 - only one context (default).
- N>1 - will execute N copies in parallel.
- Note :
- If this flag is defined to more then 1, an implementation for launching
- parallel contexts must be defined.
- Two sample implementations are provided. Use <USE_PTHREAD> or <USE_FORK>
- to enable them.
- It is valid to have a different implementation of <core_start_parallel>
- and <core_end_parallel> in <core_portme.c>, to fit a particular architecture.
- */
- #ifndef MULTITHREAD
- #define MULTITHREAD 1
- #define USE_PTHREAD 0
- #define USE_FORK 0
- #define USE_SOCKET 0
- #endif
- /* Configuration : MAIN_HAS_NOARGC
- Needed if platform does not support getting arguments to main.
- Valid values :
- 0 - argc/argv to main is supported
- 1 - argc/argv to main is not supported
- Note :
- This flag only matters if MULTITHREAD has been defined to a value
- greater then 1.
- */
- #ifndef MAIN_HAS_NOARGC
- #define MAIN_HAS_NOARGC 0
- #endif
- /* Configuration : MAIN_HAS_NORETURN
- Needed if platform does not support returning a value from main.
- Valid values :
- 0 - main returns an int, and return value will be 0.
- 1 - platform does not support returning a value from main
- */
- #ifndef MAIN_HAS_NORETURN
- #define MAIN_HAS_NORETURN 0
- #endif
- /* Variable : default_num_contexts
- Not used for this simple port, must contain the value 1.
- */
- extern ee_u32 default_num_contexts;
- typedef struct CORE_PORTABLE_S
- {
- ee_u8 portable_id;
- } core_portable;
- /* target specific init/fini */
- void portable_init(core_portable *p, int *argc, char *argv[]);
- void portable_fini(core_portable *p);
- #if !defined(PROFILE_RUN) && !defined(PERFORMANCE_RUN) \
- && !defined(VALIDATION_RUN)
- #if (TOTAL_DATA_SIZE == 1200)
- #define PROFILE_RUN 1
- #elif (TOTAL_DATA_SIZE == 2000)
- #define PERFORMANCE_RUN 1
- #else
- #define VALIDATION_RUN 1
- #endif
- #endif
- #endif /* CORE_PORTME_H */
core main.c
- /*
- Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- Original Author: Shay Gal-on
- */
- /* File: core_main.c
- This file contains the framework to acquire a block of memory, seed
- initial parameters, tun t he benchmark and report the results.
- */
- #include "coremark.h"
- /* Function: iterate
- Run the benchmark for a specified number of iterations.
- Operation:
- For each type of benchmarked algorithm:
- a - Initialize the data block for the algorithm.
- b - Execute the algorithm N times.
- Returns:
- NULL.
- */
- static ee_u16 list_known_crc[] = { (ee_u16)0xd4b0,
- (ee_u16)0x3340,
- (ee_u16)0x6a79,
- (ee_u16)0xe714,
- (ee_u16)0xe3c1 };
- static ee_u16 matrix_known_crc[] = { (ee_u16)0xbe52,
- (ee_u16)0x1199,
- (ee_u16)0x5608,
- (ee_u16)0x1fd7,
- (ee_u16)0x0747 };
- static ee_u16 state_known_crc[] = { (ee_u16)0x5e47,
- (ee_u16)0x39bf,
- (ee_u16)0xe5a4,
- (ee_u16)0x8e3a,
- (ee_u16)0x8d84 };
- void *
- iterate(void *pres)
- {
- ee_u32 i;
- ee_u16 crc;
- core_results *res = (core_results *)pres;
- ee_u32 iterations = res->iterations;
- res->crc = 0;
- res->crclist = 0;
- res->crcmatrix = 0;
- res->crcstate = 0;
- for (i = 0; i < iterations; i++)
- {
- crc = core_bench_list(res, 1);
- res->crc = crcu16(crc, res->crc);
- crc = core_bench_list(res, -1);
- res->crc = crcu16(crc, res->crc);
- if (i == 0)
- res->crclist = res->crc;
- }
- return NULL;
- }
- #if (SEED_METHOD == SEED_ARG)
- ee_s32 get_seed_args(int i, int argc, char *argv[]);
- #define get_seed(x) (ee_s16) get_seed_args(x, argc, argv)
- #define get_seed_32(x) get_seed_args(x, argc, argv)
- #else /* via function or volatile */
- ee_s32 get_seed_32(int i);
- #define get_seed(x) (ee_s16) get_seed_32(x)
- #endif
- #if (MEM_METHOD == MEM_STATIC)
- ee_u8 static_memblk[TOTAL_DATA_SIZE];
- #endif
- char *mem_name[3] = { "Static", "Heap", "Stack" };
- /* Function: main
- Main entry routine for the benchmark.
- This function is responsible for the following steps:
- 1 - Initialize input seeds from a source that cannot be determined at
- compile time. 2 - Initialize memory block for use. 3 - Run and time the
- benchmark. 4 - Report results, testing the validity of the output if the
- seeds are known.
- Arguments:
- 1 - first seed : Any value
- 2 - second seed : Must be identical to first for iterations to be
- identical 3 - third seed : Any value, should be at least an order of
- magnitude less then the input size, but bigger then 32. 4 - Iterations :
- Special, if set to 0, iterations will be automatically determined such that
- the benchmark will run between 10 to 100 secs
- */
- #if MAIN_HAS_NOARGC
- MAIN_RETURN_TYPE
- main(void)
- {
- int argc = 0;
- char *argv[1];
- #else
- MAIN_RETURN_TYPE
- CoreMark_Main(int argc, char *argv[])
- {
- #endif
- ee_u16 i, j = 0, num_algorithms = 0;
- ee_s16 known_id = -1, total_errors = 0;
- ee_u16 seedcrc = 0;
- CORE_TICKS total_time;
- core_results results[MULTITHREAD];
- #if (MEM_METHOD == MEM_STACK)
- ee_u8 stack_memblock[TOTAL_DATA_SIZE * MULTITHREAD];
- #endif
- /* first call any initializations needed */
- portable_init(&(results[0].port), &argc, argv);
- /* First some checks to make sure benchmark will run ok */
- if (sizeof(struct list_head_s) > 128)
- {
- ee_printf("list_head structure too big for comparable data!\n");
- return MAIN_RETURN_VAL;
- }
- results[0].seed1 = get_seed(1);
- results[0].seed2 = get_seed(2);
- results[0].seed3 = get_seed(3);
- results[0].iterations = get_seed_32(4);
- #if CORE_DEBUG
- results[0].iterations = 1;
- #endif
- results[0].execs = get_seed_32(5);
- if (results[0].execs == 0)
- { /* if not supplied, execute all algorithms */
- results[0].execs = ALL_ALGORITHMS_MASK;
- }
- /* put in some default values based on one seed only for easy testing */
- if ((results[0].seed1 == 0) && (results[0].seed2 == 0)
- && (results[0].seed3 == 0))
- { /* performance run */
- results[0].seed1 = 0;
- results[0].seed2 = 0;
- results[0].seed3 = 0x66;
- }
- if ((results[0].seed1 == 1) && (results[0].seed2 == 0)
- && (results[0].seed3 == 0))
- { /* validation run */
- results[0].seed1 = 0x3415;
- results[0].seed2 = 0x3415;
- results[0].seed3 = 0x66;
- }
- #if (MEM_METHOD == MEM_STATIC)
- results[0].memblock[0] = (void *)static_memblk;
- results[0].size = TOTAL_DATA_SIZE;
- results[0].err = 0;
- #if (MULTITHREAD > 1)
- #error "Cannot use a static data area with multiple contexts!"
- #endif
- #elif (MEM_METHOD == MEM_MALLOC)
- for (i = 0; i < MULTITHREAD; i++)
- {
- ee_s32 malloc_override = get_seed(7);
- if (malloc_override != 0)
- results[i].size = malloc_override;
- else
- results[i].size = TOTAL_DATA_SIZE;
- results[i].memblock[0] = portable_malloc(results[i].size);
- results[i].seed1 = results[0].seed1;
- results[i].seed2 = results[0].seed2;
- results[i].seed3 = results[0].seed3;
- results[i].err = 0;
- results[i].execs = results[0].execs;
- }
- #elif (MEM_METHOD == MEM_STACK)
- for (i = 0; i < MULTITHREAD; i++)
- {
- results[i].memblock[0] = stack_memblock + i * TOTAL_DATA_SIZE;
- results[i].size = TOTAL_DATA_SIZE;
- results[i].seed1 = results[0].seed1;
- results[i].seed2 = results[0].seed2;
- results[i].seed3 = results[0].seed3;
- results[i].err = 0;
- results[i].execs = results[0].execs;
- }
- #else
- #error "Please define a way to initialize a memory block."
- #endif
- /* Data init */
- /* Find out how space much we have based on number of algorithms */
- for (i = 0; i < NUM_ALGORITHMS; i++)
- {
- if ((1 << (ee_u32)i) & results[0].execs)
- num_algorithms++;
- }
- for (i = 0; i < MULTITHREAD; i++)
- results[i].size = results[i].size / num_algorithms;
- /* Assign pointers */
- for (i = 0; i < NUM_ALGORITHMS; i++)
- {
- ee_u32 ctx;
- if ((1 << (ee_u32)i) & results[0].execs)
- {
- for (ctx = 0; ctx < MULTITHREAD; ctx++)
- results[ctx].memblock[i + 1]
- = (char *)(results[ctx].memblock[0]) + results[0].size * j;
- j++;
- }
- }
- /* call inits */
- for (i = 0; i < MULTITHREAD; i++)
- {
- if (results[i].execs & ID_LIST)
- {
- results[i].list = core_list_init(
- results[0].size, results[i].memblock[1], results[i].seed1);
- }
- if (results[i].execs & ID_MATRIX)
- {
- core_init_matrix(results[0].size,
- results[i].memblock[2],
- (ee_s32)results[i].seed1
- | (((ee_s32)results[i].seed2) << 16),
- &(results[i].mat));
- }
- if (results[i].execs & ID_STATE)
- {
- core_init_state(
- results[0].size, results[i].seed1, results[i].memblock[3]);
- }
- }
- /* automatically determine number of iterations if not set */
- if (results[0].iterations == 0)
- {
- secs_ret secs_passed = 0;
- ee_u32 divisor;
- results[0].iterations = 1;
- while (secs_passed < (secs_ret)1)
- {
- results[0].iterations *= 10;
- start_time();
- iterate(&results[0]);
- stop_time();
- secs_passed = time_in_secs(get_time());
- }
- /* now we know it executes for at least 1 sec, set actual run time at
- * about 10 secs */
- divisor = (ee_u32)secs_passed;
- if (divisor == 0) /* some machines cast float to int as 0 since this
- conversion is not defined by ANSI, but we know at
- least one second passed */
- divisor = 1;
- results[0].iterations *= 1 + 10 / divisor;
- }
- /* perform actual benchmark */
- start_time();
- #if (MULTITHREAD > 1)
- if (default_num_contexts > MULTITHREAD)
- {
- default_num_contexts = MULTITHREAD;
- }
- for (i = 0; i < default_num_contexts; i++)
- {
- results[i].iterations = results[0].iterations;
- results[i].execs = results[0].execs;
- core_start_parallel(&results[i]);
- }
- for (i = 0; i < default_num_contexts; i++)
- {
- core_stop_parallel(&results[i]);
- }
- #else
- iterate(&results[0]);
- #endif
- stop_time();
- total_time = get_time();
- /* get a function of the input to report */
- seedcrc = crc16(results[0].seed1, seedcrc);
- seedcrc = crc16(results[0].seed2, seedcrc);
- seedcrc = crc16(results[0].seed3, seedcrc);
- seedcrc = crc16(results[0].size, seedcrc);
- switch (seedcrc)
- { /* test known output for common seeds */
- case 0x8a02: /* seed1=0, seed2=0, seed3=0x66, size 2000 per algorithm */
- known_id = 0;
- ee_printf("6k performance run parameters for coremark.\n");
- break;
- case 0x7b05: /* seed1=0x3415, seed2=0x3415, seed3=0x66, size 2000 per
- algorithm */
- known_id = 1;
- ee_printf("6k validation run parameters for coremark.\n");
- break;
- case 0x4eaf: /* seed1=0x8, seed2=0x8, seed3=0x8, size 400 per algorithm
- */
- known_id = 2;
- ee_printf("Profile generation run parameters for coremark.\n");
- break;
- case 0xe9f5: /* seed1=0, seed2=0, seed3=0x66, size 666 per algorithm */
- known_id = 3;
- ee_printf("2K performance run parameters for coremark.\n");
- break;
- case 0x18f2: /* seed1=0x3415, seed2=0x3415, seed3=0x66, size 666 per
- algorithm */
- known_id = 4;
- ee_printf("2K validation run parameters for coremark.\n");
- break;
- default:
- total_errors = -1;
- break;
- }
- if (known_id >= 0)
- {
- for (i = 0; i < default_num_contexts; i++)
- {
- results[i].err = 0;
- if ((results[i].execs & ID_LIST)
- && (results[i].crclist != list_known_crc[known_id]))
- {
- ee_printf("[%u]ERROR! list crc 0x%04x - should be 0x%04x\n",
- i,
- results[i].crclist,
- list_known_crc[known_id]);
- results[i].err++;
- }
- if ((results[i].execs & ID_MATRIX)
- && (results[i].crcmatrix != matrix_known_crc[known_id]))
- {
- ee_printf("[%u]ERROR! matrix crc 0x%04x - should be 0x%04x\n",
- i,
- results[i].crcmatrix,
- matrix_known_crc[known_id]);
- results[i].err++;
- }
- if ((results[i].execs & ID_STATE)
- && (results[i].crcstate != state_known_crc[known_id]))
- {
- ee_printf("[%u]ERROR! state crc 0x%04x - should be 0x%04x\n",
- i,
- results[i].crcstate,
- state_known_crc[known_id]);
- results[i].err++;
- }
- total_errors += results[i].err;
- }
- }
- total_errors += check_data_types();
- /* and report results */
- ee_printf("CoreMark Size : %lu\n", (long unsigned)results[0].size);
- ee_printf("Total ticks : %lu\n", (long unsigned)total_time);
- #if HAS_FLOAT
- ee_printf("Total time (secs): %f\n", time_in_secs(total_time));
- if (time_in_secs(total_time) > 0)
- ee_printf("Iterations/Sec : %f\n",
- default_num_contexts * results[0].iterations
- / time_in_secs(total_time));
- #else
- ee_printf("Total time (secs): %d\n", time_in_secs(total_time));
- if (time_in_secs(total_time) > 0)
- ee_printf("Iterations/Sec : %d\n",
- default_num_contexts * results[0].iterations
- / time_in_secs(total_time));
- #endif
- if (time_in_secs(total_time) < 10)
- {
- ee_printf(
- "ERROR! Must execute for at least 10 secs for a valid result!\n");
- total_errors++;
- }
- ee_printf("Iterations : %lu\n",
- (long unsigned)default_num_contexts * results[0].iterations);
- ee_printf("Compiler version : %s\n", COMPILER_VERSION);
- ee_printf("Compiler flags : %s\n", COMPILER_FLAGS);
- #if (MULTITHREAD > 1)
- ee_printf("Parallel %s : %d\n", PARALLEL_METHOD, default_num_contexts);
- #endif
- ee_printf("Memory location : %s\n", MEM_LOCATION);
- /* output for verification */
- ee_printf("seedcrc : 0x%04x\n", seedcrc);
- if (results[0].execs & ID_LIST)
- for (i = 0; i < default_num_contexts; i++)
- ee_printf("[%d]crclist : 0x%04x\n", i, results[i].crclist);
- if (results[0].execs & ID_MATRIX)
- for (i = 0; i < default_num_contexts; i++)
- ee_printf("[%d]crcmatrix : 0x%04x\n", i, results[i].crcmatrix);
- if (results[0].execs & ID_STATE)
- for (i = 0; i < default_num_contexts; i++)
- ee_printf("[%d]crcstate : 0x%04x\n", i, results[i].crcstate);
- for (i = 0; i < default_num_contexts; i++)
- ee_printf("[%d]crcfinal : 0x%04x\n", i, results[i].crc);
- if (total_errors == 0)
- {
- ee_printf(
- "Correct operation validated. See README.md for run and reporting "
- "rules.\n");
- #if HAS_FLOAT
- if (known_id == 3)
- {
- ee_printf("CoreMark 1.0 : %f / %s %s",
- default_num_contexts * results[0].iterations
- / time_in_secs(total_time),
- COMPILER_VERSION,
- COMPILER_FLAGS);
- #if defined(MEM_LOCATION) && !defined(MEM_LOCATION_UNSPEC)
- ee_printf(" / %s", MEM_LOCATION);
- #else
- ee_printf(" / %s", mem_name[MEM_METHOD]);
- #endif
- #if (MULTITHREAD > 1)
- ee_printf(" / %d:%s", default_num_contexts, PARALLEL_METHOD);
- #endif
- ee_printf("\n");
- }
- #endif
- }
- if (total_errors > 0)
- ee_printf("Errors detected\n");
- if (total_errors < 0)
- ee_printf(
- "Cannot validate operation for these seed values, please compare "
- "with results on a known platform.\n");
- #if (MEM_METHOD == MEM_MALLOC)
- for (i = 0; i < MULTITHREAD; i++)
- portable_free(results[i].memblock[0]);
- #endif
- /* And last call any target specific code for finalizing */
- portable_fini(&(results[0].port));
- return MAIN_RETURN_VAL;
- }
跑分如下: 图7 AT32F457跑飞结果 总的来说,移植coremark确实不麻烦,而且使用AT32_Work_Bench配合配置底层函数,非常简单便捷,看结果来说,AT32F457的性能还是不错的,很适合跑一些基础性的控制算法。这篇就到这里啦,感谢各位~
|