
    ܙd
                         d dl Zd dlmZ  edd          Z G d d          Z G d d          Z G d	 d
          Z e            Zd Z	ddZ
d ZdS )    N)
namedtuple_MemoryInfoz
free,totalc                       e Zd Zd ZdS )FakeCUDADevicec                     d| _         d S )Nz(GPU-00000000-0000-0000-0000-000000000000)uuidselfs    Dlib/python3.11/site-packages/numba/cuda/simulator/cudadrv/devices.py__init__zFakeCUDADevice.__init__   s    >			    N)__name__
__module____qualname__r    r   r   r   r      s#        ? ? ? ? ?r   r   c                       e Zd ZdZd Zd Zd Zd Zed             Z	ed             Z
ed             Zd	 Zd
 Zd ZddZdS )FakeCUDAContextz`
    This stub implements functionality only for simulating a single GPU
    at the moment.
    c                 :    || _         t                      | _        d S N)
_device_idr   _device)r
   	device_ids     r   r   zFakeCUDAContext.__init__   s    #%''r   c                     d S r   r   r	   s    r   	__enter__zFakeCUDAContext.__enter__       r   c                     d S r   r   )r
   exc_typeexc_valexc_tbs       r   __exit__zFakeCUDAContext.__exit__   r   r   c                 .    d                     |           S )Nz<Managed Device {self.id}>r	   )formatr	   s    r   __str__zFakeCUDAContext.__str__   s    +222===r   c                     | j         S r   )r   r	   s    r   idzFakeCUDAContext.id   s
    r   c                     | j         S r   )r   r	   s    r   devicezFakeCUDAContext.device"   s
    |r   c                     dS )N)      r   r	   s    r   compute_capabilityz"FakeCUDAContext.compute_capability&   s    vr   c                     d S r   r   r	   s    r   resetzFakeCUDAContext.reset*   r   r   c                 V    t          t          d          t          d                    S )z
        Cross-platform free / total host memory is hard without external
        dependencies, e.g. `psutil` - so return infinite memory to maintain API
        type compatibility
        inf)r   floatr	   s    r   get_memory_infozFakeCUDAContext.get_memory_info-   s      5<<u666r   c                 .    t          j        |d          S )z
        Allocates memory on the simulated device
        At present, there is no division between simulated
        host memory and simulated device memory.
        u1)dtype)npndarray)r
   szs     r   memalloczFakeCUDAContext.memalloc5   s     z"D))))r   Fc                 ,    |                      |          S )zAllocates memory on the host)r8   )r
   r7   mappedportablewcs        r   memhostalloczFakeCUDAContext.memhostalloc=   s    }}R   r   N)FFF)r   r   r   __doc__r   r   r    r#   propertyr%   r'   r+   r-   r1   r8   r=   r   r   r   r   r      s         ( ( (    > > >   X   X   X  7 7 7* * *! ! ! ! ! !r   r   c                   F    e Zd ZdZd Zd Zd Zd Zd Ze	d             Z
dS )	FakeDeviceListz
    This stub implements a device list containing a single GPU. It also
    keeps track of the GPU status, i.e. whether the context is closed or not,
    which may have been set by the user calling reset()
    c                 >    t          d          f| _        d| _        d S )Nr   F)r   lstclosedr	   s    r   r   zFakeDeviceList.__init__H   s    #A&&(r   c                 *    d| _         | j        |         S )NFrD   rC   )r
   devnums     r   __getitem__zFakeDeviceList.__getitem__L   s    xr   c                 J    d                     d | j        D                       S )Nz, c                 ,    g | ]}t          |          S r   )str).0ds     r   
<listcomp>z*FakeDeviceList.__str__.<locals>.<listcomp>Q   s    333Q#a&&333r   )joinrC   r	   s    r   r#   zFakeDeviceList.__str__P   s%    yy33$(333444r   c                 *    t          | j                  S r   )iterrC   r	   s    r   __iter__zFakeDeviceList.__iter__S   s    DH~~r   c                 *    t          | j                  S r   )lenrC   r	   s    r   __len__zFakeDeviceList.__len__V   s    48}}r   c                 .    | j         rd S | j        d         S )Nr   rF   r	   s    r   currentzFakeDeviceList.currentY   s    ; 	4x{r   N)r   r   r   r>   r   rH   r#   rR   rU   r?   rW   r   r   r   rA   rA   B   s         
       5 5 5       X  r   rA   c                  *    dt           d         _        d S )NTr   )gpusrD   r   r   r   r-   r-   c   s    DGNNNr   c                      t          |           S r   )r   )rG   s    r   get_contextr[   g   s    6"""r   c                     | S )zP
    In the simulator, a context is always "available", so this is a no-op.
    r   )funcs    r   require_contextr^   k   s	     Kr   )r   )numpyr5   collectionsr   r   r   r   rA   rY   r-   r[   r^   r   r   r   <module>ra      s        " " " " " "j55? ? ? ? ? ? ? ?
3! 3! 3! 3! 3! 3! 3! 3!l       < ~  # # # #    r   