Skip to content

Commit eb99f1f

Browse files
committed
energy-profiler: fix for new infrastructure
1 parent e502eb7 commit eb99f1f

File tree

5 files changed

+62
-63
lines changed

5 files changed

+62
-63
lines changed

profiling/energy-profiler/kokkos-tools/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,4 @@ if (CUDAToolkit_FOUND)
6969
endif()
7070
else()
7171
message(STATUS "CUDAToolkit not found, skipping NVML power profiler.")
72-
endif()
7372
endif()

profiling/energy-profiler/kokkos-tools/kp_nvml_direct_power.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static std::unique_ptr<Daemon> g_power_daemon;
5252
static std::unique_ptr<NVMLProvider> g_nvml_provider;
5353

5454
// Timer tool for kernel and region timing
55-
static Timer::KernelTimerTool g_timer;
55+
static EnergyProfiler::KernelTimerTool g_timer;
5656

5757
// Structure to store a single power measurement with a timestamp per device.
5858
struct DirectPowerSample {
@@ -87,7 +87,7 @@ void power_monitoring_tick() {
8787
double power = 0.0;
8888
Result result = g_nvml_provider->get_device_power_usage_direct(i, power);
8989
if (!result) {
90-
ENERGY_PROFILER_LOG_WARNING(
90+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_WARNING(
9191
COMPONENT_NAME, "Failed to get direct power for device " +
9292
std::to_string(i) + ": " + result.message);
9393
power = -1.0; // Use sentinel value for missing data
@@ -203,8 +203,8 @@ void export_direct_power_data_csv(const std::string& filename) {
203203
void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
204204
const uint32_t devInfoCount,
205205
Kokkos_Profiling_KokkosPDeviceInfo* deviceInfo) {
206-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "Initializing...");
207-
ENERGY_PROFILER_LOG_INFO(
206+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "Initializing...");
207+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(
208208
COMPONENT_NAME,
209209
"Sampling Interval: " + std::to_string(SAMPLING_INTERVAL_MS) + " ms");
210210

@@ -214,7 +214,7 @@ void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
214214
g_nvml_provider = std::make_unique<NVMLProvider>();
215215
Result init_result = g_nvml_provider->initialize();
216216
if (!init_result) {
217-
ENERGY_PROFILER_LOG_ERROR(
217+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_ERROR(
218218
COMPONENT_NAME,
219219
"Failed to initialize NVML provider: " + init_result.message +
220220
". Direct power profiling disabled.");
@@ -223,13 +223,13 @@ void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
223223
}
224224

225225
g_device_count = g_nvml_provider->get_device_count();
226-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "NVML provider initialized with " +
226+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "NVML provider initialized with " +
227227
std::to_string(g_device_count) +
228228
" device(s)");
229229

230230
// Print device information
231231
for (size_t i = 0; i < g_device_count; ++i) {
232-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
232+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
233233
"Device " + std::to_string(i) + ": " +
234234
g_nvml_provider->get_device_name(i));
235235
}
@@ -239,16 +239,16 @@ void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
239239
std::make_unique<Daemon>(power_monitoring_tick, SAMPLING_INTERVAL_MS);
240240
g_start_time = std::chrono::high_resolution_clock::now();
241241
g_power_daemon->start();
242-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
242+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
243243
"Direct power monitoring daemon started");
244244
}
245245

246246
void kokkosp_finalize_library() {
247-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "Finalizing...");
247+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "Finalizing...");
248248

249249
if (g_power_daemon) {
250250
g_power_daemon->stop();
251-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
251+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
252252
"Direct power monitoring daemon stopped");
253253
}
254254

