-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flush cache #246
Draft
fjwillemsen
wants to merge
30
commits into
master
Choose a base branch
from
flush_cache
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Flush cache #246
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
81a68a4
Added RegisterObserver with common interface among backends
fjwillemsen 943b3c4
Added test for RegisterObserver, added clause in case of mocktest
fjwillemsen 1681730
Added useful error message in case Register Observer is not supported
fjwillemsen f153945
Added tests for Register Observer for OpenCL and HIP backends
fjwillemsen 7bd7c2b
Added instruction for pointing cache directory elsewhere
fjwillemsen 9dea137
Non-argument streams are now correctly passed in the CuPy and NVCUDA …
fjwillemsen df54145
Fixed several issues pertaining to the setting of clocks, in particul…
fjwillemsen 4cc4a13
Time spent setting NVML parameters (clock & memory frequency, power) …
fjwillemsen e309bc1
Time spent setting NVML parameters (clock & memory frequency, power) …
fjwillemsen d6aac8b
Removed redundant print statement
fjwillemsen a020791
Added L2 cache size property to CUDA backends
fjwillemsen 6e6e5fb
Added specification to CUPY compiler options
fjwillemsen f15338f
Added L2 cache size property to OpenCL, HIP and mocked PyCUDA backends
fjwillemsen 00ac419
Added function to check for compute capability validity, improved che…
fjwillemsen 55ab074
Added a flush kernel to clear the L2 cache between runs
fjwillemsen e106bae
Added a flush kernel to clear the L2 cache between runs
fjwillemsen 0cb5e3a
Made function for scaling the compute capability to a valid one, adde…
fjwillemsen b682506
Applied suggestions from comments by @csbnw
fjwillemsen da907b1
Removed redundant comments / printing
fjwillemsen 2396bdf
Added L2 cache size information to backends
fjwillemsen eced775
Added L2 flush kernel
fjwillemsen 143889f
Switched to new attempt for flushing L2 using memset
fjwillemsen 651eea7
Added implementation of allocate numpy array function
fjwillemsen 7d8d48f
Added new flush L2 cache method using memset
fjwillemsen 9911f4c
Added a standard method for freeing memory from the GPU
fjwillemsen 47c2cca
Circumvented an issue where list.remove(val) was not properly impleme…
fjwillemsen 157ca41
Added the ability to recopy array arguments with every kernel launch,…
fjwillemsen 98afa60
Renamed to for clarity, added check
fjwillemsen cfecdc5
Improved getting L2 cache size
fjwillemsen 108e14c
Small improvements to flushing arrays
fjwillemsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -339,8 +339,10 @@ def __init__( | |||
self.max_threads = dev.max_threads | ||||
self.flush_possible = lang.upper() not in ['OPENCL', 'HIP', 'C', 'FORTRAN'] and isinstance(self.dev.cache_size_L2, int) and self.dev.cache_size_L2 > 0 | ||||
if self.flush_possible: | ||||
t = np.int32 | ||||
self.flush_array = np.zeros((self.dev.cache_size_L2 // t(0).itemsize), order='F').astype(t) | ||||
self.flush_type = np.uint8 | ||||
size = (self.dev.cache_size_L2 // self.flush_type(0).itemsize) | ||||
# self.flush_array = np.zeros((size), order='F', dtype=self.flush_type) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
self.flush_array = np.empty((size), order='F', dtype=self.flush_type) | ||||
self.flush_alloc = None | ||||
if not quiet: | ||||
print("Using: " + self.dev.name) | ||||
|
@@ -353,7 +355,7 @@ def flush_cache(self): | |||
self.dev.free_mem(self.flush_alloc) | ||||
# inspired by https://github.com/NVIDIA/nvbench/blob/main/nvbench/detail/l2flush.cuh#L51 | ||||
self.flush_alloc = self.dev.allocate_ndarray(self.flush_array) | ||||
self.dev.memset(self.flush_alloc, value=0, size=self.flush_array.nbytes) | ||||
self.dev.memset(self.flush_alloc, value=1, size=self.flush_array.nbytes) | ||||
|
||||
def benchmark_default(self, func, gpu_args, threads, grid, result, flush_cache=True, recopy_arrays=None): | ||||
""" | ||||
|
@@ -367,7 +369,7 @@ def benchmark_default(self, func, gpu_args, threads, grid, result, flush_cache=T | |||
] | ||||
|
||||
self.dev.synchronize() | ||||
for _ in range(self.iterations): | ||||
for i in range(self.iterations): | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||
if flush_cache: | ||||
self.flush_cache() | ||||
if recopy_arrays is not None: | ||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also cast this to
int
for consistency?