Skip to content

Commit

Permalink
kp_memory_usage: use separate file for data transfers across Kokkos M…
Browse files Browse the repository at this point in the history
…emory Spaces
  • Loading branch information
vlkale committed Dec 5, 2024
1 parent 2a05419 commit ee5872e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions profiling/memory-usage/kp_memory_usage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,18 @@ void kokkosp_finalize_library() {
int pid = getpid();

for (int s = 0; s < num_spaces; s++) {
char* fileOutput = (char*)malloc(sizeof(char) * 256);

char* fileOutput = (char*)malloc(sizeof(char) * 256);
char* fileOutputxfers = (char*)malloc(sizeof(char) * 256);

snprintf(fileOutput, 256, "%s-%d-%s.memspace_usage", hostname, pid,
space_name[s]);


snprintf(fileOutputxfers, 256, "%s-%d.memspace_transfers", hostname, pid);
FILE* ofile = fopen(fileOutput, "wb");
FILE* ofilexf = fopen(fileOutputxfers, "wb");
free(fileOutput);
free(fileOutputxfers);

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

fprintf(ofile, "# Data transferred between Kokkos Memory Spaces --- \n");
fprintf(ofilexf, "# Data transferred between Kokkos Memory Spaces --- \n");
for (int dst = 0; dst < num_spaces; dst++) {
for (int src = 0; src < num_spaces; src++) {
fprintf(ofile, "# DstSpace SrcSpace Data-Transferred(MB)\n");
fprintf(ofile, "%s %s %.1lf \n", space_name[dst], space_name[src],
fprintf(ofilexf, "# DstSpace SrcSpace Data-Transferred(MB)\n");
fprintf(ofilexf, "%s %s %.1lf \n", space_name[dst], space_name[src],
1.0 * totalMemoryTransferred[dst][src] / 1024 / 1024);
}
}
Expand Down Expand Up @@ -168,7 +174,7 @@ void kokkosp_begin_deep_copy(SpaceHandle dst_handle, const char* /* dst_name */,
totalMemoryTransferred[space_dst][space_src] += size;
}

void kokkosp_end_deep_copy() { std::lock_guard<std::mutex> lock(m); }
void kokkosp_end_deep_copy() { }

Kokkos::Tools::Experimental::EventSet get_event_set() {
Kokkos::Tools::Experimental::EventSet my_event_set;
Expand Down

0 comments on commit ee5872e

Please sign in to comment.