Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cpt-harlock committed Jan 23, 2025
1 parent b9cb642 commit 254c696
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 43 deletions.
13 changes: 11 additions & 2 deletions src/cntd.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,17 @@ void time_sample_region(int prev, int curr, int init, double timing[2]);
void time_sample_net(int prev, int curr, int init);
void time_sample_file(int prev, int curr, int init);
void time_sample_perf(int prev, int curr, int init);
void time_sample_sys_energy(int prev, int curr, int init, double energy_pkg[MAX_NUM_SOCKETS], double energy_dram[MAX_NUM_SOCKETS], double energy_sys_gpu[MAX_NUM_SOCKETS], double *energy_sys);
void time_sample_gpu(int prev, int curr, int init, unsigned int util_gpu[MAX_NUM_GPUS], unsigned int util_mem_gpu[MAX_NUM_GPUS], unsigned int temp_gpu[MAX_NUM_GPUS], unsigned int clock_gpu[MAX_NUM_GPUS], double energy_gpu[MAX_NUM_GPUS]);
void time_sample_sys_energy(int prev, int curr, int init,
double energy_pkg[MAX_NUM_SOCKETS],
double energy_dram[MAX_NUM_SOCKETS],
double energy_sys_gpu[MAX_NUM_SOCKETS],
double *energy_sys);
void time_sample_gpu(int prev, int curr, int init,
unsigned int util_gpu[MAX_NUM_GPUS],
unsigned int util_mem_gpu[MAX_NUM_GPUS],
unsigned int temp_gpu[MAX_NUM_GPUS],
unsigned int clock_gpu[MAX_NUM_GPUS],
double energy_gpu[MAX_NUM_GPUS]);
void event_sample_start(MPI_Type_t mpi_type);
void event_sample_end(MPI_Type_t mpi_type, int eam);
void init_time_sample();
Expand Down
30 changes: 18 additions & 12 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,18 @@ static void init_masters()
cntd->rank->local_rank = local_rank;
}

static void init_shmem() {
static void init_shmem()
{
char postfix[STRING_SIZE], shmem_name[STRING_SIZE];

// Init shared memory
get_rand_postfix(postfix, STRING_SIZE);
snprintf(shmem_name, sizeof(shmem_name), SHM_FILE, cntd->rank->local_rank, postfix);
cntd->local_ranks[cntd->rank->local_rank] = create_shmem_rank(shmem_name, 1);
snprintf(shmem_name, sizeof(shmem_name), SHM_FILE,
cntd->rank->local_rank, postfix);
cntd->local_ranks[cntd->rank->local_rank] =
create_shmem_rank(shmem_name, 1);
cntd->rank = cntd->local_ranks[cntd->rank->local_rank];


// Get shared memory for other local tasks
for (int i = 0; i < cntd->rank->local_size; i++) {
if (i == cntd->rank->local_rank)
Expand Down Expand Up @@ -358,16 +360,20 @@ HIDDEN void stop_cntd()
char filename[STRING_SIZE];

snprintf(filename, STRING_SIZE,
SCALING_MAX_FREQ, cntd->rank->cpu_id);
write_int_to_file(filename,
cntd->scaling_max_freq_fd,
cntd->sys_freq_khz[MAX]);
SCALING_MAX_FREQ,
cntd->rank->cpu_id);
write_int_to_file(
filename,
cntd->scaling_max_freq_fd,
cntd->sys_freq_khz[MAX]);

snprintf(filename, STRING_SIZE,
SCALING_MIN_FREQ, cntd->rank->cpu_id);
write_int_to_file(filename,
cntd->scaling_min_freq_fd,
cntd->sys_freq_khz[MIN]);
SCALING_MIN_FREQ,
cntd->rank->cpu_id);
write_int_to_file(
filename,
cntd->scaling_min_freq_fd,
cntd->sys_freq_khz[MIN]);
}
}
// Finalize PM
Expand Down
17 changes: 10 additions & 7 deletions src/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ static void print_rank(CNTD_RankInfo_t *rankinfo, double exe_time)
char postfix[STRING_SIZE];
get_rand_postfix(postfix, STRING_SIZE);

