Home > Back-end >  How do you get rid of Hz when calculating MIPS?
How do you get rid of Hz when calculating MIPS?

Time:09-18

I'm learning computer structure. I have a question about MIPS, one of the ways to calculate CPU execution time.

The MIPS formula is as follows.

enter image description here

And if the clock rate is 4 GHz and the CPI is 1. I think MIPS is 4,000hz.

Because It's 4 * 10^9 * Hz / 1 * 10^6.

I don't know if it's right to leave units of Hz.

CodePudding user response:

Hz is 1/s. MIPS is actually "mega instruction / s". To be clear, "Per" is the slash for division: Mega Instructions / Second

4GHz is 4G s⁻¹. Divide that by 1 cycle per instruction... but cycle is period, which is inverse of frequency.

It's not 4000Hz MIPS because the MIPS means "Per second". You wrote 4000 million instruction 1/s 1/s.

You eat the Hz because it's part of the name you are labeling it with.

CodePudding user response:

For any quantity, it's important to know what units it's in. As well as a scale factor (like a parsec is many times longer than an angstrom), units have dimensions, and this is fundamental (at least for physical quantities like time; it can get less obvious when you're counting abstract things).

Those units are both units of length so they have the same dimensions; it's physically meaningful to add or subtract two lengths, or if we divide them then length cancels out and we have a pure ratio. (Obviously we have to take care of the scale factors, because 1 parsec / 1 angstrom isn't 1, it's 3.0856776e 26.)

1 m/s is not the same thing as 1 kg, or as dimensionless 1.


Time (seconds) is a dimension, and we can treat instructions-executed as another dimension. (I'll call it I since there isn't a standard SI unit for it, AFAIK, and one could argue it's not a real physical dimension. That doesn't stop this kind of dimensional analysis from being useful, though.)

Counts (e.g. of clock cycles) can be treated as another dimension, in which case clock frequency is cycles / sec rather than just s-1. (Seconds, s, are the base SI unit of time.) If we want to make sure we're correctly cancelling it out in both sides, that can be a good approach, especially when we have quantities like cycles/instruction (CPI). Thus cycle time is s/c,seconds per cycle.

Hz has dimensions of s-1, so if it's something per second we should not use Hz, if something isn't dimensionless. (Clock frequencies normally are given in Hz, because "cycles" aren't a real unit in physics. That's something we're introducing to make sure everything cancels properly).

MIPS has dimensions of instructions / time (I / s), so the factors that contribute to it must cancel out any cycle counts. And we're not calling it Hz because we're considering "instructions" as a real unit, thus 4000 MIPS not 4000 Hz. (And MIPS is itself a unit so it's definitely not 4000 Hz MIPS).

From your list of formulas, leaving out the factor of 10^6 (that's the M in MIPS, just a metric prefix in front of Instructions Per Sec, I/s)

  • instructions / total time obviously works without needing any cancelling.

  • I / (c * s / c) = I / s after cancelling cycles in the denominator

  • (I * c/s) / (I * c/I) cancel the Instructions in the denominator:
    (I * c/s) / c cancel the cycles:
    (I * 1/s) / 1 = I/s

  • (c/s) / (c/I) cancel cycles:
    (1/s) / (1/I) apply 1/(1/I) = I reciprocal of reciprocal
    (1/s) * I = I / s

All of these have dimensions of Instructions / Seconds, i.e. I/S or IPS. With a scale factor of 106, that's MIPS.


BTW, this is called "dimensional analysis", and in physics (and other sciences) it's a handy tool to see if a formula is sane, because both sides must have the same dimensions.

e.g. if you're trying to remember how position (or distance-travelled) of an accelerating object works, d = 1/2 * a * t^2 works because acceleration is distance / time / time (e.g. m/s^2), and time-squared cancels out the s^-2 leaving just distance. If you mis-remembered something like 1/2 a^2 * t, you can immediate see that's wrong because you'd have dimensions of m / s^4 * s = m / s^3 which is not a unit of distance.

(The factor of 1/2 is not something you can check with dimensional analysis; you only get those constant factors like 1/2, pi, e, or whatever from doing the full math, e.g. taking the derivative or integral, or making geometric arguments about linear plots of velocity vs. time.)

  • Related