From efd88de7ab7af9fc6997a5e972b79dda4cb3d214 Mon Sep 17 00:00:00 2001 From: Stephanie Brink Date: Tue, 19 Mar 2024 11:07:06 -0700 Subject: [PATCH] first pass --- src/examples/variorum-print-energy-example.c | 3 +-- .../variorum-print-verbose-energy-example.c | 2 +- src/variorum/IBM/Power9.c | 7 +++--- src/variorum/IBM/Power9.h | 9 ++++++-- src/variorum/IBM/config_ibm.c | 3 +-- src/variorum/Intel/Intel_06_3F.c | 4 ++-- src/variorum/Intel/Intel_06_4F.c | 4 ++-- src/variorum/Intel/Intel_06_55.c | 4 ++-- src/variorum/Intel/config_intel.c | 3 +-- src/variorum/Intel/intel_power_features.c | 3 +-- src/variorum/Intel/intel_power_features.h | 22 +++++++++++-------- src/variorum/config_architecture.h | 2 +- src/variorum/variorum.c | 10 +++++---- src/variorum/variorum.h | 6 ++--- 14 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/examples/variorum-print-energy-example.c b/src/examples/variorum-print-energy-example.c index f5352f832..c6901268f 100644 --- a/src/examples/variorum-print-energy-example.c +++ b/src/examples/variorum-print-energy-example.c @@ -41,12 +41,11 @@ int main(int argc, char **argv) sleep(2); - //Second call to variorum_print_energy should print a valid value. + // Second call to variorum_print_energy should print a valid value. ret = variorum_print_energy(); if (ret != 0) { printf("Print core and Socket energy failed!\n"); return ret; } - } diff --git a/src/examples/variorum-print-verbose-energy-example.c b/src/examples/variorum-print-verbose-energy-example.c index 1263de33c..1b6b7d877 100644 --- a/src/examples/variorum-print-verbose-energy-example.c +++ b/src/examples/variorum-print-verbose-energy-example.c @@ -33,7 +33,7 @@ int main(int argc, char **argv) ret = variorum_print_verbose_energy(); if (ret != 0) { - printf("Print core and Socket energy failed!\n"); + printf("Print core and socket energy failed!\n"); } return ret; } diff --git a/src/variorum/IBM/Power9.c b/src/variorum/IBM/Power9.c index 05b0ac28e..43553bf6f 100644 --- a/src/variorum/IBM/Power9.c +++ b/src/variorum/IBM/Power9.c @@ -673,7 +673,7 @@ int ibm_cpu_p9_get_energy(int long_ver) } else { - // /* The first call should print zero as energy. */ + /* The first call should print zero as energy. */ printf("Accumulated energy before starting the thread is %lu\n", th_args.energy_acc); } @@ -792,7 +792,6 @@ void *power_measurement(void *arg) return arg; } - int ibm_cpu_p9_get_node_energy_json(json_t *get_energy_obj) { /* Enter the function the first time */ @@ -809,7 +808,7 @@ int ibm_cpu_p9_get_node_energy_json(json_t *get_energy_obj) // printf("Accumulated energy before starting the thread is %lu\n", // th_args.energy_acc); - /*Only set node_energy for now */ + /* Only set node_energy for now */ json_object_set_new(get_energy_obj, "energy_node_joules", json_integer(th_args.energy_acc)); @@ -832,7 +831,7 @@ int ibm_cpu_p9_get_node_energy_json(json_t *get_energy_obj) // printf("Accumulated energy after stopping the thread is %lu\n", // th_args.energy_acc); - /*Only set node_energy for now */ + /* Only set node_energy for now */ json_object_set_new(get_energy_obj, "energy_node_joules", json_integer(th_args.energy_acc)); diff --git a/src/variorum/IBM/Power9.h b/src/variorum/IBM/Power9.h index 3820c5eba..920375c87 100644 --- a/src/variorum/IBM/Power9.h +++ b/src/variorum/IBM/Power9.h @@ -8,6 +8,7 @@ #include #include + #include struct thread_args @@ -61,9 +62,13 @@ int ibm_cpu_p9_get_node_frequency_json( ); /* Sampling functions for get_energy thread implementation */ -void *power_measurement(void *arg); +void *power_measurement( + void *arg +); -unsigned long take_measurement(); +unsigned long take_measurement( + void +); int ibm_cpu_p9_get_node_energy_json( json_t *get_energy_obj diff --git a/src/variorum/IBM/config_ibm.c b/src/variorum/IBM/config_ibm.c index f1eb23f56..a0d236a04 100644 --- a/src/variorum/IBM/config_ibm.c +++ b/src/variorum/IBM/config_ibm.c @@ -40,8 +40,7 @@ int set_ibm_func_ptrs(int idx) g_platform[idx].variorum_get_thermals_json = ibm_cpu_p9_get_node_thermal_json; g_platform[idx].variorum_get_frequency_json = ibm_cpu_p9_get_node_frequency_json; - g_platform[idx].variorum_get_energy_json = - ibm_cpu_p9_get_node_energy_json; + g_platform[idx].variorum_get_energy_json = ibm_cpu_p9_get_node_energy_json; } else { diff --git a/src/variorum/Intel/Intel_06_3F.c b/src/variorum/Intel/Intel_06_3F.c index 7d441b383..91730f58c 100644 --- a/src/variorum/Intel/Intel_06_3F.c +++ b/src/variorum/Intel/Intel_06_3F.c @@ -558,8 +558,8 @@ int intel_cpu_fm_06_3f_get_energy(int long_ver) if (long_ver == 0) { - print_energy_data(stdout, msrs.msr_rapl_power_unit, - msrs.msr_pkg_energy_status, msrs.msr_dram_energy_status); + print_energy_data(stdout, msrs.msr_rapl_power_unit, msrs.msr_pkg_energy_status, + msrs.msr_dram_energy_status); } else if (long_ver == 1) { diff --git a/src/variorum/Intel/Intel_06_4F.c b/src/variorum/Intel/Intel_06_4F.c index a1f1a9b88..1ee6d0ad8 100644 --- a/src/variorum/Intel/Intel_06_4F.c +++ b/src/variorum/Intel/Intel_06_4F.c @@ -580,8 +580,8 @@ int intel_cpu_fm_06_4f_get_energy(int long_ver) if (long_ver == 0) { - print_energy_data(stdout, msrs.msr_rapl_power_unit, - msrs.msr_pkg_energy_status, msrs.msr_dram_energy_status); + print_energy_data(stdout, msrs.msr_rapl_power_unit, msrs.msr_pkg_energy_status, + msrs.msr_dram_energy_status); } else if (long_ver == 1) { diff --git a/src/variorum/Intel/Intel_06_55.c b/src/variorum/Intel/Intel_06_55.c index e5c41a6fb..1060f35f7 100644 --- a/src/variorum/Intel/Intel_06_55.c +++ b/src/variorum/Intel/Intel_06_55.c @@ -515,8 +515,8 @@ int intel_cpu_fm_06_55_get_energy(int long_ver) if (long_ver == 0) { - print_energy_data(stdout, msrs.msr_rapl_power_unit, - msrs.msr_pkg_energy_status, msrs.msr_dram_energy_status); + print_energy_data(stdout, msrs.msr_rapl_power_unit, msrs.msr_pkg_energy_status, + msrs.msr_dram_energy_status); } else if (long_ver == 1) { diff --git a/src/variorum/Intel/config_intel.c b/src/variorum/Intel/config_intel.c index e4dbaf6fd..d03c0282b 100644 --- a/src/variorum/Intel/config_intel.c +++ b/src/variorum/Intel/config_intel.c @@ -239,8 +239,7 @@ int set_intel_func_ptrs(int idx) g_platform[idx].variorum_print_counters = intel_cpu_fm_06_55_get_counters; g_platform[idx].variorum_print_frequency = intel_cpu_fm_06_55_get_clocks; g_platform[idx].variorum_print_power = intel_cpu_fm_06_55_get_power; - g_platform[idx].variorum_print_energy = - intel_cpu_fm_06_55_get_energy; + g_platform[idx].variorum_print_energy = intel_cpu_fm_06_55_get_energy; //g_platform[idx].variorum_print_turbo = intel_cpu_fm_06_55_get_turbo_status; //g_platform[idx].variorum_enable_turbo = intel_cpu_fm_06_55_enable_turbo; //g_platform[idx].variorum_disable_turbo = intel_cpu_fm_06_55_disable_turbo; diff --git a/src/variorum/Intel/intel_power_features.c b/src/variorum/Intel/intel_power_features.c index df340e348..61d145aba 100644 --- a/src/variorum/Intel/intel_power_features.c +++ b/src/variorum/Intel/intel_power_features.c @@ -1621,8 +1621,7 @@ void print_energy_data(FILE *writedest, off_t msr_rapl_unit, if (!init) { gettimeofday(&start, NULL); - fprintf(writedest, - "_PACKAGE_ENERGY_STATUS Offset Host Socket Bits Energy_J\n"); + fprintf(writedest, "_PACKAGE_ENERGY_STATUS Offset Host Socket Bits Energy_J\n"); rapl_storage(&rapl); } gettimeofday(&now, NULL); diff --git a/src/variorum/Intel/intel_power_features.h b/src/variorum/Intel/intel_power_features.h index e663a1b62..5502cd7b1 100644 --- a/src/variorum/Intel/intel_power_features.h +++ b/src/variorum/Intel/intel_power_features.h @@ -253,15 +253,19 @@ void print_verbose_power_data(FILE *writedest, off_t msr_pkg_energy_status, off_t msr_dram_energy_status); -void print_energy_data(FILE *writedest, - off_t msr_rapl_unit, - off_t msr_pkg_energy_status, - off_t msr_dram_energy_status); - -void print_verbose_energy_data(FILE *writedest, - off_t msr_rapl_unit, - off_t msr_pkg_energy_status, - off_t msr_dram_energy_status); +void print_energy_data( + FILE *writedest, + off_t msr_rapl_unit, + off_t msr_pkg_energy_status, + off_t msr_dram_energy_status +); + +void print_verbose_energy_data( + FILE *writedest, + off_t msr_rapl_unit, + off_t msr_pkg_energy_status, + off_t msr_dram_energy_status +); void json_get_power_data(json_t *get_power_obj, off_t msr_power_limit, diff --git a/src/variorum/config_architecture.h b/src/variorum/config_architecture.h index 037312b67..f9f694c19 100644 --- a/src/variorum/config_architecture.h +++ b/src/variorum/config_architecture.h @@ -278,7 +278,7 @@ struct platform /// @return Error code. int (*variorum_print_energy)(int long_ver); - /// @brief Function pointer to get JSON object for thermal information + /// @brief Function pointer to get JSON object for energy information /// /// @return Error code. int (*variorum_get_energy_json)(json_t *get_energy_obj); diff --git a/src/variorum/variorum.c b/src/variorum/variorum.c index 79fded788..764b0488d 100644 --- a/src/variorum/variorum.c +++ b/src/variorum/variorum.c @@ -1576,7 +1576,8 @@ int variorum_print_energy(void) { int err = 0; int i; - int has_cpu = 0, has_gpu = 0; + int has_cpu = 0; + int has_gpu = 0; err = variorum_enter(__FILE__, __FUNCTION__, __LINE__); if (err) { @@ -1631,12 +1632,12 @@ int variorum_print_energy(void) return err; } - int variorum_print_verbose_energy(void) { int err = 0; int i; - int has_cpu = 0, has_gpu = 0; + int has_cpu = 0; + int has_gpu = 0; err = variorum_enter(__FILE__, __FUNCTION__, __LINE__); if (err) { @@ -1694,7 +1695,8 @@ int variorum_get_energy_json(char **get_energy_obj_str) { int err = 0; int i; - int has_cpu = 0, has_gpu = 0; + int has_cpu = 0; + int has_gpu = 0; char hostname[1024]; uint64_t ts; struct timeval tv; diff --git a/src/variorum/variorum.h b/src/variorum/variorum.h index f50a5adfc..37a8fe577 100644 --- a/src/variorum/variorum.h +++ b/src/variorum/variorum.h @@ -684,13 +684,13 @@ int variorum_get_thermals_json(char **get_thermal_obj_str); /// check for NULL strings. int variorum_get_frequency_json(char **get_frequency_obj_str); -/// @brief Populate a string in JSON format with node level frequency information +/// @brief Populate a string in JSON format with node level energy information /// /// @supparch /// - IBM Power9 /// -/// @param [out] get_energy_obj_str String (passed by reference) that contains the -/// node-level energy information. +/// @param [out] get_energy_obj_str String (passed by reference) containing +/// the node-level energy information. /// /// @return 0 if successful, otherwise -1. Note that feature not implemented /// returns a -1 for the JSON APIs so that users don't have to explicitly