Skip to content

Commit

Permalink
Update PMTObserver for latest PMT changes
Browse files Browse the repository at this point in the history
  • Loading branch information
csbnw committed Jun 5, 2024
1 parent 13429e2 commit 3737052
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/cuda/vector_add_observers_pmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def tune():
tune_params = dict()
tune_params["block_size_x"] = [128+64*i for i in range(15)]

pmtobserver = PMTObserver(["nvml", "rapl"])
pmtobserver = PMTObserver(["nvidia", "rapl"])

metrics = OrderedDict()
metrics["GPU W"] = lambda p: p["nvml_power"]
metrics["GPU W"] = lambda p: p["nvidia_power"]
metrics["CPU W"] = lambda p: p["rapl_power"]

results, env = tune_kernel("vector_add", kernel_string, size, args, tune_params, observers=[pmtobserver], metrics=metrics, iterations=32)
Expand Down
8 changes: 5 additions & 3 deletions kernel_tuner/observers/pmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ def __init__(self, observable=None):
else:
# User specifices a string (single platform) as observable
observable = {observable: None}
supported = ["arduino", "jetson", "likwid", "nvml", "rapl", "rocm", "xilinx"]
supported = ["powersensor2", "powersensor3", "nvidia", "likwid", "rapl", "rocm", "xilinx"]
for obs in observable.keys():
if not obs in supported:
raise ValueError(f"Observable {obs} not in supported: {supported}")

print(observable.items())
self.pms = [pmt.get_pmt(obs[0], obs[1]) for obs in observable.items()]
self.pm_names = list(observable.keys())

Expand All @@ -70,8 +71,9 @@ def after_finish(self):
for i in range(len(self.pms)):
begin_state = self.begin_states[i]
end_state = end_states[i]
measured_energy = pmt.joules(begin_state, end_state)
measured_power = pmt.watts(begin_state, end_state)
measured_energy = pmt.pypmt.PMT.joules(begin_state, end_state)
measured_power = pmt.pypmt.PMT.watts(begin_state, end_state)
print(measured_energy, measured_power)
pm_name = self.pm_names[i]
energy_result_name = f"{pm_name}_energy"
power_result_name = f"{pm_name}_power"
Expand Down

0 comments on commit 3737052

Please sign in to comment.