Skip to content

Commit b073e99

Browse files
zzzariescopybara-github
authored andcommitted
Add normalized_total_op_time_ps (on default dvfs) to opstats.device_op_metrics_db, together with the total_op_time_ps, it will give us a weighted average dvfs multiplier, which can be used to calculate dvfs normalized flops utilization and so on.
- The aggregated dvfs multiplier will be shown in roofline page top as part of the device info, and used for device spec normalization. - The agg dvfs multiplier will also be used a an identifier if dvfs normalization control knobs should be displayed on UI or not. (show the knob with a valid multiplier, which is >0 and <1) PiperOrigin-RevId: 817431887
1 parent 7424479 commit b073e99

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

plugin/xprof/protobuf/op_metrics.proto

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ message OpMetrics {
120120
uint32 occurrences = 3;
121121
// Total time (self + children) in picoseconds.
122122
uint64 time_ps = 7;
123-
// Total time (self + children) in picoseconds normalized to the default
124-
// device capability.
123+
// Total time (self + children) in picoseconds needs to be spent if running on
124+
// the default pstate.
125125
uint64 normalized_time_ps = 27;
126126
// Minimum time (self + children) among all occurrences.
127127
uint64 min_time_ps = 17;
@@ -179,7 +179,7 @@ message PrecisionStats {
179179
}
180180

181181
// A database for OpMetrics.
182-
// Next ID: 16
182+
// Next ID: 17
183183
message OpMetricsDb {
184184
// A bunch of OpMetrics.
185185
repeated OpMetrics metrics_db = 10;
@@ -192,6 +192,9 @@ message OpMetricsDb {
192192
uint64 total_time_ps = 11;
193193
// The total time incurred by OPs in picoseconds.
194194
uint64 total_op_time_ps = 12;
195+
// The weighted average total op time in picoseconds if running all ops on the
196+
// default pstate.
197+
uint64 normalized_total_op_time_ps = 16;
195198
// Precision-related stats.
196199
PrecisionStats precision_stats = 13;
197200
// The below two stats will be different from the total time ps and total op

xprof/convert/op_metrics_db_combiner.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ void OpMetricsDbCombiner::Combine(const OpMetricsDb& src,
136136
dst->set_total_op_time_ps(src.total_op_time_ps() + dst->total_op_time_ps());
137137
dst->set_idle_time_ps(src.idle_time_ps() + dst->idle_time_ps());
138138
dst->set_busy_time_ps(src.busy_time_ps() + dst->busy_time_ps());
139+
dst->set_normalized_total_op_time_ps(src.normalized_total_op_time_ps() +
140+
dst->normalized_total_op_time_ps());
139141
CombinePrecisionStats(src.precision_stats(), dst->mutable_precision_stats());
140142

141143
for (const auto& src_metrics : src.metrics_db()) {

xprof/convert/xplane_to_op_metrics_db_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ TEST(ConvertXPlaneToOpMetricsDb, TpuDeviceOpMetricsDb) {
278278
metrics_db { name: "IDLE" category: "IDLE" }
279279
total_time_ps: 10000
280280
total_op_time_ps: 10000
281+
normalized_total_op_time_ps: 20000
281282
)pb")));
282283
#endif
283284
}

xprof/utils/op_metrics_db_utils.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,19 @@ OpMetricsDb XEventsOpMetricsDbBuilder::Finalize(uint64_t total_time_ps) {
321321
OpMetricsDb XEventsOpMetricsDbBuilder::Finalize() {
322322
OpMetricsDb db;
323323
uint64_t total_op_time_ps = 0;
324+
uint64_t normalized_total_op_time_ps = 0;
324325
for (auto& [program_id, op_metric_by_symbol] : flat_op_metric_) {
325326
for (auto& [symbol_id, op_metrics] : op_metric_by_symbol) {
326327
AdjustFlopsAndBytesAccessed(op_metrics);
327328
total_op_time_ps += op_metrics.self_time_ps();
329+
normalized_total_op_time_ps +=
330+
op_metrics.self_time_ps() *
331+
(op_metrics.normalized_time_ps() * 1.0 / op_metrics.time_ps());
328332
db.add_metrics_db()->Swap(&op_metrics);
329333
}
330334
}
331335
db.set_total_op_time_ps(total_op_time_ps);
336+
db.set_normalized_total_op_time_ps(normalized_total_op_time_ps);
332337
return db;
333338
}
334339

xprof/utils/op_metrics_db_utils_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ TEST(OpMetricsDbTest, AddOpMetric) {
237237
num_cores: 1
238238
}
239239
total_op_time_ps: 300
240+
normalized_total_op_time_ps: 350
240241
)pb")));
241242
#endif
242243
}

0 commit comments

Comments
 (0)