From f9b66d2b1ffdeb564790f9c0b54e7dfff97a5edf Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 11 Sep 2023 12:10:12 -0500 Subject: [PATCH] Update babeltrace_thapi.in --- utils/babeltrace_thapi.in | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/utils/babeltrace_thapi.in b/utils/babeltrace_thapi.in index f3cf9e3a..48940221 100755 --- a/utils/babeltrace_thapi.in +++ b/utils/babeltrace_thapi.in @@ -160,18 +160,20 @@ def get_components(names) require 'babeltrace_cuda_lib' if $options[:backends].include?('cuda') require 'babeltrace_hip_lib' if $options[:backends].include?('hip') # I guess need to put it in `babeltrace_energy_lib` at some point? - $energies={} - $event_lambdas["lttng_ust_ze_sampling:gpu_energy"] = lambda { |defi| - energy = defi['energy'] - timestamp = defi['timestamp'] - key = [ defi['hDevice'], defi['domain'] ] - previous = $energies[key] - if previous - p_energy, p_timestamp = previous - puts "#{key[0]}:#{key[1]}: #{(energy - p_energy).to_f/(timestamp - p_timestamp)}" - end - $energies[key] = [energy, timestamp] - } if $options[:backends].include?('ze') + if $options[:backends].include?('ze') + $energies={} + $event_lambdas["lttng_ust_ze_sampling:gpu_energy"] = lambda { |defi| + energy = defi['energy'] + timestamp = defi['timestamp'] + key = [ defi['hDevice'], defi['domain'] ] + previous = $energies[key] + if previous + p_energy, p_timestamp = previous + puts "#{key[0]}:#{key[1]}: #{(energy - p_energy).to_f/(timestamp - p_timestamp)}" + end + $energies[key] = [energy, timestamp] + } + end f = lambda { |iterator, _| iterator.next_messages.each do |m|