superstar_gu 发表于 2021-1-19 16:58

【GD32E503评测】GD32E503VET6 性能测试

<p>2.4&nbsp;&nbsp; &nbsp;GD32E503VET6 性能测试<br />
2.4.1&nbsp;&nbsp; &nbsp;指标初步分析<br />
使用GD32E503开发产品,研发工程师基本会考虑两个指标:功耗和性能。<br />
功耗非常难算的,而且跟硬件使用频率、环境及程序等相关。按照功能接口把单片机的功耗按照下面的划分:内部功耗(与频率有关)、数字输入输出口、输入口、模拟接口等。我们直接引用GD32E5032 datasheet资料,查询资料如下:<br />
&nbsp;<br />
&nbsp;<br />
如何综合考虑GD32E503各方面性能?在嵌入式处理器领域,常见测试CPU性能方法有:Dhrystone 和 CoreMark。Dhrystone方法陈旧,且 一直没有更新,我也没有没有移植成功,因此本文将借助于CoreMark测试方法。<br />
CoreMark标准于2009年由EEMBC组织的Shay Gla-On提出,并且试图将其发展成为工业标准,从而代替陈旧的Dhrystone标准。<br />
CoreMark is a simple, yet sophisticated benchmark that is designed specifically to test the functionality of a processor core. Running CoreMark produces a single-number score allowing users to make quick comparisons between processors.<br />
CoreMark跑分是通过运行C语言代码得出来的分数。主要包含如下的运算法则:列举(寻找并排序),数学矩阵操作(普通矩阵运算)和状态机(用来确定输入流中是否包含有效数字),最后还包括CRC(循环冗余校验)。<br />
2.4.2&nbsp;&nbsp; &nbsp;CoreMark核心程序<br />
参考CoreMark官网信息,地址:https://www.eembc.org/coremark/index.php<br />
最新版本是1.0。<br />
&nbsp;<br />
2.4.3&nbsp;&nbsp; &nbsp;兆易创新(GigaDevice)官方开发包<br />
下载兆易创新(GigaDevice) GD32E50x_Demo<br />
&nbsp;<br />
2.4.4&nbsp;&nbsp; &nbsp;集成开发环境为IAR EWARM<br />
&nbsp;<br />
Fig 33 IAR版本示意图<br />
2.4.5&nbsp;&nbsp; &nbsp;移植CoreMark程序<br />
首先,选择一个完整的模板,以demo例程中,串口例程04_USART_Printf 为模板进行配置,简化了配置过程。<br />
&nbsp;<br />
Fig 34 开发板UART0原理图<br />
由于GD32E503V-EVAL开发板核心芯片GD32E503VET6的处理器操作频率最高位180MHz,推荐将主频设定在180M。我没有修改。<br />
将初始化时的堆栈改大一些,否则会出现问题,默认的都是0X00000800,这里我改成了0X00002000。<br />
开启 options &gt; linker &gt;Override default &gt; Edit,修改为:0x2000&nbsp;&nbsp;<br />
新建Coremark文件夹,添加Coremark程序<br />
&nbsp;<br />
在工程里添加文件,并包含头文件路径<br />
&nbsp;<br />
(1)&nbsp;&nbsp; &nbsp;Core_portme.c 添加初始化代码<br />
1)&nbsp;&nbsp; &nbsp;portable_init 函数<br />
Core_portme.c 中的 portable_init 函数在 Core_main.c 的 main 函数中首先被调用, 平台的初始化的函数(时钟, GPIO, 串口) 可以放在这里。 将Main 函数中的初始化代码复制到 portable_init 函数中。<br />
&nbsp;<br />
2)&nbsp;&nbsp; &nbsp;添加变量和函数<br />
#define SysTick_Counter_Disable &nbsp; ((uint32_t)0xFFFFFFFE)<br />
#define SysTick_Counter_Enable &nbsp; &nbsp;((uint32_t)0x00000001)<br />
#define SysTick_Counter_Clear &nbsp; &nbsp; ((uint32_t)0x00000000)<br />
__IO uint32_t Tick;<br />
3)&nbsp;&nbsp; &nbsp;添加头文件<br />
&nbsp;<br />
4)&nbsp;&nbsp; &nbsp;删除main函数,因为Core_main.c有main函数<br />
5)&nbsp;&nbsp; &nbsp;修改计时器代码<br />
start_time/ stop_time/ get_time 这几个函数,是 coremark 程序运行时计算程序运行时间所用。 这里使用 system tick 进行计时, system tick 配置为 1ms 的中断间隔。 system tick 中断函数中更新 Tick 的值,每进一次中断加 1。 所以还需要修改system tick 的中断处理函数。 Core_portme.c 中按下表找到需要修改的地方<br />
start_time(void)<br />
{<br />
&nbsp; &nbsp; //GETMYTIME(&amp;start_time_val);<br />
&nbsp; &nbsp; Tick=0;<br />
&nbsp; &nbsp; SysTick_Config(SystemCoreClock/1000);<br />
}<br />
stop_time(void)<br />
{<br />
&nbsp; &nbsp; //GETMYTIME(&amp;stop_time_val);<br />
&nbsp; &nbsp; SysTick-&gt;CTRL&amp;=SysTick_Counter_Disable;<br />
&nbsp; &nbsp; SysTick-&gt;VAL=SysTick_Counter_Clear;<br />
&nbsp;&nbsp;<br />
}<br />
get_time(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;CORE_TICKS elapsed=(CORE_TICKS)Tick;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return elapsed;<br />
}<br />
6)&nbsp;&nbsp; &nbsp;注释无用语句<br />
//#define NSECS_PER_SEC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CLOCKS_PER_SEC<br />
//#define CORETIMETYPE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clock_t<br />
//#define GETMYTIME(_t) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*_t = clock())<br />
//#define MYTIMEDIFF(fin, ini) &nbsp; &nbsp; &nbsp; ((fin) - (ini))<br />
//#define TIMER_RES_DIVIDER &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<br />
//#define SAMPLE_TIME_IMPLEMENTATION 1</p>

