
    J/Ph
                         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dS )    N)
namedtuple_MemoryInfoz
free,total)      c                   *    e Zd Zd Zed             ZdS )FakeCUDADevicec                     d| _         d S )Nz(GPU-00000000-0000-0000-0000-000000000000)uuidselfs    d/var/www/html/test/jupyter/venv/lib/python3.11/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>        ? ? ?   X  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 r   )
_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                     t           S r   r   r   s    r   r   z"FakeCUDAContext.compute_capability,   r   r   c                     d S r   r   r   s    r   resetzFakeCUDAContext.reset0   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_info3   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.memalloc;   s     z"D))))r   Fc                 ,    |                      |          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      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__N   s    #A&&(r   c                 *    d| _         | j        |         S )NFrH   rG   )r   devnums     r   __getitem__zFakeDeviceList.__getitem__R   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>W   s    333Q#a&&333r   )joinrG   r   s    r   r+   zFakeDeviceList.__str__V   s%    yy33$(333444r   c                 *    t          | j                  S r   )iterrG   r   s    r   __iter__zFakeDeviceList.__iter__Y   s    DH~~r   c                 *    t          | j                  S r   )lenrG   r   s    r   __len__zFakeDeviceList.__len__\   s    48}}r   c                 .    | j         rd S | j        d         S )Nr   rJ   r   s    r   currentzFakeDeviceList.current_   s    ; 	4x{r   N)r   r   r   rC   r   rL   r+   rV   rY   r   r[   r   r   r   rE   rE   H   s         
       5 5 5       X  r   rE   c                  *    dt           d         _        d S )NTr   )gpusrH   r   r   r   r2   r2   i   s    DGNNNr   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_contextrb   q   s	     Kr   )r   )numpyr:   collectionsr   r   r   r   r   rE   r]   r2   r_   rb   r   r   r   <module>re      s        " " " " " "j55       3! 3! 3! 3! 3! 3! 3! 3!l       < ~  # # # #    r   