Skip to content

Commit b343a50

Browse files
Copilotleofang
andcommitted
Remove try-except wrapper and performance demo per code review feedback
Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
1 parent 547129b commit b343a50

2 files changed

Lines changed: 12 additions & 89 deletions

File tree

cuda_core/cuda/core/experimental/_memory.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -329,24 +329,19 @@ def __init__(self, device_id: int):
329329
# Set a higher release threshold to improve performance when there are no active allocations.
330330
# By default, the release threshold is 0, which means memory is immediately released back
331331
# to the OS when there are no active suballocations, causing performance issues.
332-
try:
333-
# Check current release threshold
334-
current_threshold = handle_return(
335-
driver.cuMemPoolGetAttribute(self._handle, driver.CUmemPool_attribute.CU_MEMPOOL_ATTR_RELEASE_THRESHOLD)
336-
)
337-
# If threshold is 0 (default), set it to maximum to retain memory in the pool
338-
if int(current_threshold) == 0:
339-
handle_return(
340-
driver.cuMemPoolSetAttribute(
341-
self._handle,
342-
driver.CUmemPool_attribute.CU_MEMPOOL_ATTR_RELEASE_THRESHOLD,
343-
driver.cuuint64_t(0xFFFFFFFFFFFFFFFF),
344-
)
332+
# Check current release threshold
333+
current_threshold = handle_return(
334+
driver.cuMemPoolGetAttribute(self._handle, driver.CUmemPool_attribute.CU_MEMPOOL_ATTR_RELEASE_THRESHOLD)
335+
)
336+
# If threshold is 0 (default), set it to maximum to retain memory in the pool
337+
if int(current_threshold) == 0:
338+
handle_return(
339+
driver.cuMemPoolSetAttribute(
340+
self._handle,
341+
driver.CUmemPool_attribute.CU_MEMPOOL_ATTR_RELEASE_THRESHOLD,
342+
driver.cuuint64_t(0xFFFFFFFFFFFFFFFF),
345343
)
346-
except Exception:
347-
# If setting the attribute fails (e.g., on older drivers), continue without error
348-
# to maintain backward compatibility
349-
pass
344+
)
350345

351346
def allocate(self, size: int, stream: Stream = None) -> Buffer:
352347
"""Allocate a buffer of the requested size.

cuda_core/examples/memory_performance_demo.py

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)