<p>//static CORETIMETYPE start_time_val, stop_time_val;<br />
7)&nbsp;&nbsp; &nbsp;其他<br />
#define EE_TICKS_PER_SEC 1000&nbsp;</p>

<p class="MsoBodyText" style="margin-bottom:13px; margin-left:36px"><span style="font-size:11.5pt"><span style="font-family:&quot;Gill Sans MT&quot;,sans-serif"><span style="font-family:华文中宋">关联</span>printf<span style="font-family:华文中宋">函数</span></span></span></p>

<p class="MsoBodyText" style="margin-bottom:13px; margin-left:36px"><span style="font-size:11.5pt"><span style="font-family:&quot;Gill Sans MT&quot;,sans-serif">/* retarget the C library printf function to the USART */</span></span></p>

<p class="MsoBodyText" style="margin-bottom:13px; margin-left:36px"><span style="font-size:11.5pt"><span style="font-family:&quot;Gill Sans MT&quot;,sans-serif">int fputc(int ch, FILE *f)</span></span></p>

<p class="MsoBodyText" style="margin-bottom:13px; margin-left:36px"><span style="font-size:11.5pt"><span style="font-family:&quot;Gill Sans MT&quot;,sans-serif">{</span></span></p>

<p class="MsoBodyText" style="margin-bottom:13px; margin-left:36px"><span style="font-size:11.5pt"><span style="font-family:&quot;Gill Sans MT&quot;,sans-serif">&nbsp;&nbsp;&nbsp; usart_data_transmit(EVAL_COM0, (uint8_t)ch);</span></span></p>

<p class="MsoBodyText" style="margin-bottom:13px; margin-left:36px"><span style="font-size:11.5pt"><span style="font-family:&quot;Gill Sans MT&quot;,sans-serif">&nbsp;&nbsp;&nbsp; while (RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TBE));</span></span></p>

<p class="MsoBodyText" style="margin-bottom:13px; margin-left:36px"><span style="font-size:11.5pt"><span style="font-family:&quot;Gill Sans MT&quot;,sans-serif">&nbsp;&nbsp;&nbsp; return ch;</span></span></p>

<p class="MsoBodyText" style="margin-bottom:13px; margin-left:36px"><span style="font-size:11.5pt"><span style="font-family:&quot;Gill Sans MT&quot;,sans-serif">}</span></span></p>

<p>(2)&nbsp;&nbsp; &nbsp;修改systick.c函数</p>

<p></p>

<p>(3)&nbsp;&nbsp; &nbsp;运行配置<br />
CoreMark 要求程序运行的最短时间至少是 10s, 根据使用的系统时钟等情况,可以在 Core_portme.h 中修改迭代次数。<br />
#define ITERATIONS 12000<br />
(4)&nbsp;&nbsp; &nbsp;CoreMark运行配置<br />
1)&nbsp;&nbsp; &nbsp;设置迭代次数<br />
CoreMark要求程序运行的最短时间至少是10s, 根据使用的系统时钟等情况,可以在Core_portme.h中修改迭代次数。<br />
#define ITERATIONS 12000<br />
2)&nbsp;&nbsp; &nbsp;设置打印信息<br />
根据具体所用的编译器版本,优化配置进行修改。在Core_portme.h中修改<br />
找到 COMPILER_FLAGS修改为&nbsp;<br />
&nbsp;#ifndef COMPILER_FLAGS&nbsp;<br />
#define COMPILER_FLAGS &quot;-Ohs -no_size_constraints&quot;&nbsp;<br />
#endif&nbsp;</p>

<p>3)&nbsp;&nbsp; &nbsp;优化等级<br />
&nbsp;<br />
&nbsp;&nbsp;</p>

<p>2.4.6&nbsp;&nbsp; &nbsp;CoreMark结果</p>

<p>(我没有修改主频,结果如下;)<br />
2K performance run parameters for coremark.<br />
CoreMark Size &nbsp; &nbsp;: 666<br />
Total ticks &nbsp;: 23833<br />
Total time (secs): 23.833000<br />
Iterations/Sec &nbsp; : 503.503546<br />
Iterations &nbsp; : 12000<br />
Compiler version : Please put compiler version here (e.g. gcc 4.1)<br />
Compiler flags &nbsp; : -Ohs -no_size_constraints<br />
Memory location &nbsp;: STACK<br />
seedcrc : 0xe9f5<br />
&nbsp;crclist &nbsp; &nbsp; &nbsp; : 0xe714<br />
&nbsp;crcmatrix &nbsp; &nbsp; : 0x1fd7<br />
&nbsp;crcstate &nbsp; &nbsp; &nbsp;: 0x8e3a<br />
&nbsp;crcfinal &nbsp; &nbsp; &nbsp;: 0xd340<br />
&nbsp;Correct operation validated. See README.md for run and reporting rules.<br />
&nbsp; CoreMark 1.0 : 503.503546 / Please put compiler version here<br />
&nbsp;(e.g. gcc 4.1) -Ohs -no_size_constraints / STACK</p>

<p>&nbsp;</p>

w494143467 发表于 2021-1-19 20:11

<p>感谢分享!</p>
页: [1]
查看完整版本: 【GD32E503评测】GD32E503VET6 性能测试