In the CPU time equation (Tcpu) what are the number of instructions (IC) and cycles per instruction (CPI)?

Asked

Viewed 139 times

2

Of a slide about computer organization:

Performance of instructions

A particular programme shall require:

  • a number of machine instructions
  • a certain number of cycles
  • a certain number of seconds

Thus:

Tcpu = IC * CPI * Tempodocyclodeclock

IC = number of machine instructions (Instruction Count)

CPI (cycles per instruction)

I don’t quite understand this one slide.

The IC is the number of machine instructions involved for example in a sum or multiplication operation (the latter is more complex than the sum). It would be the number of most basic instructions that make up an addition statement?

Is CPI a fixed value, or does it vary by instruction? Or is it an average?

Not yet mandatory but if you can add, how does it all affect the performance in executing instructions?

Drawn from here, also here. And this one can also help.

1 answer

3


The cycle is the basic unit of execution, is the minimum step of execution that occurs and the time between one and the other is defined by the mechanism of clock from the computer, so a 4Ghz computer runs about 4 billion cycles in a second. I time between each is obviously the second divided by the number of cycles per second.

Instruction is an operation that performs something that makes sense to the computer and to a human. It’s something that commands the computer to manipulate data in a certain way. It can be an arithmetic, relational calculus, a movement of data in registers and memory, or something like that. It does a minimal full operation.

What I understood to be the IC in this context is the total instructions of a given code, so I would be teaching to calculate a theoretical execution time.

There are architectures that all instructions run with the same amount of cycles and others where each instruction has its own cost, and even the same instruction can vary in each run. In the cases that the cost varies this measure can be an average, just do not know average that since it depends on the context of where you are measuring.

I imagine that this average in this context is calculated by adding up the number of cycles of each of the instructions of the code being observed by dividing by the number of instructions. But part of the equation is multiplying by the number of instructions, so you shouldn’t use the mean, you should just use the sum of cycles. Wikipedia has a formula that you can understand better.

Otherwise I don’t know what that equation is for.

Even using the Wikipedia formula may not work on the architectures that the actual running will determine how many cycles you consume in a given instruction. And depending on the context can be worse, by a number of optimizations that can occur. Theory is useful, but there are cases that it has no relation to practice.

I do a lot of optimization and have never had to do this calculation :) I needed others you might see in these classes. It may be that on a lower level I need the formula (from Wikipedia).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.