views:

182

answers:

5

I have a big problem. My boss said to me that he wants two "magic black box": 1- something that receives a micropocessor like input and return, like output, the MIPS and/or MFLOPS. 2- something that receives a c code like input and return, like output, something that can characterize the code in term of performance (something like the necessary MIPS that a uP must have to execute the code in some time).

So the first "black box" I think could be a benchmark of EEMBC or SPEC...different uP, same benchmark that returns MIPS/MFLOPS of each uP. The first problem is OK (I hope)

But the second...the second black box is my nightmare...the only thingh that i find is to use profiling tool but I ask a particular profiling tool. Is there somebody that know a profiling tool that can have, like input, simple c code and gives me, like output, the performance characteristics of my c code (or the times that some assembly instruction is called)?

The real problem is that we must choose the correct uP for a certai c code...but we want a uP tailored for our c code...so if we know a MIPS (and architectural structure of uP, memory structure...) and what our code needed

Thanks to everyone

A: 

No. If someone made a tool that could analyse (non-trivial) source code and tell you its performance characteristics, it would be common place. i.e. everyone would be using it.

Until source code is compiled for a particular target architecture, you will not be able to determine its overall performance. For instance, a parallelising compiler targeting n processors might conceivably be able to change an O(n^2) algorithm to one of O(n).

Mitch Wheat
Dear Mitch Wheat,thank so much,but i would make a new question...when i looked for profiling tools i've seen simics...do you it? I think that this tool could be good to obtain something information about performance for different uP...do you think the samwe or not?Thanks in advanceMarco
Marco Scappatura
A: 

Dear Mitch Wheat, thank so much, but i would make a new question... when i looked for profiling tools i've seen simics...do you it? I think that this tool could be good to obtain something information about performance for different uP...do you think the samwe or not? Thanks in advance Marco

Marco Scappatura
A: 

You won't find a tool to do what you want.

Your only option is to cross-compile the code and profile it on an emulator for the architecture you're running. The problem with profiling high level code is the compiler makes a stack of optimizations that are non trivial and you'd need to know how the particular compiler did that.

It sounds dumb, but why do you want to fit your code to a uP and a uP to your code? If you're writing signal processing buy a DSP. If you're building a SCADA box then look into Atmel or ARM stuff. Are you building a general purpose appliance with a user interface? Look into PPC or X86 compatible stuff.

Simply put, choose a bloody architecture that's suitable and provides the features you need. Optimization before choosing the processor is retarded (very roughly paraphrasing Knuth).

Fix the architecture at something roughly appropriate, work out roughly the processing requirements (you can scratch up an estimate by hand which will always be too high when looking at C code) and buy a uP to match.

Adam Hawes
A: 

Dear Adam,

thanks for your answer.

My boss asks this type of tool...the problem is: I have a c code and during a meeting a engineer ask the MIPS of this code...My face was so...strange...because MIPS is uP characteristic non software characteristic ( it is somethingh like speak about the performance of a PC in term of Km/h)...so the problem will be to have a code and the performance of this code...not relative performance but absolute performance.

The only solution I've seen is to characterized code with profiling tool that can consider also the instruction set of different uP so I think that simics is a good solution. But i never used SIMICS so i ask if somebody knows this tool...

Thanks

Marco

Marco Scappatura
The only way you can do this properly is compile and run the code on all of the processors you're evaluating. Break it down into number of add/sub and mul/div as well as conditionals. That's a good estimator.
Adam Hawes
A: 

Hello Marco,

I have to agree with Adam, though I would be a little more gracious about it. Compiler optimizations only matter in hotspot code, i.e. tight loops that a) don't call functions, and b) take a large percentage of time.

On a positive note, here's what I would suggest:

  • Run the C code on a processor, any processor. On that processor, find out what takes the most time.

You could use a profiler for this. The simple method I prefer is to just run it under a debugger and manually halt it, some number of times (like 10) and each time write down the call stack. I suppose there is something in the code taking a good percentage of the time, like 50%. If so, you will see it doing that thing on roughly that percentage of samples, so you won't have to guess what it is.

  • If that activity is something that would be helped by some special processor, then try that processor.

It is important not to guess. If you say "I think this needs a DSP chip", or "I think it needs a multi-core chip", that is a guess. The guess might be right, but probably not. It is probably the case that what takes the most time is something you never would guess, like memory management or I/O formatting. Performance issues are very good at hiding from you.

Mike Dunlavey