Skip to content

Commit 606afc4

Browse files
authored
Drop support for CUDA 10.1; Enable support for CUDA 12.4 by eliminating NVPA_MetricsContext (#68)
1 parent 88880fc commit 606afc4

File tree

1 file changed

+1
-41
lines changed

1 file changed

+1
-41
lines changed

cpp/src/cuda/new_cupti_profiler.cpp

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ namespace {
3636
class ProfilingSession {
3737
public:
3838
ProfilingSession(
39-
NVPA_MetricsContext* metrics_context,
4039
const std::string& chip_name,
4140
const std::string& metric,
4241
int num_kernels,
@@ -54,7 +53,6 @@ class ProfilingSession {
5453
CUpti_ProfilerReplayMode profiler_replay_mode_;
5554
CUpti_ProfilerRange profiler_range_;
5655
const std::string& metric_;
57-
NVPA_MetricsContext* metrics_context_;
5856
const std::string& chip_name_;
5957
int num_kernels_;
6058

@@ -67,7 +65,6 @@ class ProfilingSession {
6765
};
6866

6967
ProfilingSession::ProfilingSession(
70-
NVPA_MetricsContext* metrics_context,
7168
const std::string& chip_name,
7269
const std::string& metric,
7370
int num_kernels,
@@ -76,7 +73,6 @@ ProfilingSession::ProfilingSession(
7673
: profiler_replay_mode_(CUPTI_KernelReplay),
7774
profiler_range_(CUPTI_AutoRange),
7875
metric_(metric),
79-
metrics_context_(metrics_context),
8076
chip_name_(chip_name),
8177
num_kernels_(num_kernels),
8278
image_prefix_(image_prefix),
@@ -169,13 +165,8 @@ void ProfilingSession::stopProfiling() {
169165

170166
std::vector<habitat::cuda::KernelMetric> ProfilingSession::getMeasuredMetrics() {
171167
std::vector<NV::Metric::Eval::MetricNameValue> metric_name_value_map;
172-
#if (CUDA_VERSION == 10010)
173-
bool succeeded = NV::Metric::Eval::GetMetricGpuValue(
174-
metrics_context_, chip_name_, counter_data_image_, {metric_}, metric_name_value_map);
175-
#elif (CUDA_VERSION >= 10020)
176168
bool succeeded = NV::Metric::Eval::GetMetricGpuValue(
177169
chip_name_, counter_data_image_, {metric_}, metric_name_value_map);
178-
#endif
179170
if (!succeeded) {
180171
return {};
181172
}
@@ -212,7 +203,7 @@ namespace cuda {
212203

213204
class NewCuptiProfiler::State {
214205
public:
215-
State() : metrics_context_(nullptr) {
206+
State() {
216207
CUpti_Profiler_Initialize_Params initialize_params = {CUpti_Profiler_Initialize_Params_STRUCT_SIZE};
217208
CUPTI_CALL(cuptiProfilerInitialize(&initialize_params));
218209

@@ -224,21 +215,9 @@ class NewCuptiProfiler::State {
224215

225216
NVPW_InitializeHost_Params initialize_host_params = {NVPW_InitializeHost_Params_STRUCT_SIZE};
226217
NVPW_API_CALL(NVPW_InitializeHost(&initialize_host_params));
227-
228-
NVPW_CUDA_MetricsContext_Create_Params metrics_context_create_params =
229-
{NVPW_CUDA_MetricsContext_Create_Params_STRUCT_SIZE};
230-
metrics_context_create_params.pChipName = chip_name_.c_str();
231-
NVPW_API_CALL(NVPW_CUDA_MetricsContext_Create(&metrics_context_create_params));
232-
metrics_context_ = metrics_context_create_params.pMetricsContext;
233218
}
234219

235220
~State() {
236-
NVPW_MetricsContext_Destroy_Params metrics_context_destroy_params =
237-
{NVPW_MetricsContext_Destroy_Params_STRUCT_SIZE};
238-
metrics_context_destroy_params.pMetricsContext = metrics_context_;
239-
NVPW_MetricsContext_Destroy((NVPW_MetricsContext_Destroy_Params *)&metrics_context_destroy_params);
240-
metrics_context_ = nullptr;
241-
242221
CUpti_Profiler_DeInitialize_Params deinitialize_params = {CUpti_Profiler_DeInitialize_Params_STRUCT_SIZE};
243222
// NOTE: We don't error check because this is the destructor and so
244223
// throwing an exception on an error here won't really help
@@ -252,15 +231,9 @@ class NewCuptiProfiler::State {
252231
}
253232

254233
auto inserted = config_images_.emplace(std::make_pair<std::string, std::vector<uint8_t>>(std::string(metric), {}));
255-
#if (CUDA_VERSION == 10010)
256-
if (!NV::Metric::Config::GetConfigImage(metrics_context_, chip_name_, {metric}, inserted.first->second)) {
257-
throw std::runtime_error("Failed to create config_image!");
258-
}
259-
#elif (CUDA_VERSION >= 10020)
260234
if (!NV::Metric::Config::GetConfigImage(chip_name_, {metric}, inserted.first->second)) {
261235
throw std::runtime_error("Failed to create config_image!");
262236
}
263-
#endif
264237
return inserted.first->second;
265238
}
266239

@@ -272,33 +245,21 @@ class NewCuptiProfiler::State {
272245

273246
auto inserted = image_prefixes_.emplace(
274247
std::make_pair<std::string, std::vector<uint8_t>>(std::string(metric), {}));
275-
#if (CUDA_VERSION == 10010)
276-
if (!NV::Metric::Config::GetCounterDataPrefixImage(
277-
metrics_context_, chip_name_, {metric}, inserted.first->second)) {
278-
throw std::runtime_error("Failed to create counter_data_image_prefix!");
279-
}
280-
#elif (CUDA_VERSION >= 10020)
281248
if (!NV::Metric::Config::GetCounterDataPrefixImage(
282249
chip_name_, {metric}, inserted.first->second)) {
283250
throw std::runtime_error("Failed to create counter_data_image_prefix!");
284251
}
285-
#endif
286252
return inserted.first->second;
287253
}
288254

289255
const std::string& chipName() const {
290256
return chip_name_;
291257
}
292258

293-
NVPA_MetricsContext* metricsContext() const {
294-
return metrics_context_;
295-
}
296-
297259
private:
298260
std::string chip_name_;
299261
mutable std::unordered_map<std::string, std::vector<uint8_t>> config_images_;
300262
mutable std::unordered_map<std::string, std::vector<uint8_t>> image_prefixes_;
301-
NVPA_MetricsContext* metrics_context_;
302263
};
303264

304265
NewCuptiProfiler::NewCuptiProfiler() {}
@@ -317,7 +278,6 @@ void NewCuptiProfiler::profile(
317278
}
318279

319280
ProfilingSession session(
320-
state_->metricsContext(),
321281
state_->chipName(),
322282
metric_name,
323283
kernels.size(),

0 commit comments

Comments
 (0)