SWDEV-422207 - Report kernel names for activity profiling

- Report kernel names for optimized graph path
- Refactor code so that we store profiling info in Accumulate command

Change-Id: Ib97735a0239aeb9fc3a50a4bb7126dd0bcadc8af


[ROCm/clr commit: b056686607]
Este commit está contenido en:
Saleel Kudchadker
2023-11-15 04:27:56 +00:00
padre 153bb15f46
commit cb9a715e04
Se han modificado 5 ficheros con 55 adiciones y 21 borrados
+6 -2
Ver fichero
@@ -101,10 +101,14 @@ void ReportActivity(const amd::Command& command) {
break;
}
if (command.profilingInfo().tsList_.size() > 0) {
for (auto& it : command.profilingInfo().tsList_) {
if (command.type() == CL_COMMAND_TASK) {
auto timestamps = static_cast<const amd::AccumulateCommand&>(command).getTimestamps();
for (uint32_t i = 0; i < timestamps.size(); i++) {
auto it = timestamps[i];
record.begin_ns = it.first;
record.end_ns = it.second;
record.kernel_name =
static_cast<const amd::AccumulateCommand&>(command).getKernelNames()[i].c_str();
function(ACTIVITY_DOMAIN_HIP_OPS, operation_id, &record);
}
} else {
+34 -14
Ver fichero
@@ -105,7 +105,7 @@ class Event : public RuntimeObject {
struct ProfilingInfo {
ProfilingInfo(bool enabled = false)
: enabled_(enabled), marker_ts_(false), multiple_ts_(false) {
: enabled_(enabled), marker_ts_(false) {
if (enabled) {
clear();
correlation_id_ = activity_prof::correlation_id;
@@ -116,20 +116,17 @@ class Event : public RuntimeObject {
uint64_t submitted_;
uint64_t start_;
uint64_t end_;
std::vector<std::pair<uint64_t, uint64_t>> tsList_;
uint64_t correlation_id_;
bool enabled_; //!< Profiling enabled for the wave limiter
bool marker_ts_; //!< TS marker
bool multiple_ts_; //!< Multiple TS
void clear() {
queued_ = 0ULL;
submitted_ = 0ULL;
start_ = 0ULL;
end_ = 0ULL;
tsList_.clear();
}
}
} profilingInfo_;
//! Construct a new event.
@@ -225,11 +222,6 @@ class Event : public RuntimeObject {
//! Set release scope for the event
void setEventScope(int32_t scope) { event_scope_ = scope; }
//! Add a timestamp to the list
void AddTimeStamps(uint64_t start, uint64_t end) {
profilingInfo_.tsList_.push_back(std::make_pair(start, end));
}
};
union CopyMetadata {
@@ -1263,17 +1255,45 @@ class Marker : public Command {
class AccumulateCommand : public Command {
private:
uint8_t* lastPacket_;
//! Kernel names and timestamps list for activity profiling
std::vector<std::string> kernelNames_;
std::vector<std::pair<uint64_t, uint64_t>> tsList_;
public:
//! Create a new Marker
AccumulateCommand(HostQueue& queue, const EventWaitList& eventWaitList = nullWaitList,
const Event* waitingEvent = nullptr, uint8_t* lastPacket = nullptr)
: Command(queue, CL_COMMAND_TASK, eventWaitList, 0, waitingEvent),
lastPacket_(lastPacket)
{
profilingInfo_.multiple_ts_ = true;
}
// Return last packet
{}
//! Return last packet
uint8_t* getLastPacket() const { return lastPacket_; }
//! Add kernel name to the list if available
void addKernelName(const std::string& kernelName) {
if (activity_prof::IsEnabled(OP_ID_DISPATCH)) {
kernelNames_.push_back(kernelName);
}
}
//! Add kernel timestamp to the list if available
void addTimestamps(uint64_t startTs, uint64_t endTs) {
if (activity_prof::IsEnabled(OP_ID_DISPATCH)) {
tsList_.push_back(std::make_pair(startTs, endTs));
}
}
//! Return the kernel names
const std::vector<std::string>& getKernelNames() const {
return kernelNames_;
}
//! Return the kernel timestamps
const std::vector<std::pair<uint64_t, uint64_t>>& getTimestamps() const {
return tsList_;
}
//! The command implementation
virtual void submit(device::VirtualDevice& device) {
device.submitAccumulate(*this);