Skip to content

Commit

Permalink
first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
slabasan committed Mar 19, 2024
1 parent 0521ada commit efd88de
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 38 deletions.
3 changes: 1 addition & 2 deletions src/examples/variorum-print-energy-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
2 changes: 1 addition & 1 deletion src/examples/variorum-print-verbose-energy-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 3 additions & 4 deletions src/variorum/IBM/Power9.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 */
Expand All @@ -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));

Expand All @@ -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));

Expand Down
9 changes: 7 additions & 2 deletions src/variorum/IBM/Power9.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <jansson.h>
#include <pthread.h>

#include <variorum_timers.h>

struct thread_args
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/variorum/IBM/config_ibm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/variorum/Intel/Intel_06_3F.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions src/variorum/Intel/Intel_06_4F.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions src/variorum/Intel/Intel_06_55.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 1 addition & 2 deletions src/variorum/Intel/config_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/variorum/Intel/intel_power_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 13 additions & 9 deletions src/variorum/Intel/intel_power_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/variorum/config_architecture.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions src/variorum/variorum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/variorum/variorum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit efd88de

Please sign in to comment.