src/profile_report.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | // The device-neutral half of profile_end() (profile.h): each backend that ran | ||
| 4 | // work in the session hands over what its GPU did, as timed activities, and | ||
| 5 | // this turns them into the report: the GPU's span, busy time and idle gaps, | ||
| 6 | // then a table per op (calls, time, idle just before it, fill, achieved | ||
| 7 | // TFLOP/s and GB/s against the device's peaks where the op reported its work) | ||
| 8 | // and the heaviest shapes of the ops that name them. | ||
| 9 | |||
| 10 | #include <cstdint> | ||
| 11 | #include <string> | ||
| 12 | #include <vector> | ||
| 13 | |||
| 14 | namespace brotensor::detail::prof { | ||
| 15 | |||
| 16 | // One kernel, copy or fill as the GPU timed it. | ||
| 17 | struct Activity { | ||
| 18 | std::string name; | ||
| 19 | std::uint64_t start_ns = 0; // any common origin | ||
| 20 | std::uint64_t end_ns = 0; | ||
| 21 | bool has_work = false; // flops / bytes are known | ||
| 22 | double flops = 0.0; | ||
| 23 | double bytes = 0.0; | ||
| 24 | bool tc = false; // the flops ran on the tensor cores | ||
| 25 | std::string shape; // optional tag the op named | ||
| 26 | double fill = -1.0; // share of the GPU's resident slots its waves filled; < 0 unknown | ||
| 27 | }; | ||
| 28 | |||
| 29 | // Device peaks, 0 where unknown (the %pk columns then show "-"). | ||
| 30 | struct Peaks { | ||
| 31 | double fp32 = 0.0; // FLOP/s | ||
| 32 | double tc = 0.0; // FLOP/s | ||
| 33 | double bw = 0.0; // DRAM bytes/s | ||
| 34 | }; | ||
| 35 | |||
| 36 | // `head`: the backend's device and peaks lines; `host`: its host-side line(s), | ||
| 37 | // printed after the GPU line. Times and counts divide by `iterations`. | ||
| 38 | std::string render(const std::string& head, const std::string& host, std::vector<Activity> acts, | ||
| 39 | const Peaks& peaks, int iterations); | ||
| 40 | |||
| 41 | void appendf(std::string& out, const char* fmt, ...); | ||
| 42 | |||
| 43 | } // namespace brotensor::detail::prof | ||
| 44 |