Skip to content

dump cudaOccDeviceProp #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions libkineto/src/CudaDeviceProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

#include "CudaDeviceProperties.h"

#include <vector>

#include <cuda_runtime.h>
#include <cuda_occupancy.h>

#include "Logger.h"

Expand Down
4 changes: 4 additions & 0 deletions libkineto/src/CudaDeviceProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@

#pragma once

#include <vector>
#include <stdint.h>
#include <cuda_occupancy.h>

namespace KINETO_NAMESPACE {

const std::vector<cudaOccDeviceProp>& occDeviceProps();

float kernelOccupancy(
uint32_t deviceId,
uint16_t registersPerThread,
Expand Down
31 changes: 31 additions & 0 deletions libkineto/src/output_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,37 @@ void ChromeTraceLogger::handleTraceStart(
"schemaVersion": {},
)JSON", kSchemaVersion);

#ifdef HAS_CUPTI
const std::vector<cudaOccDeviceProp>& occProps = KINETO_NAMESPACE::occDeviceProps();
if (occProps.size() > 0) {
std::ostringstream oss;
oss << "[";
for (size_t i = 0; i < occProps.size(); i += 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i++ or ++i?

const cudaOccDeviceProp& occProp = occProps[i];
if (i > 0) {
oss << ", ";
}
oss << "{";
oss << "\"computeMajor\": " << occProp.computeMajor << ", ";
oss << "\"computeMinor\": " << occProp.computeMinor << ", ";
oss << "\"maxThreadsPerBlock\": " << occProp.maxThreadsPerBlock << ", ";
oss << "\"maxThreadsPerMultiprocessor\": " << occProp.maxThreadsPerMultiprocessor << ", ";
oss << "\"regsPerBlock\": " << occProp.regsPerBlock << ", ";
oss << "\"regsPerMultiprocessor\": " << occProp.regsPerMultiprocessor << ", ";
oss << "\"warpSize\": " << occProp.warpSize << ", ";
oss << "\"sharedMemPerBlock\": " << occProp.sharedMemPerBlock << ", ";
oss << "\"sharedMemPerMultiprocessor\": " << occProp.sharedMemPerMultiprocessor << ", ";
Copy link
Contributor

@guotuofeng guotuofeng May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need we consolidate with device metadata like "id", "name" and "total_memory" in PR pytorch/pytorch#57252?

oss << "\"numSms\": " << occProp.numSms << ", ";
oss << "\"sharedMemPerBlockOptin\": " << occProp.sharedMemPerBlockOptin;
oss << "}";
}
oss << "]";
traceOf_ << fmt::format(R"JSON(
"cudaOccDeviceProps": {},
)JSON", oss.str());
}
#endif // HAS_CUPTI

if (!metadata.empty()) {
traceOf_ << R"JSON(
"metadata": {
Expand Down