cuda.core._memory._managed_buffer.AccessedBySetProxy#

class cuda.core._memory._managed_buffer.AccessedBySetProxy(
buf: ManagedBuffer,
)#

Live driver-backed view of set_accessed_by advice for a managed buffer.

Reads (__contains__, __iter__, len(...)) call cuMemRangeGetAttribute; writes (add, discard) call cuMemAdvise. There is no in-memory mirror, so the view always reflects the current driver state.

Note

The driver returns integer device ordinals (-1 for host); host NUMA distinctions applied via Host(numa_id=...) collapse to a generic Host() when iterating this set.

Methods

__init__(
buf: ManagedBuffer,
)#
add(
location: Device | Host,
) None#

Apply set_accessed_by advice for location.

clear()#

This is slow (creates N new iterators!) but effective.

discard(
location: Device | Host,
) None#

Apply unset_accessed_by advice for location.

Per the MutableSet contract, discard is a no-op for elements not in the set. set_accessed_by only accepts Device and the generic Host() — NUMA-aware host variants (Host(numa_id=...), Host.numa_current()) can never enter the set, so discarding them is silently ignored rather than forwarded to the driver.

isdisjoint(other)#

Return True if two sets have a null intersection.

pop()#

Return the popped value. Raise KeyError if empty.

remove(value)#

Remove an element. If not a member, raise a KeyError.