@@ -49,7 +49,7 @@ static constexpr const char* COMPONENT_NAME = "EnergyConsumption";
4949static 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
5454static size_t g_device_count = 0 ;
5555static 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() {
323323void 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
359359void 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
0 commit comments