### 02- CoreMark transplantation evaluation of Atria AT32A403A development board### 1. Software and hardware platform 1. AT32A403A Board development board 2. MDK-ARM Keil 3. CoreMark source code
### 2. CoreMark CoreMark is a benchmark program used to evaluate CPU performance. It includes a variety of different computing tasks, including floating point, integer, cache, memory and other aspects. CoreMark test results are usually used as a reference for CPU performance. It can help developers and system administrators evaluate the performance of different processors and systems, compare the performance differences between different processors, and can also be used to test the performance of processors in multi-threaded parallel computing. Official website: https://www.eembc.org/ Github repository address: https://github.com/eembc/coremark Among them, simple is the interface transplantation file, which is more important. Important modifications are made here. The following core_main.c, core_matrix.c and other files are important files for testing
### 3. CoreMark transplantation 1. Make modifications to the project that supports printf and build your own project template, mainly modifying the path and establishing the at32a403a_coremark_tempalte project template.
1. Application Main function, application layer code 2. BspDrivers Board-level driver module files 3. Drivers Low-level driver library files Firmware Library 4. Project Project files
2. Add CoreMark source code, where core_portme.c core_portme.h are the files that need to be modified (sample files)
3. Open the project and add files
4. Modify the content of the core_portme.c file 1. Modify some macro definitions The value of ITERATIONS depends on the situation. If **ERROR! Must execute for at least 10 secs for a valid result!** appears, then you need to change this value to make the program run time at least 10 seconds. ```c #define SysTick_Counter_Disable ((uint32_t)0xFFFFFFFE) #define SysTick_Counter_Enable ((uint32_t)0x00000001) #define SysTick_Counter_Clear ((uint32_t)0x00000000) __IO uint32_t Ticks; #define ITERATIONS 500 0; ``` 2. Shield part of the code ```c //#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_IMPLEMENT ATION 1 //#define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER) /** Define Host specific (POSIX), or target specific global time variables. */ //static CORETIMETYPE start_time_val, stop_time_val;//changed ```` 3. Add start_time, stop_time, get_time function body, mainly for time timing ```c __IO uint32_t Ticks; /* 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 - eg setting the cpu clocks cycles to 0. */ void start_time(void)//changed { //GETMYTIME(&start_time_val); Ticks++; SysTick_Config(SystemCoreClock / 1000); //1ms interrupt} /* 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 - eg reading the current value of cpu cycles counter.*/
void stop_time(void)//changed
{
//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
. This
methodology is taken to accomodate any hardware or simulated platform. The
sample implementation returns millisecs by default, and the resolution is
controlled by
*/ CORE_TICKS get_time(void)//changed { CORE_TICKS elapsed=(CORE_TICKS) Ticks;//(MYTIMEDIFF(stop_time_val, start_time_val)); return elapsed; } ``` You need to add the following code in the interrupt service function```c extern __IO uint32_t Ticks; void SysTick_Handler(void) { Ticks++; } ``` 4. Perform chip initialization functions (such as system clock, serial port configuration) in the portable_init function ```c /* Function : portable_init Target specific initialization code Test for some common mistakes. */ void portable_init(core_portable *p, int *argc, char *argv[]) { system_clock_config(); delay_init(); uart_print_init(115200); printf("at32a403a_board hardware_init [ok] _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
#include
#include "coremark.h"
#include "main.h"
#define SysTick_Counter_Disable ((uint32_t)0xFFFFFFFE)//changed
#define SysTick_Counter_Enable ((uint32_t)0x00000001)//changed
#define SysTick_Counter_Clear ((uint32_t)0x00000000)//changed
__IO uint32_t Ticks;//changed
//define ITERATIONS
#define ITERATIONS 5000;//changed
#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;
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{}
}
/* 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.
*/
//changed
//#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 Host specific (POSIX), or target specific global time variables. */
//static CORETIMETYPE start_time_val, stop_time_val;//changed
#define EE_TICKS_PER_SEC 1000.0//changed
/* 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)//changed
{
//GETMYTIME(&start_time_val);
Ticks++;
SysTick_Config(SystemCoreClock / 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)//changed
{
//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 . This
methodology is taken to accomodate any hardware or simulated platform. The
sample implementation returns millisecs by default, and the resolution is
controlled by
*/
CORE_TICKS get_time(void)//changed
{
CORE_TICKS elapsed=(CORE_TICKS) Ticks;//(MYTIMEDIFF(stop_time_val, start_time_val));
return elapsed;
}
/* Function : time_in_secs
Convert the value returned by get_time to seconds.
The type is used to accomodate 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[])
{
system_clock_config();
delay_init();
uart_print_init(115200);
printf("at32a403a_board hardware_init [ok] \r\n");
printf("at_start_a403a board coremark testing 2024-1-29\r\n");
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *))
{
ee_printf(
"ERROR! Please define ee_ptr_int to a type that holds a "
"pointer!\n");
}
if (sizeof(ee_u32) != 4)
{
ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
}
p->portable_id = 1;
}
/* Function : portable_fini
Target specific final code
*/
void
portable_fini(core_portable *p)
{
p->portable_id = 0;
}
```
5. ÓÉÓÚÔ¹¤³ÌÓÐmainº¯Êý£¬core_mainÒ²ÓÐmainº¯Êý£¬ÔòÐèҪעÊ͵õmain.cµÄº¯Êý¡£
6. Ð޸ıàÒëÆ÷°æ±¾ºÍÓÅ»¯µÈ¼¶£¨ÓëMDK¹¤³ÌÉèÖñ£³ÖÒ»Ö£©
7. ±àÒ룬ÏÂÔسÌÐò£¬²âÊÔ