Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit d58ff74

Browse files
authored
Added GPU memory report (#714)
* Added GPU memory report * Added fixes for CPU build and clang-format * Fixing memory reporting for CPU builds
1 parent 2ffa262 commit d58ff74

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

coreneuron/utils/memory_utils.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <fstream>
2626
#include <unistd.h>
2727
#include "coreneuron/utils/memory_utils.h"
28+
#include "coreneuron/utils/profile/cuda_profile.h"
2829
#include "coreneuron/mpi/nrnmpi.h"
2930
#include "coreneuron/mpi/core/nrnmpi.hpp"
3031
#include "coreneuron/apps/corenrn_parameters.hpp"
@@ -105,6 +106,11 @@ void report_mem_usage(const char* message, bool all_ranks) {
105106
mem_max,
106107
mem_min,
107108
mem_avg);
109+
#ifdef CORENEURON_ENABLE_GPU
110+
if (corenrn_param.gpu) {
111+
print_gpu_memory_usage();
112+
}
113+
#endif
108114
}
109115
fflush(stdout);
110116
}

coreneuron/utils/profile/cuda_profile.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "cuda_profiler_api.h"
1010
#include <stdio.h>
11+
#include <ostream>
1112

1213
void print_gpu_memory_usage() {
1314
size_t free_byte;
@@ -23,7 +24,7 @@ void print_gpu_memory_usage() {
2324
double free_db = (double) free_byte;
2425
double total_db = (double) total_byte;
2526
double used_db = total_db - free_db;
26-
printf("\n => GPU MEMORY USAGE (MB) : Used = %f, Free = %f MB, Total = %f",
27+
printf(" GPU Memory (MBs) : Used = %f, Free = %f, Total = %f\n",
2728
used_db / 1024.0 / 1024.0,
2829
free_db / 1024.0 / 1024.0,
2930
total_db / 1024.0 / 1024.0);

0 commit comments

Comments
 (0)