@@ -300,16 +300,16 @@ void kokkosp_finalize_library() {
300300
std::string prefix = generate_prefix();
301301

302302
const auto& kernels = g_timer.get_kernel_timings();
303-
KokkosTools::Timer::print_kernels_summary(kernels);
304-
KokkosTools::Timer::export_kernels_csv(kernels, prefix + "_kernels.csv");
303+
KokkosTools::EnergyProfiler::print_kernels_summary(kernels);
304+
KokkosTools::EnergyProfiler::export_kernels_csv(kernels, prefix + "_kernels.csv");
305305

306306
const auto& regions = g_timer.get_region_timings();
307-
KokkosTools::Timer::print_regions_summary(regions);
308-
KokkosTools::Timer::export_regions_csv(regions, prefix + "_regions.csv");
307+
KokkosTools::EnergyProfiler::print_regions_summary(regions);
308+
KokkosTools::EnergyProfiler::export_regions_csv(regions, prefix + "_regions.csv");
309309

310310
const auto& deepcopies = g_timer.get_deep_copy_timings();
311-
KokkosTools::Timer::print_deepcopies_summary(deepcopies);
312-
KokkosTools::Timer::export_deepcopies_csv(deepcopies,
311+
KokkosTools::EnergyProfiler::print_deepcopies_summary(deepcopies);
312+
KokkosTools::EnergyProfiler::export_deepcopies_csv(deepcopies,
313313
prefix + "_deepcopies.csv");
314314

315315
if (g_nvml_provider) {

profiling/energy-profiler/kokkos-tools/kp_nvml_energy_consumption.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static constexpr const char* COMPONENT_NAME = "EnergyConsumption";
4949
static std::unique_ptr<NVMLProvider> g_nvml_provider;
5050

5151
// Timer tool for kernel and region timing
52-
static Timer::KernelTimerTool g_timer;
52+
static EnergyProfiler::KernelTimerTool g_timer;
5353

5454
static size_t g_device_count = 0;
5555
static std::chrono::high_resolution_clock::time_point g_start_time;
@@ -115,7 +115,7 @@ EnergySnapshot capture_energy_snapshot() {
115115
for (size_t i = 0; i < g_device_count; ++i) {
116116
snapshot.device_energies_joules.push_back(-1.0);
117117
}
118-
ENERGY_PROFILER_LOG_WARNING(
118+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_WARNING(
119119
COMPONENT_NAME,
120120
"Provider not initialized, using invalid energy values");
121121
return snapshot;
@@ -129,7 +129,7 @@ EnergySnapshot capture_energy_snapshot() {
129129
snapshot.device_energies_joules.push_back(energy);
130130
} else {
131131
snapshot.device_energies_joules.push_back(-1.0);
132-
ENERGY_PROFILER_LOG_WARNING(
132+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_WARNING(
133133
COMPONENT_NAME, "Failed to get energy for device " +
134134
std::to_string(i) + ": " + result.message);
135135
}
@@ -179,7 +179,7 @@ Result export_energy_consumption_csv(const std::string& filename) {
179179
std::ofstream file(filename);
180180
if (!file.is_open()) {
181181
std::string error_msg = "Unable to open file " + filename + " for writing";
182-
ENERGY_PROFILER_LOG_ERROR(COMPONENT_NAME, error_msg);
182+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_ERROR(COMPONENT_NAME, error_msg);
183183
return Result(ErrorCode::FILE_WRITE_FAILED, error_msg);
184184
}
185185

@@ -236,18 +236,18 @@ Result export_energy_consumption_csv(const std::string& filename) {
236236

237237
if (file.fail()) {
238238
std::string error_msg = "Failed to write data to file " + filename;
239-
ENERGY_PROFILER_LOG_ERROR(COMPONENT_NAME, error_msg);
239+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_ERROR(COMPONENT_NAME, error_msg);
240240
return Result(ErrorCode::FILE_WRITE_FAILED, error_msg);
241241
}
242242

243-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
243+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
244244
"Energy consumption data exported to " + filename);
245245
return Result(ErrorCode::SUCCESS);
246246

247247
} catch (const std::exception& e) {
248248
std::string error_msg =
249249
"Exception while writing to file " + filename + ": " + e.what();
250-
ENERGY_PROFILER_LOG_ERROR(COMPONENT_NAME, error_msg);
250+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_ERROR(COMPONENT_NAME, error_msg);
251251
return Result(ErrorCode::FILE_WRITE_FAILED, error_msg);
252252
}
253253
}
@@ -323,7 +323,7 @@ void print_energy_summary() {
323323
void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
324324
const uint32_t devInfoCount,
325325
Kokkos_Profiling_KokkosPDeviceInfo* deviceInfo) {
326-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "Initializing...");
326+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "Initializing...");
327327

328328
// Initialize the timer tool
329329
g_timer.init_library(loadSeq, interfaceVer, devInfoCount, deviceInfo);
@@ -333,31 +333,31 @@ void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
333333
if (!init_result) {
334334
std::string error_msg =
335335
"Failed to initialize NVML provider: " + init_result.message;
336-
ENERGY_PROFILER_LOG_ERROR(
336+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_ERROR(
337337
COMPONENT_NAME, error_msg + ". Energy consumption profiling disabled.");
338338
g_nvml_provider.reset(); // Release the provider
339339
return;
340340
}
341341

342342
g_device_count = g_nvml_provider->get_device_count();
343-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "NVML provider initialized with " +
343+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "NVML provider initialized with " +
344344
std::to_string(g_device_count) +
345345
" device(s)");
346346

347347
// Print device information
348348
for (size_t i = 0; i < g_device_count; ++i) {
349-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
349+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
350350
"Device " + std::to_string(i) + ": " +
351351
g_nvml_provider->get_device_name(i));
352352
}
353353

354354
g_start_time = std::chrono::high_resolution_clock::now();
355-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
355+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME,
356356
"Energy consumption monitoring initialized");
357357
}
358358

359359
void kokkosp_finalize_library() {
360-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "Finalizing...");
360+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "Finalizing...");
361361

