@@ -36,7 +36,6 @@ namespace {
36
36
class ProfilingSession {
37
37
public:
38
38
ProfilingSession (
39
- NVPA_MetricsContext* metrics_context,
40
39
const std::string& chip_name,
41
40
const std::string& metric,
42
41
int num_kernels,
@@ -54,7 +53,6 @@ class ProfilingSession {
54
53
CUpti_ProfilerReplayMode profiler_replay_mode_;
55
54
CUpti_ProfilerRange profiler_range_;
56
55
const std::string& metric_;
57
- NVPA_MetricsContext* metrics_context_;
58
56
const std::string& chip_name_;
59
57
int num_kernels_;
60
58
@@ -67,7 +65,6 @@ class ProfilingSession {
67
65
};
68
66
69
67
ProfilingSession::ProfilingSession (
70
- NVPA_MetricsContext* metrics_context,
71
68
const std::string& chip_name,
72
69
const std::string& metric,
73
70
int num_kernels,
@@ -76,7 +73,6 @@ ProfilingSession::ProfilingSession(
76
73
: profiler_replay_mode_(CUPTI_KernelReplay),
77
74
profiler_range_ (CUPTI_AutoRange),
78
75
metric_(metric),
79
- metrics_context_(metrics_context),
80
76
chip_name_(chip_name),
81
77
num_kernels_(num_kernels),
82
78
image_prefix_(image_prefix),
@@ -169,13 +165,8 @@ void ProfilingSession::stopProfiling() {
169
165
170
166
std::vector<habitat::cuda::KernelMetric> ProfilingSession::getMeasuredMetrics () {
171
167
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)
176
168
bool succeeded = NV::Metric::Eval::GetMetricGpuValue (
177
169
chip_name_, counter_data_image_, {metric_}, metric_name_value_map);
178
- #endif
179
170
if (!succeeded) {
180
171
return {};
181
172
}
@@ -212,7 +203,7 @@ namespace cuda {
212
203
213
204
class NewCuptiProfiler ::State {
214
205
public:
215
- State () : metrics_context_( nullptr ) {
206
+ State () {
216
207
CUpti_Profiler_Initialize_Params initialize_params = {CUpti_Profiler_Initialize_Params_STRUCT_SIZE};
217
208
CUPTI_CALL (cuptiProfilerInitialize (&initialize_params));
218
209
@@ -224,21 +215,9 @@ class NewCuptiProfiler::State {
224
215
225
216
NVPW_InitializeHost_Params initialize_host_params = {NVPW_InitializeHost_Params_STRUCT_SIZE};
226
217
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 ;
233
218
}
234
219
235
220
~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
-
242
221
CUpti_Profiler_DeInitialize_Params deinitialize_params = {CUpti_Profiler_DeInitialize_Params_STRUCT_SIZE};
243
222
// NOTE: We don't error check because this is the destructor and so
244
223
// throwing an exception on an error here won't really help
@@ -252,15 +231,9 @@ class NewCuptiProfiler::State {
252
231
}
253
232
254
233
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)
260
234
if (!NV::Metric::Config::GetConfigImage (chip_name_, {metric}, inserted.first ->second )) {
261
235
throw std::runtime_error (" Failed to create config_image!" );
262
236
}
263
- #endif
264
237
return inserted.first ->second ;
265
238
}
266
239
@@ -272,33 +245,21 @@ class NewCuptiProfiler::State {
272
245
273
246
auto inserted = image_prefixes_.emplace (
274
247
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)
281
248
if (!NV::Metric::Config::GetCounterDataPrefixImage (
282
249
chip_name_, {metric}, inserted.first ->second )) {
283
250
throw std::runtime_error (" Failed to create counter_data_image_prefix!" );
284
251
}
285
- #endif
286
252
return inserted.first ->second ;
287
253
}
288
254
289
255
const std::string& chipName () const {
290
256
return chip_name_;
291
257
}
292
258
293
- NVPA_MetricsContext* metricsContext () const {
294
- return metrics_context_;
295
- }
296
-
297
259
private:
298
260
std::string chip_name_;
299
261
mutable std::unordered_map<std::string, std::vector<uint8_t >> config_images_;
300
262
mutable std::unordered_map<std::string, std::vector<uint8_t >> image_prefixes_;
301
- NVPA_MetricsContext* metrics_context_;
302
263
};
303
264
304
265
NewCuptiProfiler::NewCuptiProfiler () {}
@@ -317,7 +278,6 @@ void NewCuptiProfiler::profile(
317
278
}
318
279
319
280
ProfilingSession session (
320
- state_->metricsContext (),
321
281
state_->chipName (),
322
282
metric_name,
323
283
kernels.size (),
0 commit comments