慕容雪花 发表于 2024-2-8 18:24

【ST NUCLEO-U5A5ZJ-Q开发板测评】-5-U5A5ZJ-Q Coremark评分

<div class='showpostmsg'><p>在上一篇文章里解决了如何使得HCLK能够达到160MHz的问题,这篇文章记录一下第一次成功使用Coremark来测试一下功能强大的U5A5ZJ-Q的跑分情况。</p>

<p>官方数据手册给出的结果是:655.</p>

<p> &nbsp;</p>

<p>&nbsp;</p>

<p>首先要准备好一个可以正常串口打印的Keil工程。</p>

<p> &nbsp;</p>

<p>接下来一步是下载最新的Coremark源文件:</p>

<div style="text-align: center;"></div>

<p>源码是以压缩包的形式提供的,解压后重要的文件如下:</p>

<p> &nbsp;</p>

<p>&nbsp;</p>

<p>之后把下载后的源码添加到Keil项目,Keil项目由STM32CubeMX自动生成,基本无需任何修改!</p>

<p> &nbsp;</p>

<p>&nbsp;</p>

<p>之后就是最重要的一步:修改core_portme.c</p>

<pre>
<code>/*
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 &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include "main.h"
#include "dcache.h"
#include "icache.h"
#include "memorymap.h"
#include "usart.h"
#include "gpio.h"
#include "coremark.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 unsigned int Tick;
#define ITERATIONS      12000

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 Host specific (POSIX), or target specific global time variables. */
//static CORETIMETYPE start_time_val, stop_time_val;
#define EE_TICKS_PER_SEC         1000

/* 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(&amp;start_time_val);
                Tick = 0;
                HAL_SYSTICK_Config(SystemCoreClock/(1000UL));
}
/* 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(&amp;stop_time_val);
                SysTick-&gt;CTRL &amp;= ~SysTick_CTRL_ENABLE_Msk;
                SysTick-&gt;VAL = 0;
}
/* 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 &lt;time_in_secs&gt;. This
   methodology is taken to accommodate any hardware or simulated platform. The
   sample implementation returns millisecs by default, and the resolution is
   controlled by &lt;TIMER_RES_DIVIDER&gt;
*/
CORE_TICKS
get_time(void)
{
    CORE_TICKS elapsed
                                =(CORE_TICKS)Tick;
      //= (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
    return elapsed;
}
/* Function : time_in_secs
      Convert the value returned by get_time to seconds.

      The &lt;secs_ret&gt; 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;


extern void Board_Init_Main(void);
extern int fputc(int ch, FILE *f);
/* Function : portable_init
      Target specific initialization code
      Test for some common mistakes.
*/
void
portable_init(core_portable *p, int *argc, char *argv[])
{

    (void)argc; // prevent unused warning
    (void)argv; // prevent unused warning
       
                Board_Init_Main();
                printf("\r\nBoard Init Done");
    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-&gt;portable_id = 1;
}
/* Function : portable_fini
      Target specific final code
*/
void
portable_fini(core_portable *p)
{
    p-&gt;portable_id = 0;
}
</code></pre>

<p>&nbsp;</p>

<p>还有一个地方:</p>

<pre>
<code>/**
* <a href="home.php?mod=space&amp;uid=159083" target="_blank">@brief </a> This function handles System tick timer.
*/
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */

/* USER CODE END SysTick_IRQn 0 */
        extern volatile unsigned int Tick;
        Tick++;
HAL_IncTick();
/* USER CODE BEGIN SysTick_IRQn 1 */

/* USER CODE END SysTick_IRQn 1 */
}</code></pre>

<p>还有要把Stack和Heap的值调大:</p>

<p> &nbsp;</p>

<p>之后编译下载:</p>

<div style="text-align: center;"></div>

<div style="text-align: center;">&nbsp;</div>

<div>
<pre>
<code>SysteCoreClock = 160000000

Board Init Done2K performance run parameters for coremark.
CoreMark Size    : 666
Total ticks      : 18503
Total time (secs): 18.503000
Iterations/Sec   : 648.543479
Iterations       : 12000
Compiler version : GCCClang 13.0.0 (ssh://ds-gerrit/armcompiler/llvm-project 1f5770d6f72ee4eba2159092bbf4cbb819be323a)
Compiler flags   : -Omax -LTO
Memory location: STACK
seedcrc          : 0xe9f5
crclist       : 0xe714
crcmatrix   : 0x1fd7
crcstate      : 0x8e3a
crcfinal      : 0xd340
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 648.543479 / GCCClang 13.0.0 (ssh://ds-gerrit/armcompiler/llvm-project 1f5770d6f72ee4eba2159092bbf4cbb819be323a) -Omax -LTO / STACK
</code></pre>

<p>&nbsp;</p>
</div>

<div>&nbsp;</div>

<div>测试得到648.54,与官方的655非常接近了。</div>

<p>&nbsp;</p>
</div><script>                                        var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;"   style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
                                       
                                        if(parseInt(discuz_uid)==0){
                                                                                                (function($){
                                                        var postHeight = getTextHeight(400);
                                                        $(".showpostmsg").html($(".showpostmsg").html());
                                                        $(".showpostmsg").after(loginstr);
                                                        $(".showpostmsg").css({height:postHeight,overflow:"hidden"});
                                                })(jQuery);
                                        }                </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script>

Jacktang 发表于 2024-2-12 09:55

<p>能测试得到648.54确实是不错的精度了</p>

怀揣少年梦 发表于 2024-2-22 11:29

<p>跑分值和官方差不多,性能杠杠的</p>
页: [1]
查看完整版本: 【ST NUCLEO-U5A5ZJ-Q开发板测评】-5-U5A5ZJ-Q Coremark评分