Skip to content

Commit

Permalink
move internal function up a level
Browse files Browse the repository at this point in the history
  • Loading branch information
slabasan committed Jan 15, 2024
1 parent 930f611 commit c143eb7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/variorum/Intel/clocks_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,23 @@ int print_verbose_clocks_data(FILE *writedest, off_t msr_aperf, off_t msr_mperf,
return 0;
}

json_t *make_socket_obj(json_t *node_obj, int socket_index)
{
char socket_name[16];
snprintf(socket_name, 16, "socket_%d", socket_index);
json_t *socket_obj = json_object_get(node_obj, socket_name);
if (socket_obj == NULL)
{
socket_obj = json_object();
json_object_set_new(node_obj, socket_name, socket_obj);
}
return socket_obj;
}

int get_clocks_data_json(json_t *output, off_t msr_aperf, off_t msr_mperf,
off_t msr_tsc, off_t msr_perf_status, off_t msr_platform_info,
enum ctl_domains_e control_domains)
{

static struct clocks_data *cd;
static struct perf_data *pd;
unsigned i, j, k;
Expand All @@ -331,19 +343,6 @@ int get_clocks_data_json(json_t *output, off_t msr_aperf, off_t msr_mperf,
read_batch(CLOCKS_DATA);
read_batch(PERF_DATA);

json_t *make_socket_obj(json_t *node_obj, int socket_index)
{
char socket_name[16];
snprintf(socket_name, 16, "socket_%d", socket_index);
json_t *socket_obj = json_object_get(node_obj, socket_name);
if (socket_obj == NULL)
{
socket_obj = json_object();
json_object_set_new(node_obj, socket_name, socket_obj);
}
return socket_obj;
}

//use array to store core frequencies;
double core_frequencies[ncores];
memset(core_frequencies, 0.0, ncores * sizeof(double));
Expand All @@ -366,9 +365,8 @@ int get_clocks_data_json(json_t *output, off_t msr_aperf, off_t msr_mperf,
for (k = 0; k < nthreads / ncores; k++)
{
idx = (k * nsockets * (ncores / nsockets)) + (i * (ncores / nsockets)) + j;
core_frequencies[core_freq_index] += (max_non_turbo_ratio *
(*cd->aperf[idx] / (double)(
*cd->mperf[idx])));
core_frequencies[core_freq_index] += (max_non_turbo_ratio * (*cd->aperf[idx] /
(double)(*cd->mperf[idx])));
}
core_frequencies[core_freq_index] /= 2;
socket_average_freq += core_frequencies[core_freq_index];
Expand Down
5 changes: 5 additions & 0 deletions src/variorum/Intel/clocks_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ int get_clocks_data_json(
enum ctl_domains_e control_domain
);

json_t *make_socket_obj(
json_t *node_obj,
int socket_index
)

///// @brief Print current p-state.
/////
///// @param [in] writedest File stream where output will be written to.
Expand Down

0 comments on commit c143eb7

Please sign in to comment.