snprintf(filename, STRING_SIZE, "%s/" RANK_REPORT_FILE, cntd->log_dir, postfix);
snprintf(filename, STRING_SIZE, "%s/" RANK_REPORT_FILE, cntd->log_dir,
postfix);
FILE *fd = fopen(filename, "w");
if (fd == NULL) {
fprintf(stderr,
Expand Down Expand Up @@ -284,7 +285,8 @@ static void print_mpi_report(uint64_t *mpi_type_cnt, double *mpi_type_time,
char postfix[STRING_SIZE];
get_rand_postfix(postfix, STRING_SIZE);

snprintf(filename, STRING_SIZE, "%s/" MPI_REPORT_FILE, cntd->log_dir, postfix);
snprintf(filename, STRING_SIZE, "%s/" MPI_REPORT_FILE, cntd->log_dir,
postfix);
FILE *fd = fopen(filename, "w");
if (fd == NULL) {
fprintf(stderr,
Expand Down Expand Up @@ -714,7 +716,8 @@ HIDDEN void print_final_report()

if (cntd->enable_report) {
snprintf(filename, STRING_SIZE,
"%s/" SUMMARY_REPORT_FILE, cntd->log_dir, postfix);
"%s/" SUMMARY_REPORT_FILE, cntd->log_dir,
postfix);
summary_report_fd = fopen(filename, "w");
if (summary_report_fd == NULL) {
fprintf(stderr,
Expand Down Expand Up @@ -1742,8 +1745,8 @@ HIDDEN void init_timeseries_report()
char postfix[STRING_SIZE], filename[STRING_SIZE];

get_rand_postfix(postfix, STRING_SIZE);
snprintf(filename, STRING_SIZE, TIME_SERIES_FILE,
cntd->tmp_dir, cntd->node.hostname, postfix);
snprintf(filename, STRING_SIZE, TIME_SERIES_FILE, cntd->tmp_dir,
cntd->node.hostname, postfix);
timeseries_fd = fopen(filename, "w");
if (timeseries_fd == NULL) {
fprintf(stderr,
Expand Down Expand Up @@ -1993,8 +1996,8 @@ HIDDEN void finalize_timeseries_report()
fclose(timeseries_fd);

get_rand_postfix(postfix, STRING_SIZE);
snprintf(oldname, STRING_SIZE, TIME_SERIES_FILE,
cntd->tmp_dir, cntd->node.hostname, postfix);
snprintf(oldname, STRING_SIZE, TIME_SERIES_FILE, cntd->tmp_dir,
cntd->node.hostname, postfix);
snprintf(newname, STRING_SIZE, TIME_SERIES_FILE, cntd->log_dir,
cntd->node.hostname, postfix);

Expand Down
85 changes: 63 additions & 22 deletions src/sampling.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,13 @@ HIDDEN void time_sample(int sig, siginfo_t *siginfo, void *context)
if (cntd->enable_perf)
time_sample_perf(prev, curr, init);
if (cntd->enable_power_monitor) {
time_sample_sys_energy(prev, curr, init, energy_pkg, energy_dram, energy_sys_gpu, &energy_sys);
time_sample_sys_energy(prev, curr, init, energy_pkg,
energy_dram, energy_sys_gpu,
&energy_sys);
}
#ifdef NVIDIA_GPU
time_sample_gpu(prev, curr, init, util_gpu, util_mem_gpu, temp_gpu, clock_gpu, energy_gpu);
time_sample_gpu(prev, curr, init, util_gpu, util_mem_gpu, temp_gpu,
clock_gpu, energy_gpu);
#endif

if (!init)
Expand Down Expand Up @@ -534,30 +537,60 @@ HIDDEN void time_sample_region(int prev, int curr, int init, double timing[2])
for (i = 0; i < cntd->rank->local_size; i++) {
get_access(cntd->local_ranks[i]->access_shmem);
timing_s[curr] = read_time();
time_region[i][APP][curr] = cntd->local_ranks[i]->app_time[TOT];
time_region[i][MPI][curr] = cntd->local_ranks[i]->mpi_time[TOT];
time_region[i][APP][curr] =
cntd->local_ranks[i]->app_time[TOT];
time_region[i][MPI][curr] =
cntd->local_ranks[i]->mpi_time[TOT];
if (cntd->local_ranks[i]->into_mpi) {
if (last_event_time[i][MPI] != cntd->local_ranks[i]->timing_event_sample[START]) {
time_region[i][MPI][curr] += timing_s[curr] - cntd->local_ranks[i]->timing_event_sample[START];
if (last_event_time[i][MPI] !=
cntd->local_ranks[i]
->timing_event_sample[START]) {
time_region[i][MPI][curr] +=
timing_s[curr] -
cntd->local_ranks[i]
->timing_event_sample
[START];
} else {
// Use the previous value as the starting point because
// TOT is not updated yet.
time_region[i][MPI][curr] = time_region[i][MPI][prev];
time_region[i][MPI][curr] += timing_s[curr] - timing_s[prev];
time_region[i][MPI][curr] =
time_region[i][MPI][prev];
time_region[i][MPI][curr] +=
timing_s[curr] - timing_s[prev];
}
cntd->local_ranks[i]->mpi_time[CURR] = time_region[i][MPI][curr] - time_region[i][MPI][prev];
cntd->local_ranks[i]->app_time[CURR] = time_region[i][APP][curr] - time_region[i][APP][prev];
last_event_time[i][MPI] = cntd->local_ranks[i]->timing_event_sample[START];
cntd->local_ranks[i]->mpi_time[CURR] =
time_region[i][MPI][curr] -
time_region[i][MPI][prev];
cntd->local_ranks[i]->app_time[CURR] =
time_region[i][APP][curr] -
time_region[i][APP][prev];
last_event_time[i][MPI] =
cntd->local_ranks[i]
->timing_event_sample[START];
} else {
if (last_event_time[i][APP] != cntd->local_ranks[i]->timing_event_sample[END]) {
time_region[i][APP][curr] += timing_s[curr] - cntd->local_ranks[i]->timing_event_sample[END];
if (last_event_time[i][APP] !=
cntd->local_ranks[i]
->timing_event_sample[END]) {
time_region[i][APP][curr] +=
timing_s[curr] -
cntd->local_ranks[i]
->timing_event_sample
[END];
} else {
time_region[i][APP][curr] = time_region[i][APP][prev];
time_region[i][APP][curr] += timing_s[curr] - timing_s[prev];
time_region[i][APP][curr] =
time_region[i][APP][prev];
time_region[i][APP][curr] +=
timing_s[curr] - timing_s[prev];
}
cntd->local_ranks[i]->app_time[CURR] = time_region[i][APP][curr] - time_region[i][APP][prev];
cntd->local_ranks[i]->mpi_time[CURR] = time_region[i][MPI][curr] - time_region[i][MPI][prev];
last_event_time[i][APP] = cntd->local_ranks[i]->timing_event_sample[END];
cntd->local_ranks[i]->app_time[CURR] =
time_region[i][APP][curr] -
time_region[i][APP][prev];
cntd->local_ranks[i]->mpi_time[CURR] =
time_region[i][MPI][curr] -
time_region[i][MPI][prev];
last_event_time[i][APP] =
cntd->local_ranks[i]
->timing_event_sample[END];
}
release_access(cntd->local_ranks[i]->access_shmem);
}
Expand Down Expand Up @@ -765,9 +798,12 @@ HIDDEN void time_sample_perf(int prev, int curr, int init)
}
}

HIDDEN void time_sample_sys_energy(int prev, int curr, int init, double energy_pkg[MAX_NUM_SOCKETS], double energy_dram[MAX_NUM_SOCKETS], double energy_sys_gpu[MAX_NUM_SOCKETS], double *energy_sys)
HIDDEN void time_sample_sys_energy(int prev, int curr, int init,
double energy_pkg[MAX_NUM_SOCKETS],
double energy_dram[MAX_NUM_SOCKETS],
double energy_sys_gpu[MAX_NUM_SOCKETS],
double *energy_sys)
{

if (init == FALSE) {
#ifdef POWER9
make_occ_sample(flip);
Expand Down Expand Up @@ -798,7 +834,12 @@ HIDDEN void time_sample_sys_energy(int prev, int curr, int init, double energy_p
}

#ifdef NVIDIA_GPU
HIDDEN void time_sample_gpu(int prev, int curr, int init, unsigned int util_gpu[MAX_NUM_GPUS], unsigned int util_mem_gpu[MAX_NUM_GPUS], unsigned int temp_gpu[MAX_NUM_GPUS], unsigned int clock_gpu[MAX_NUM_GPUS], double energy_gpu[MAX_NUM_GPUS])
HIDDEN void time_sample_gpu(int prev, int curr, int init,
unsigned int util_gpu[MAX_NUM_GPUS],
unsigned int util_mem_gpu[MAX_NUM_GPUS],
unsigned int temp_gpu[MAX_NUM_GPUS],
unsigned int clock_gpu[MAX_NUM_GPUS],
double energy_gpu[MAX_NUM_GPUS])
{
static uint64_t energy_gpu_s[2][MAX_NUM_GPUS] = { 0 };
nvmlUtilization_t nvml_util;
Expand All @@ -822,7 +863,7 @@ HIDDEN void time_sample_gpu(int prev, int curr, int init, unsigned int util_gpu[
energy_gpu_s[prev][i], UINT64_MAX);
energy_gpu[i] = (double)energy_diff / 1.0E6;
cntd->gpu.energy[i] += energy_gpu[i];
}
}
}

// Utilization
Expand Down

0 comments on commit 254c696

Please sign in to comment.