@@ -302,6 +302,25 @@ class Mempool(MemoryResource):
302302 Use the static methods `create` or `from_shared_handle` to instantiate a Mempool.
303303 Direct instantiation is not supported.
304304
305+ Properties
306+ ----------
307+ reuse_follow_event_dependencies : bool
308+ Allow memory to be reused when there are event dependencies between streams.
309+ reuse_allow_opportunistic : bool
310+ Allow reuse of completed frees without dependencies.
311+ reuse_allow_internal_dependencies : bool
312+ Allow insertion of new stream dependencies for memory reuse.
313+ release_threshold : int
314+ Amount of reserved memory to hold before OS release.
315+ reserved_mem_current : int
316+ Current amount of backing memory allocated.
317+ reserved_mem_high : int
318+ High watermark of backing memory allocated.
319+ used_mem_current : int
320+ Current amount of memory in use.
321+ used_mem_high : int
322+ High watermark of memory in use.
323+
305324 See Also
306325 --------
307326 create : Create a new memory pool
@@ -590,38 +609,85 @@ def device_id(self) -> int:
590609 """
591610 return self ._dev_id
592611
593- def get_attribute (self , attr : driver .CUmemPool_attribute ) -> int :
594- """Get a memory pool attribute.
612+ @property
613+ def reuse_follow_event_dependencies (self ) -> bool :
614+ """Allow memory to be reused when there are event dependencies between streams."""
615+ return bool (
616+ handle_return (
617+ driver .cuMemPoolGetAttribute (
618+ self ._handle , driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES
619+ )
620+ )
621+ )
595622
596- Parameters
597- ----------
598- attr : CUmemPool_attribute
599- The attribute to query. Supported attributes are:
600- - CU_MEMPOOL_ATTR_RELEASE_THRESHOLD: Amount of reserved memory to hold before releasing
601- - CU_MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES: Allow reuse with event dependencies
602- - CU_MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC: Allow reuse without dependencies
603- - CU_MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES: Allow reuse with internal dependencies
604- - CU_MEMPOOL_ATTR_RESERVED_MEM_CURRENT: Current reserved memory
605- - CU_MEMPOOL_ATTR_RESERVED_MEM_HIGH: High watermark of reserved memory
606- - CU_MEMPOOL_ATTR_USED_MEM_CURRENT: Current used memory
607- - CU_MEMPOOL_ATTR_USED_MEM_HIGH: High watermark of used memory
623+ @property
624+ def reuse_allow_opportunistic (self ) -> bool :
625+ """Allow reuse of completed frees without dependencies."""
626+ return bool (
627+ handle_return (
628+ driver .cuMemPoolGetAttribute (
629+ self ._handle , driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC
630+ )
631+ )
632+ )
608633
609- Returns
610- -------
611- int
612- The value of the requested attribute
634+ @property
635+ def reuse_allow_internal_dependencies (self ) -> bool :
636+ """Allow insertion of new stream dependencies for memory reuse."""
637+ return bool (
638+ handle_return (
639+ driver .cuMemPoolGetAttribute (
640+ self ._handle , driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES
641+ )
642+ )
643+ )
613644
614- Raises
615- ------
616- CUDAError
617- If the attribute query fails
645+ @property
646+ def release_threshold (self ) -> int :
647+ """Amount of reserved memory to hold before OS release."""
648+ return int (
649+ handle_return (
650+ driver .cuMemPoolGetAttribute (self ._handle , driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_RELEASE_THRESHOLD )
651+ )
652+ )
618653
619- Notes
620- -----
621- The meaning and units of the returned value depend on the specific attribute
622- being queried. See the CUDA documentation for details on each attribute.
623- """
624- return handle_return (driver .cuMemPoolGetAttribute (self ._handle , attr ))
654+ @property
655+ def reserved_mem_current (self ) -> int :
656+ """Current amount of backing memory allocated."""
657+ return int (
658+ handle_return (
659+ driver .cuMemPoolGetAttribute (
660+ self ._handle , driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_RESERVED_MEM_CURRENT
661+ )
662+ )
663+ )
664+
665+ @property
666+ def reserved_mem_high (self ) -> int :
667+ """High watermark of backing memory allocated."""
668+ return int (
669+ handle_return (
670+ driver .cuMemPoolGetAttribute (self ._handle , driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_RESERVED_MEM_HIGH )
671+ )
672+ )
673+
674+ @property
675+ def used_mem_current (self ) -> int :
676+ """Current amount of memory in use."""
677+ return int (
678+ handle_return (
679+ driver .cuMemPoolGetAttribute (self ._handle , driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_USED_MEM_CURRENT )
680+ )
681+ )
682+
683+ @property
684+ def used_mem_high (self ) -> int :
685+ """High watermark of memory in use."""
686+ return int (
687+ handle_return (
688+ driver .cuMemPoolGetAttribute (self ._handle , driver .CUmemPool_attribute .CU_MEMPOOL_ATTR_USED_MEM_HIGH )
689+ )
690+ )
625691
626692
627693class _DefaultAsyncMempool (MemoryResource ):
0 commit comments