Skip to content

Commit

Permalink
Fixed GPU stats merging (#851)
Browse files Browse the repository at this point in the history
* Added handling for n_gpu_samples and gpu_mem_samples.

* Include files with any GPU samples.
  • Loading branch information
emeryberger authored Aug 15, 2024
1 parent bdf9218 commit 47154cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scalene/scalene_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def output_profiles(
not stats.total_cpu_samples
and not stats.total_memory_malloc_samples
and not stats.total_memory_free_samples
and not stats.total_gpu_samples
):
# Nothing to output.
return {}
Expand All @@ -315,6 +316,7 @@ def output_profiles(
+ list(stats.cpu_samples_c.keys())
+ list(stats.memory_free_samples.keys())
+ list(stats.memory_malloc_samples.keys())
+ list(stats.gpu_samples.keys())
)
)
if not all_instrumented_files:
Expand Down
5 changes: 5 additions & 0 deletions scalene/scalene_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ def build_function_stats(self, filename: Filename) -> ScaleneStatistics:
"function_map",
"firstline_map",
"gpu_samples",
"n_gpu_samples",
"gpu_mem_samples",
"total_gpu_samples",
"memory_malloc_count",
"memory_free_count",
Expand Down Expand Up @@ -458,6 +460,9 @@ def merge_stats(self, the_dir_name: pathlib.Path) -> None:
self.increment_per_line_samples(
self.n_gpu_samples, x.n_gpu_samples
)
self.increment_per_line_samples(
self.gpu_mem_samples, x.gpu_mem_samples
)
self.increment_per_line_samples(
self.memcpy_samples, x.memcpy_samples
)
Expand Down

0 comments on commit 47154cf

Please sign in to comment.