Skip to content

Commit a020791

Browse files
committed
Added L2 cache size property to CUDA backends
1 parent d6aac8b commit a020791

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

kernel_tuner/backends/cupy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(self, device=0, iterations=7, compiler_options=None, observers=None
4646
self.devprops = dev.attributes
4747
self.cc = dev.compute_capability
4848
self.max_threads = self.devprops["MaxThreadsPerBlock"]
49+
self.cache_size_L2 = self.devprops["L2CacheSize"]
4950

5051
self.iterations = iterations
5152
self.current_module = None

kernel_tuner/backends/nvcuda.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ def __init__(self, device=0, iterations=7, compiler_options=None, observers=None
6666
cudart.cudaDeviceAttr.cudaDevAttrMaxThreadsPerBlock, device
6767
)
6868
cuda_error_check(err)
69+
err, self.cache_size_L2 = cudart.cudaDeviceGetAttribute(
70+
cudart.cudaDeviceAttr.cudaDevAttrL2CacheSize, device
71+
)
72+
cuda_error_check(err)
6973
self.cc = f"{major}{minor}"
7074
self.iterations = iterations
7175
self.current_module = None

kernel_tuner/backends/pycuda.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def _finish_up():
101101
str(k): v for (k, v) in self.context.get_device().get_attributes().items()
102102
}
103103
self.max_threads = devprops["MAX_THREADS_PER_BLOCK"]
104+
self.cache_size_L2 = devprops["L2_CACHE_SIZE"]
104105
cc = str(devprops.get("COMPUTE_CAPABILITY_MAJOR", "0")) + str(
105106
devprops.get("COMPUTE_CAPABILITY_MINOR", "0")
106107
)

0 commit comments

Comments
 (0)