362362
// Finalize the timer
363363
g_timer.finalize_library();
@@ -366,7 +366,7 @@ void kokkosp_finalize_library() {
366366
auto total_duration_s =
367367
std::chrono::duration<double>(end_time - g_start_time).count();
368368

369-
ENERGY_PROFILER_LOG_INFO(
369+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(
370370
COMPONENT_NAME,
371371
"Total Monitoring Duration: " + std::to_string(total_duration_s) + " s");
372372

@@ -376,30 +376,30 @@ void kokkosp_finalize_library() {
376376

377377
// Export energy data
378378
std::string csv_filename = prefix + "_nvml_energy_consumption.csv";
379-
ENERGY_PROFILER_LOG_INFO(
379+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(
380380
COMPONENT_NAME, "Exporting energy consumption data to " + csv_filename);
381381
Result export_result = export_energy_consumption_csv(csv_filename);
382382
if (!export_result) {
383-
ENERGY_PROFILER_LOG_ERROR(COMPONENT_NAME, "Failed to export energy data: " +
383+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_ERROR(COMPONENT_NAME, "Failed to export energy data: " +
384384
export_result.message);
385385
}
386386

387387
// Export timing data
388388
const auto& kernels = g_timer.get_kernel_timings();
389-
Timer::print_kernels_summary(kernels);
390-
Timer::export_kernels_csv(kernels, prefix + "_kernels.csv");
389+
KokkosTools::EnergyProfiler::print_kernels_summary(kernels);
390+
KokkosTools::EnergyProfiler::export_kernels_csv(kernels, prefix + "_kernels.csv");
391391

392392
const auto& regions = g_timer.get_region_timings();
393-
Timer::print_regions_summary(regions);
394-
Timer::export_regions_csv(regions, prefix + "_regions.csv");
393+
KokkosTools::EnergyProfiler::print_regions_summary(regions);
394+
KokkosTools::EnergyProfiler::export_regions_csv(regions, prefix + "_regions.csv");
395395

396396
const auto& deepcopies = g_timer.get_deep_copy_timings();
397-
Timer::print_deepcopies_summary(deepcopies);
398-
Timer::export_deepcopies_csv(deepcopies, prefix + "_deepcopies.csv");
397+
KokkosTools::EnergyProfiler::print_deepcopies_summary(deepcopies);
398+
KokkosTools::EnergyProfiler::export_deepcopies_csv(deepcopies, prefix + "_deepcopies.csv");
399399

400400
if (g_nvml_provider) {
401401
g_nvml_provider->finalize();
402-
ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "NVML provider finalized");
402+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_INFO(COMPONENT_NAME, "NVML provider finalized");
403403
}
404404
}
405405

profiling/energy-profiler/kokkos-tools/kp_nvml_power.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static std::unique_ptr<Daemon> g_power_daemon;
5353
static std::unique_ptr<NVMLProvider> g_nvml_provider;
5454

5555
// Timer tool for kernel and region timing
56-
static Timer::KernelTimerTool g_timer;
56+
static EnergyProfiler::KernelTimerTool g_timer;
5757

5858
// Structure to store a single power measurement with a timestamp.
5959
struct PowerSample {
@@ -80,7 +80,7 @@ void power_monitoring_tick() {
8080
double current_power = 0.0;
8181
Result result = g_nvml_provider->get_total_power_usage(current_power);
8282
if (!result) {
83-
ENERGY_PROFILER_LOG_WARNING(
83+
KOKKOS_TOOLS_ENERGY_PROFILER_LOG_WARNING(
8484
COMPONENT_NAME, "Failed to get total power usage: " + result.message);
8585
return;
8686
}
@@ -225,16 +225,16 @@ void kokkosp_finalize_library() {
225225
std::string prefix = generate_prefix();
226226

227227
const auto& kernels = g_timer.get_kernel_timings();
228-
KokkosTools::Timer::print_kernels_summary(kernels);
229-
KokkosTools::Timer::export_kernels_csv(kernels, prefix + "_kernels.csv");
228+
KokkosTools::EnergyProfiler::print_kernels_summary(kernels);
229+
KokkosTools::EnergyProfiler::export_kernels_csv(kernels, prefix + "_kernels.csv");
230230

231231
const auto& regions = g_timer.get_region_timings();
232-
KokkosTools::Timer::print_regions_summary(regions);
233-
KokkosTools::Timer::export_regions_csv(regions, prefix + "_regions.csv");
232+
KokkosTools::EnergyProfiler::print_regions_summary(regions);
233+
KokkosTools::EnergyProfiler::export_regions_csv(regions, prefix + "_regions.csv");
234234

235235
const auto& deepcopies = g_timer.get_deep_copy_timings();
236-
KokkosTools::Timer::print_deepcopies_summary(deepcopies);
237-
KokkosTools::Timer::export_deepcopies_csv(deepcopies,
236+
KokkosTools::EnergyProfiler::print_deepcopies_summary(deepcopies);
237+
KokkosTools::EnergyProfiler::export_deepcopies_csv(deepcopies,
238238
prefix + "_deepcopies.csv");
239239

240240
if (g_nvml_provider) {

0 commit comments

Comments
 (0)