Calculate MIPS in assembly language

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
GAT
Member
Member
Posts: 75
Joined: Wed Nov 30, 2011 9:51 pm
Contact:

Calculate MIPS in assembly language

Post by GAT »

What would be the best way to calculate MIPS(Millions of instructions per second) for a CPU in x86 assembly?
d3: virtualizing kernel in progress
https://github.com/WizardOfHaas/d3/
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Calculate MIPS in assembly language

Post by Brendan »

Hi,
GAT wrote:What would be the best way to calculate MIPS(Millions of instructions per second) for a CPU in x86 assembly?
There's only 2 ways:
  • See how many instructions you can do in a fixed amount of time
  • See how long it takes to do a fixed amount of instructions
The main problem is deciding which instructions (3 million "NOPs" per second is going to be very different to 3 million "DIV" instructions per second). You'd want to determine how often each instruction is used in "average" code and use that as the basis for your benchmark so that it indicates what average code can expect. However people have already done that and created a standardised benchmarks (e.g. SPECint) so it'd probably be a good idea to base your code on their work.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: Calculate MIPS in assembly language

Post by Nessphoro »

But wasn't there already a post about that on the Wiki?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Calculate MIPS in assembly language

Post by Brendan »

Hi,
Nessphoro wrote:But wasn't there already a post about that on the Wiki?
I don't think so (I couldn't find one).

There is an article about detecting the CPU speed but that doesn't help when you want instructions per second rather than cycles per second (e.g. consider a 1 GHz CPU that averages 4 instructions per cycle vs. a 4 GHz CPU that averages 1 instruction per cycle).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Calculate MIPS in assembly language

Post by Solar »

A cautious query: What do you need the MIPS for? As Brendan pointed out, it is a very dicey metric...

If you need it to calibrate some busy-loop, the answer is simple: Measure how often the CPU executes your loop in a set amount of time. Ref. BogoMips.
Every good solution is obvious once you've found it.
Post Reply