fix stop_cycle_counter() return value overflow issue

This commit is contained in:
Gabriel Wang 2023-03-06 11:40:42 +00:00
parent 58cb54f009
commit 47c8c3be6f
7 changed files with 23 additions and 20 deletions

View File

@ -16,8 +16,8 @@
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
<releases>
<release date="2023-03-03" version="2.1.0-dev" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.1.0-dev.pack">
- Add Coremark
<release date="2023-03-06" version="2.1.0-dev2" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.1.0-dev2.pack">
- Update stop_cycle_counter prototype to solve return-value-overflow issue
</release>
<release date="2023-03-02" version="2.0.0" url="https://github.com/GorgonMeducer/perf_counter/raw/0c6b79b20308bb9b7d15a7c65f0fe91174c78061/cmsis-pack/GorgonMeducer.perf_counter.2.0.0.pack">
- Add Coremark
@ -271,12 +271,12 @@
</Pre_Include_Global_h>
</component>
<component Cgroup="perf_counter" Csub="Benchmark" Cvariant="Coremark" Cversion="1.0.0" condition="perf_counter">
<component Cgroup="perf_counter" Csub="Benchmark" Cvariant="Coremark" Cversion="1.1.0" condition="perf_counter">
<description>Coremark</description>
<files>
<file category="source" name="benchmark/coremark_port/core_main.c"/>
<file category="source" name="benchmark/coremark_port/core_portme.c" attr="config" version="1.0.0" />
<file category="header" name="benchmark/coremark_port/core_portme.h" attr="config" version="1.0.0" />
<file category="source" name="benchmark/coremark_port/core_portme.c" attr="config" version="1.1.0" />
<file category="header" name="benchmark/coremark_port/core_portme.h" attr="config" version="1.1.0" />
<file category="include" name="benchmark/coremark/" />
<file category="source" name="benchmark/coremark/core_list_join.c"/>

View File

@ -65,7 +65,7 @@ volatile ee_s32 seed5_volatile = 0;
extern uint32_t SystemCoreClock;
static volatile CORE_TICKS s_nCycleElapsed = 0;
static volatile CORE_TICKS s_tCycleElapsed = 0;
/* Function : start_time
This function will be called right before starting the timed portion of
@ -91,7 +91,7 @@ start_time(void)
void
stop_time(void)
{
s_nCycleElapsed = stop_cycle_counter();
s_tCycleElapsed = stop_cycle_counter();
}
/* Function : get_time
Return an abstract "ticks" number that signifies time on the system.
@ -105,7 +105,7 @@ stop_time(void)
CORE_TICKS
get_time(void)
{
return s_nCycleElapsed;
return s_tCycleElapsed;
}
/* Function : time_in_secs
Convert the value returned by get_time to seconds.

View File

@ -76,7 +76,7 @@ Original Author: Shay Gal-on
/* Configuration : CORE_TICKS
Define type of return from the timing functions.
*/
typedef int32_t CORE_TICKS;
typedef int64_t CORE_TICKS;
/* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION
Initialize these strings per platform

View File

@ -16,7 +16,10 @@
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
<releases>
<release date="2023-03-02" version="2.0.0" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.0.0.pack">
<release date="2023-03-06" version="2.1.0-dev2" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.1.0-dev2.pack">
- Update stop_cycle_counter prototype to solve return-value-overflow issue
</release>
<release date="2023-03-02" version="2.0.0" url="https://github.com/GorgonMeducer/perf_counter/raw/0c6b79b20308bb9b7d15a7c65f0fe91174c78061/cmsis-pack/GorgonMeducer.perf_counter.2.0.0.pack">
- Add Coremark
</release>
<release date="2023-02-09" version="1.9.11" url="https://github.com/GorgonMeducer/perf_counter/raw/659eb12026977d81391d90290706f9ac3c8efe7e/cmsis-pack/GorgonMeducer.perf_counter.1.9.11.pack">
@ -227,7 +230,7 @@
-->
<components>
<bundle Cbundle="Performance Counter" Cclass="Utilities" Cversion="2.0.0">
<bundle Cbundle="Performance Counter" Cclass="Utilities" Cversion="2.1.0-dev">
<description>A dedicated performance counter for Cortex-M systick.</description>
<doc>documents/Doxygen/html/index.html</doc>
<component Cgroup="perf_counter" Csub="Core" Cvariant="Library" condition="CMSIS-CORE">
@ -268,12 +271,12 @@
</Pre_Include_Global_h>
</component>
<component Cgroup="perf_counter" Csub="Benchmark" Cvariant="Coremark" Cversion="1.0.0" condition="perf_counter">
<component Cgroup="perf_counter" Csub="Benchmark" Cvariant="Coremark" Cversion="1.1.0" condition="perf_counter">
<description>Coremark</description>
<files>
<file category="source" name="benchmark/coremark_port/core_main.c"/>
<file category="source" name="benchmark/coremark_port/core_portme.c" attr="config" version="1.0.0" />
<file category="header" name="benchmark/coremark_port/core_portme.h" attr="config" version="1.0.0" />
<file category="source" name="benchmark/coremark_port/core_portme.c" attr="config" version="1.1.0" />
<file category="header" name="benchmark/coremark_port/core_portme.h" attr="config" version="1.1.0" />
<file category="include" name="benchmark/coremark/" />
<file category="source" name="benchmark/coremark/core_list_join.c"/>

View File

@ -424,11 +424,11 @@ void start_cycle_counter(void)
* \return int32_t the elapsed cycle count
*/
__STATIC_INLINE
int32_t stop_cycle_counter(void)
int64_t stop_cycle_counter(void)
{
int32_t nTemp = (int32_t)(get_system_ticks() - g_lLastTimeStamp);
int64_t lTemp = (get_system_ticks() - g_lLastTimeStamp);
return nTemp - g_nOffset;
return lTemp - g_nOffset;
}
/*!

View File

@ -424,11 +424,11 @@ void start_cycle_counter(void)
* \return int32_t the elapsed cycle count
*/
__STATIC_INLINE
int32_t stop_cycle_counter(void)
int64_t stop_cycle_counter(void)
{
int32_t nTemp = (int32_t)(get_system_ticks() - g_lLastTimeStamp);
int64_t lTemp = (get_system_ticks() - g_lLastTimeStamp);
return nTemp - g_nOffset;
return lTemp - g_nOffset;
}
/*!