size optimization of coremark code causes shorter execution time than speed optimization

265 views
Skip to first unread message

Peter

unread,
May 3, 2012, 2:31:04 AM5/3/12
to CoreMark
Hello CoreMark group,

my name is Peter and I'm working on my Bachelor Thesis.

I have detected a inconsistency by executing the coremark at a
Freescale PowerPC MPC5607B.

How you can read in the subject above, i have compiled and linked the
coremark code with several optimization settings. I have optimized the
code in regard to a smaller size and to a shorter execution time. I
have used the Freescale CodeWarrior IDE 5.9.0 with the related
Metrowerks Compiler.

The result for maximum size optimized code is: 97,18 or 1,51/MHz
The result for maximum speed optimized code is: 87,48 or 1,36/MHz

Does anybody have an idea what fact cause these results?

Many thanks!

Peter

Shay Gal-On

unread,
May 3, 2012, 11:49:36 AM5/3/12
to Peter, CoreMark
Hello Peter,

When you tell the compiler to optimize for speed, it makes a best effort to
get the best performance, and when you use size optimizations, it still
optimizes the code for performance, but takes code size into account.
The fact you get 10% faster code by choosing size optimization is not really
all that surprising, but you should definitely write to the compiler team,
as it indicates that they can improve their performance optimization
heuristics.
Remember that a C compiler is simply a program that translates the C source
code to machine language. That translation relies on analysis and heuristics
to get the best performance and code size.
The "for speed" and "for size" are simply shortcuts for specific default
heuristics, but compiler have flags that control the heuristics much more
and you can take advantage of those flags to get the most out of your
software.
Check the Metrowerks user manual for compiler flags for more details.

Thanks,
- Shay Gal-On

Dir. Software Engineering, EEMBC
www.eembc.org/contact
--
You received this message because you are subscribed to the Google Groups
"CoreMark" group.
To post to this group, send email to core...@googlegroups.com.
To unsubscribe from this group, send email to
coremark+u...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/coremark?hl=en.



Bruno Richard

unread,
May 3, 2012, 11:51:26 AM5/3/12
to CoreMark
Hi Peter,

I wrote a short note about this some time ago: Why is my code smaller when compiled in speed optimization mode?

I hope this helps,
--
Bruno Richard  +33 (6) 03 60 66 95



2012/5/3 Peter <Pie...@web.de>

Peter

TRIVIKRAM CHOUDHURY

unread,
Aug 2, 2020, 2:06:36 AM8/2/20
to EEMBC CoreMark Public Group
Hi Bruno,
The link you have posted seems to have expired. Can you upload an updated link to the article?
Thanks in advance.
Trivikram Choudhury

Bruno Richard

unread,
Aug 3, 2020, 2:09:45 PM8/3/20
to TRIVIKRAM CHOUDHURY, EEMBC CoreMark Public Group
Hello Trivikram,

I have not been able to find the reference to my initial article. I am no longer part of the Raisonance company and Google did not help much.
Out of my mind, the idea is that when in speed optimization code all the code gets inlined, even the code for basic arithmetic. So for example long++ will be executed through inline assembly instructions. In size optimization mode, a call to a C library function will be executed instead. There are many such functions on a 8-bit MCU, as its instruction set  is not designed for 16 or 32-bit objects handling (which is what C requires).
So if such functions are only called once in an application, their overhead will make the code slower and bigger.

When you measure the size of an application on 8-bit MCUs, it is usually better to measure only the size of your code but exclude the size of the C library functions.
I hope this helps.
--
Bruno Richard  +33 6 03 60 66 95


You received this message because you are subscribed to the Google Groups "EEMBC CoreMark Public Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coremark+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coremark/8b66b0c1-d1b4-48b7-a7ff-8c2bfa5d2f69n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages