Skip to content
svtcliPublic

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

41 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

p3em

Permitted, Portable, Parsable Energy Meter for CPUs and GPUs.

  • Native Intel, NVIDIA and AMD GPU via xxx-smi. Native CPU support via perf or likwid
  • Millisecond latency
  • Fortran, C, C++, Python examples provided
  • Encapsulated in unix shell for complete freedom of interface and portability.
  • Add any custom energy meter simply by executing in shell.

Usage

Open p3em.sh, uncomment the right energy meter section for your system (or add your own, see below) to get accumulated energy consumption of your node.

The flexibility and low latency of p3em makes it perfect to profile energy consumption of regions of interest in your of code. If you are at this point, you likely have already your regions of interest marked by your internal code timer. If not, add one right now (for a compact one you may look into this one).

We won't give you yet another API.

Use the one you already have, by instrumenting your timer now() funciton to return energy instead of time. Both quantities are monotonic, additive in intervals, and your timer will zero either variable.

A likely workflow:

  • add p3em as submodule in your repository
  • follow the provided examples (C/Fortran/C++/python) for instrumenting your timer
  • run your code without any change
  • process the performance measures with your usual pipeline.

Environment variables

  • P3EM_ENABLED=1 activates monitoring; otherwise the API returns wall‑clock seconds.
  • P3EM_CPU and/or P3EM_GPU point to up‑to‑two custom meter scripts (you may set one, the other, or both). Use the CPU script for CPU‑related meters and the GPU script for GPU‑related meters, or any combination you prefer.

The same variables drive all interfaces (C, C++, Fortran, Python), so instrumenting a timer is a one‑line change. In Python, for instance:

import p3em

p3em.init()            # reads P3EM_ENABLED / P3EM_CPU / P3EM_GPU; further calls are no-ops
start = p3em.now()     # instead of time.time()
...
print("elapsed:", p3em.now() - start)   # energy when enabled, seconds otherwise

Run the bundled example from the repository root with, e.g. P3EM_ENABLED=1 P3EM_CPU=meters/simple_counter.sh python3 src/python/test_driver.py.

Tip: For simple timing, reuse your existing code’s built‑in timer instead of the mock my_timer.

For further examples you may look at the timer linked above.

Not what you are looking...

  • p3em.sh parses the sample energy meters to yield a running total of consumed energy.
  • The measure is intended at node level (i.e. it yields the sum over all selected devices in a node); node fractions are no fun.
  • The provided energy meters aim only at the device cores , as a proxy of device size for providing properly normalized performance values, directly comparable among devices. See paper (TBA).

Interested in other metrics with different meanings, e.g: global "at the plug" measures? Include memory/disk? Adding CPU and GPU together? See below!

Add your own energy meter

Simply add your own executable or script, written in your favourite language, printing any running total of consumed energy, and lowest possible latency, following the example. Just run p3em.sh and play with it in your shell for visual clarity.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages