Skip to content

Commit 2a8b536

Browse files
Copilotkkraus14
andcommitted
Address code review feedback: move skip logic, add docstring note, update release note
Co-authored-by: kkraus14 <3665167+kkraus14@users.noreply.github.com>
1 parent 3e50d07 commit 2a8b536

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

cuda_core/cuda/core/experimental/_memory.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,13 @@ class DeviceMemoryResource(MemoryResource):
318318
Device ordinal for which a memory resource is constructed. The mempool that is
319319
set to *current* on ``device_id`` is used. If no mempool is set to current yet,
320320
the driver would use the *default* mempool on the device.
321+
322+
Notes
323+
-----
324+
During initialization, this class automatically configures the memory pool's release
325+
threshold for improved performance. If the current threshold is 0 (default), it is
326+
set to the maximum value to prevent immediate memory release when there are no active
327+
allocations, which can cause performance degradation.
321328
"""
322329

323330
__slots__ = ("_dev_id",)

cuda_core/docs/source/release/0.X.Y-notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ None.
3636
Fixes and enhancements
3737
----------------------
3838

39-
- Improved :class:`DeviceMemoryResource` allocation performance when there are no active allocations (addresses issue #771).
39+
- Improved :class:`DeviceMemoryResource` allocation performance when there are no active allocations by setting a higher release threshold (addresses issue #771).
4040
- Fix :class:`LaunchConfig` grid unit conversion when cluster is set (addresses issue #867).

cuda_core/tests/test_memory.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,15 @@ def test_buffer_dunder_dlpack_device_failure():
259259
buffer.__dlpack_device__()
260260

261261

262-
@pytest.mark.skipif(not Device().properties.memory_pools_supported, reason="memory pools not supported")
263262
def test_device_memory_resource_initialization():
264263
"""Test that DeviceMemoryResource can be initialized successfully.
265264
266265
This test verifies that the DeviceMemoryResource initializes properly,
267266
including the release threshold configuration for performance optimization.
268267
"""
269268
device = Device()
269+
if not device.properties.memory_pools_supported:
270+
pytest.skip("memory pools not supported")
270271
device.set_current()
271272

272273
# This should succeed and configure the memory pool release threshold

0 commit comments

Comments
 (0)