
    xKg
                         d dl Zd dlmZ  edd      ZdZ G d d      Z G d d	      Z G d
 d      Z e       Z	d Z
ddZd Zy)    N)
namedtuple_MemoryInfoz
free,total)      c                   "    e Zd Zd Zed        Zy)FakeCUDADevicec                     d| _         y )Nz(GPU-00000000-0000-0000-0000-000000000000)uuidselfs    h/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/cuda/simulator/cudadrv/devices.py__init__zFakeCUDADevice.__init__
   s	    >	    c                     t         S N_SIMULATOR_CCr   s    r   compute_capabilityz!FakeCUDADevice.compute_capability       r   N)__name__
__module____qualname__r   propertyr    r   r   r   r   	   s    ?  r   r   c                   r    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y)FakeCUDAContextz`
    This stub implements functionality only for simulating a single GPU
    at the moment.
    c                 0    || _         t               | _        y r   )
_device_idr   _device)r   	device_ids     r   r   zFakeCUDAContext.__init__   s    #%'r   c                      y r   r   r   s    r   	__enter__zFakeCUDAContext.__enter__       r   c                      y r   r   )r   exc_typeexc_valexc_tbs       r   __exit__zFakeCUDAContext.__exit__   r#   r   c                 &    dj                  |       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                     t         S r   r   r   s    r   r   z"FakeCUDAContext.compute_capability,   r   r   c                      y r   r   r   s    r   resetzFakeCUDAContext.reset0   r#   r   c                 >    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_info3   s     5<u66r   c                 0    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.memalloc;   s     zz"D))r   c                 $    | j                  |      S )zAllocates memory on the host)r=   )r   r<   mappedportablewcs        r   memhostalloczFakeCUDAContext.memhostallocC   s    }}R  r   N)FFF)r   r   r   __doc__r   r"   r(   r+   r   r-   r/   r   r2   r6   r=   rB   r   r   r   r   r      sk    (>      7*!r   r   c                   >    e Zd ZdZd Zd Zd Zd Zd Ze	d        Z
y)	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                 4    t        d      f| _        d| _        y )Nr   F)r   lstclosedr   s    r   r   zFakeDeviceList.__init__N   s    #A&(r   c                 .    d| _         | j                  |   S )NFrH   rG   )r   devnums     r   __getitem__zFakeDeviceList.__getitem__R   s    xxr   c                 p    dj                  | j                  D cg c]  }t        |       c}      S c c}w )Nz, )joinrG   str)r   ds     r   r+   zFakeDeviceList.__str__V   s+    yy$((3(Q#a&(3443s   3c                 ,    t        | j                        S r   )iterrG   r   s    r   __iter__zFakeDeviceList.__iter__Y   s    DHH~r   c                 ,    t        | j                        S r   )lenrG   r   s    r   __len__zFakeDeviceList.__len__\   s    488}r   c                 :    | j                   ry | j                  d   S )Nr   rJ   r   s    r   currentzFakeDeviceList.current_   s    ;;xx{r   N)r   r   r   rC   r   rL   r+   rS   rV   r   rX   r   r   r   rE   rE   H   s4    
 5  r   rE   c                       dt         d   _        y )NTr   )gpusrH   r   r   r   r2   r2   i   s    DGNr   c                     t        |       S r   )r   )rK   s    r   get_contextr\   m   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_   q   s	     Kr   )r   )numpyr:   collectionsr   r   r   r   r   rE   rZ   r2   r\   r_   r   r   r   <module>rb      sT     "5 3! 3!l < #r   