We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
When using gcc to compile c code for ARM platform, we set object platform by using:
-mcpu = xxxxxx
To what extent will that affect results of compiling ?
For example:
-mcpu = cortex-a8
and
-mcpu = cortex-a9
When I use results compiled with -mcpu=cortex-a8 to run on A9 platform, will it cause some problems?
Hello jayzhao,
I am not sure whether the differences are documented or not.
For example, I compared the generated codes of dhrystone benchmark by using GCC4.9.3.
I observed the following 3 points.
1) Immediates are redundantly used by -mcpu=cortex-a9, and Immediates are re-used via registers by -mcpu=cortex-a8.
2) For the same registers, interval (i.e. the number of independent instructions) between the modifying and referring is wider at -mcpu=cortex-a9.
3) Much more registers are used by -mcpu=cortex-a9.
I think these points seem to come from the pipleline features. Cortex-A8 is in-order and Cortex-A9 is out-of-order.
I hope this helps you.
Best regards,
Yasuhiko Koumoto.
It should "work" - i.e. it will run and produce the correct result - both are ARMv7-A architecture cores.
It may not be "optimal" - the main function of setting a specific CPU core is to allow the compiler to schedule code to get the best performance. As Koumoto-san mentions, these two cores are quite different when it comes to their internal micro-architecture, so you may be reducing your peak performance if you don't compile for the right core.
HTH,
Pete
Thank u very much~
What if some are compiled with -mcpu=cortex-a8, and others are compiled with -mcpu=cortex-a9 , and then link them together to generate an ELF file, will that be ok or some conflict may happen?
It would be ok because the calling and receiving conventions for functions don't vary by the cpu specification option.
However, as fot some options (e.g. -msingle-pic-base), linking of objects which will be compiled with or without them would fail.