[MAGEEC] Measuring the energy consumption of an LLVM basic block

Simon Cook simon.cook at embecosm.com
Mon Nov 23 11:26:24 GMT 2015

Hi Rasool,

> May I ask how I would be able to measure the energy consumption of one
> basic block?

The way you measure just one basic block depends on what you have
available to you in terms of execution.

Chances are, the device you are running a program on runs much faster
than the energy measuring board can usefully take a sample. What you
would have to do in this case is run the basic block many times in
succession in order to get an energy measurement and then divide back
down to get the energy of running just that block once.

If you run the board in its read mode, where it uses trigger pins, you
may be able to construct a setup like this:

 <... many more times ...>
_stop trigger

You would know how many times your basic block ran between the trigger
points, and be able to work out the energy for your basic block.

Alternatively, if you have a simulator for your target that can give you
an cycle-accurate instruction trace, you might be able to take a more
continuous reading and correlate the trace information to the energy
readings (which could be thought of as an energy trace), and associate
energy that way (e.g. half of the time was spent between sample X and
X+1 on this block, I can therefore that proportion to the energy).

In this case the continuous mode of energytool may be more helpful,
though it's likely you would want to combine this with energy triggers,
in which case writing your own Python script using pyenergy may give you
the best result. In either case, again running the basic block multiple
times would provide a more accurate result.

Hope this helps.

More information about the mageec mailing list