Skip to content

Commit ee5872e

Browse files
committed
kp_memory_usage: use separate file for data transfers across Kokkos Memory Spaces
1 parent 2a05419 commit ee5872e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

profiling/memory-usage/kp_memory_usage.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,18 @@ void kokkosp_finalize_library() {
6767
int pid = getpid();
6868

6969
for (int s = 0; s < num_spaces; s++) {
70-
char* fileOutput = (char*)malloc(sizeof(char) * 256);
70+
71+
char* fileOutput = (char*)malloc(sizeof(char) * 256);
72+
char* fileOutputxfers = (char*)malloc(sizeof(char) * 256);
73+
7174
snprintf(fileOutput, 256, "%s-%d-%s.memspace_usage", hostname, pid,
7275
space_name[s]);
73-
76+
77+
snprintf(fileOutputxfers, 256, "%s-%d.memspace_transfers", hostname, pid);
7478
FILE* ofile = fopen(fileOutput, "wb");
79+
FILE* ofilexf = fopen(fileOutputxfers, "wb");
7580
free(fileOutput);
81+
free(fileOutputxfers);
7682

7783
fprintf(ofile, "# Space %s\n", space_name[s]);
7884
fprintf(ofile,
@@ -88,11 +94,11 @@ void kokkosp_finalize_library() {
8894
1.0 * std::get<2>(space_size_track[s][i]) / 1024 / 1024);
8995
}
9096

91-
fprintf(ofile, "# Data transferred between Kokkos Memory Spaces --- \n");
97+
fprintf(ofilexf, "# Data transferred between Kokkos Memory Spaces --- \n");
9298
for (int dst = 0; dst < num_spaces; dst++) {
9399
for (int src = 0; src < num_spaces; src++) {
94-
fprintf(ofile, "# DstSpace SrcSpace Data-Transferred(MB)\n");
95-
fprintf(ofile, "%s %s %.1lf \n", space_name[dst], space_name[src],
100+
fprintf(ofilexf, "# DstSpace SrcSpace Data-Transferred(MB)\n");
101+
fprintf(ofilexf, "%s %s %.1lf \n", space_name[dst], space_name[src],
96102
1.0 * totalMemoryTransferred[dst][src] / 1024 / 1024);
97103
}
98104
}
@@ -168,7 +174,7 @@ void kokkosp_begin_deep_copy(SpaceHandle dst_handle, const char* /* dst_name */,
168174
totalMemoryTransferred[space_dst][space_src] += size;
169175
}
170176

171-
void kokkosp_end_deep_copy() { std::lock_guard<std::mutex> lock(m); }
177+
void kokkosp_end_deep_copy() { }
172178

173179
Kokkos::Tools::Experimental::EventSet get_event_set() {
174180
Kokkos::Tools::Experimental::EventSet my_event_set;

0 commit comments

Comments
 (0)