Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21611 Discussions

gnu profiler for Nios application, which compiler optimization level to choose

Altera_Forum
Honored Contributor II
1,732 Views

I'm trying to use the gprof as described in the AN391, and I'm not sure how to handle the compiler optimization flag -O, 

should I set it both in BSP and in Nios application ? 

in the AN391 it's recommended ("a must") to use -O3 for the application, 

but I get more reasonable results when I set only BSP to -O3 and switch optimization off for the application, 

the application is a simple AES encode & decode 

 

Quartus 12.1 

DE-1 eval. board Cyclone-II
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
973 Views

You have to think about what you are trying to measure. 

The usual reason for considering profiling something is because you want to make it run faster - and profiling might identify the slow parts that are worth further investigation. 

You'll get a big gain from using -O3, so there is no point profiling without it, you'll be measuing something else. 

 

Profiling isn't necessarily the best tool for optimising simple algorithms. I would consider looking at how many clocks it takes to get from the start to various intermediate points, and then the end. That will give more stable results than timer-tick based profiling, although the effects of instruction and data caches, and the branch predictor state will still give some variation. 

 

Speeding up AES probably needs careful inspection of the generated code, and possibly the addition of some 'helper' custom instructions.
0 Kudos
Altera_Forum
Honored Contributor II
973 Views

 

--- Quote Start ---  

 

but I get more reasonable results when I set only BSP to -O3 and switch optimization off for the application, 

the application is a simple AES encode & decode 

 

--- Quote End ---  

 

 

That sounds like a bug in your software that maybe you should look into. 

However, if you want to defer looking into it, what you can do is just change the compiler settings for the source files which have your core AES algorithm in them. 

If you continue to get incorrect results, you'll have to look into that.
0 Kudos
Reply