# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_graph_memory_resource.pyx

from __future__ import annotations

from cuda.core._device import Device
from cuda.core._memory._buffer import Buffer, MemoryResource
from cuda.core._stream import Stream
from cuda.core.graph import GraphBuilder
from cuda.core.typing import DevicePointerType


class GraphMemoryResourceAttributes:

    def __init__(self, *args, **kwargs) -> None:
        ...

    @classmethod
    def _init(cls, device_id: int) -> GraphMemoryResourceAttributes:
        ...

    def __repr__(self) -> str:
        ...

    @property
    def reserved_mem_current(self) -> int:
        """Current amount of backing memory allocated."""

    @property
    def reserved_mem_high(self) -> int:
        """
        High watermark of backing memory allocated. It can be set to zero to
        reset it to the current usage.
        """

    @reserved_mem_high.setter
    def reserved_mem_high(self, value: int) -> None:
        ...

    @property
    def used_mem_current(self) -> int:
        """Current amount of memory in use."""

    @property
    def used_mem_high(self) -> int:
        """
        High watermark of memory in use. It can be set to zero to reset it to
        the current usage.
        """

    @used_mem_high.setter
    def used_mem_high(self, value: int) -> None:
        ...

class cyGraphMemoryResource(MemoryResource):

    def __cinit__(self, device_id: int) -> None:
        ...

    def allocate(self, size: int, *, stream: Stream | GraphBuilder) -> Buffer:
        """
        Allocate a buffer of the requested size. See documentation for :obj:`~_memory.MemoryResource`.
        """

    def deallocate(self, ptr: DevicePointerType, size: int, *, stream: Stream | GraphBuilder) -> None:
        """
        Deallocate a buffer of the requested size. See documentation for :obj:`~_memory.MemoryResource`.
        """

    def close(self) -> None:
        """No operation (provided for compatibility)."""

    def trim(self) -> None:
        """Free unused memory that was cached on the specified device for use with graphs back to the OS."""

    @property
    def attributes(self) -> GraphMemoryResourceAttributes:
        """Asynchronous allocation attributes related to graphs."""

    @property
    def device_id(self) -> int:
        """The associated device ordinal."""

    @property
    def is_device_accessible(self) -> bool:
        """Return True. This memory resource provides device-accessible buffers."""

    @property
    def is_host_accessible(self) -> bool:
        """Return False. This memory resource does not provide host-accessible buffers."""

class GraphMemoryResource(cyGraphMemoryResource):
    """
    A memory resource for memory related to graphs.

    The only supported operations are allocation, deallocation, and a limited
    set of status queries.

    This memory resource should be used when building graphs.  Using this when
    graphs capture is not enabled will result in a runtime error.

    Conversely, allocating memory from a `DeviceMemoryResource` when graph
    capturing is enabled results in a runtime error.

    Parameters
    ----------
    device_id: int | Device
        Device or Device ordinal for which a graph memory resource is obtained.
    """

    def __new__(cls, device_id: int | Device) -> GraphMemoryResource:
        ...

    @classmethod
    def _create(cls, device_id: int) -> GraphMemoryResource:
        ...
__all__ = ['GraphMemoryResource']