Skip to content

Commit

Permalink
Add CUPTI/RoCM versions to traces
Browse files Browse the repository at this point in the history
Summary: Because of the differences that are emerging between different versions, it would be useful in the metadata we could see which third-party library version we are using. We add them to our kineto traces in this diff.

Differential Revision: D62538511
  • Loading branch information
sraikund16 authored and facebook-github-bot committed Sep 12, 2024
1 parent 76f2334 commit b7f637b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
17 changes: 17 additions & 0 deletions libkineto/src/CuptiActivityProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ void CuptiActivityProfiler::logGpuVersions() {
"cuda_runtime_version", std::to_string(cudaRuntimeVersion));
LOGGER_OBSERVER_ADD_METADATA(
"cuda_driver_version", std::to_string(cudaDriverVersion));
addVersionMetadata(
"cupti_version", std::to_string(cuptiVersion));
addVersionMetadata(
"cuda_runtime_version", std::to_string(cudaRuntimeVersion));
addVersionMetadata(
"cuda_driver_version", std::to_string(cudaDriverVersion));

#elif defined(HAS_ROCTRACER)
uint32_t majorVersion = roctracer_version_major();
Expand All @@ -267,13 +273,24 @@ void CuptiActivityProfiler::logGpuVersions() {
"hip_runtime_version", std::to_string(hipRuntimeVersion));
LOGGER_OBSERVER_ADD_METADATA(
"hip_driver_version", std::to_string(hipDriverVersion));
addVersionMetadata(
"roctracer_version", roctracerVersion);
addVersionMetadata(
"hip_runtime_version", std::to_string(hipRuntimeVersion));
addVersionMetadata(
"hip_driver_version", std::to_string(hipDriverVersion));

#endif
}

void CuptiActivityProfiler::processTraceInternal(ActivityLogger& logger) {
LOG(INFO) << "Processing " << traceBuffers_->cpu.size() << " CPU buffers";
VLOG(0) << "Profile time range: " << captureWindowStartTime_ << " - "
<< captureWindowEndTime_;
for (auto& pair : versionMetadata_) {
// We already own mutex here so don't bother locking
addMetadata(pair.first, pair.second, false);
}
logger.handleTraceStart(metadata_);
setCpuActivityPresent(false);
setGpuActivityPresent(false);
Expand Down
14 changes: 12 additions & 2 deletions libkineto/src/CuptiActivityProfiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,18 @@ class CuptiActivityProfiler {
}
}

void addMetadata(const std::string& key, const std::string& value) {
std::lock_guard<std::mutex> guard(mutex_);
void addMetadata(const std::string& key, const std::string& value, bool lock_mutex=true) {
if (lock_mutex){
std::lock_guard<std::mutex> guard(mutex_);
}
metadata_[key] = value;
}

void addVersionMetadata(const std::string& key, const std::string& value) {
std::lock_guard<std::mutex> guard(mutex_);
versionMetadata_[key] = value;
}

void addChildActivityProfiler(
std::unique_ptr<IActivityProfiler> profiler) {
std::lock_guard<std::mutex> guard(mutex_);
Expand Down Expand Up @@ -528,6 +535,9 @@ class CuptiActivityProfiler {
// Trace metadata
std::unordered_map<std::string, std::string> metadata_;

// Version metadata
std::unordered_map<std::string, std::string> versionMetadata_;

// child activity profilers
std::vector<std::unique_ptr<IActivityProfiler>> profilers_;

Expand Down

0 comments on commit b7f637b

Please sign in to comment.