Skip to content

Commit 2afcb20

Browse files
committed
cache cc to speed it up
1 parent 1e1148b commit 2afcb20

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

cuda_core/cuda/core/experimental/_device.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,13 +1029,11 @@ def properties(self) -> DeviceProperties:
10291029
@property
10301030
def compute_capability(self) -> ComputeCapability:
10311031
"""Return a named tuple with 2 fields: major and minor."""
1032-
major = handle_return(
1033-
runtime.cudaDeviceGetAttribute(runtime.cudaDeviceAttr.cudaDevAttrComputeCapabilityMajor, self._id)
1034-
)
1035-
minor = handle_return(
1036-
runtime.cudaDeviceGetAttribute(runtime.cudaDeviceAttr.cudaDevAttrComputeCapabilityMinor, self._id)
1037-
)
1038-
return ComputeCapability(major, minor)
1032+
if "compute_capability" in self.properties._cache:
1033+
return self.properties._cache["compute_capability"]
1034+
cc = ComputeCapability(self.properties.compute_capability_major, self.properties.compute_capability_minor)
1035+
self.properties._cache["compute_capability"] = cc
1036+
return cc
10391037

10401038
@property
10411039
@precondition(_check_context_initialized)

0 commit comments

Comments
 (0)