U
    9%e
                     @   sl   d dl Zd dlmZ eddZG dd dZG dd dZG d	d
 d
Ze Zdd Z	dddZ
dd ZdS )    N)
namedtuple_MemoryInfoz
free,totalc                   @   s   e Zd Zdd ZdS )FakeCUDADevicec                 C   s
   d| _ d S )Nz(GPU-00000000-0000-0000-0000-000000000000)uuidself r   c/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/numba/cuda/simulator/cudadrv/devices.py__init__   s    zFakeCUDADevice.__init__N)__name__
__module____qualname__r
   r   r   r   r	   r      s   r   c                   @   sv   e Zd ZdZdd Zdd Zdd Zdd	 Zed
d Z	edd Z
edd Zdd Zdd Zdd ZdddZdS )FakeCUDAContextz`
    This stub implements functionality only for simulating a single GPU
    at the moment.
    c                 C   s   || _ t | _d S N)
_device_idr   _device)r   Z	device_idr   r   r	   r
      s    zFakeCUDAContext.__init__c                 C   s   d S r   r   r   r   r   r	   	__enter__   s    zFakeCUDAContext.__enter__c                 C   s   d S r   r   )r   exc_typeexc_valexc_tbr   r   r	   __exit__   s    zFakeCUDAContext.__exit__c                 C   s   dj | dS )Nz<Managed Device {self.id}>r   )formatr   r   r   r	   __str__   s    zFakeCUDAContext.__str__c                 C   s   | j S r   )r   r   r   r   r	   id   s    zFakeCUDAContext.idc                 C   s   | j S r   )r   r   r   r   r	   device"   s    zFakeCUDAContext.devicec                 C   s   dS )N)      r   r   r   r   r	   compute_capability&   s    z"FakeCUDAContext.compute_capabilityc                 C   s   d S r   r   r   r   r   r	   reset*   s    zFakeCUDAContext.resetc                 C   s   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   r   r   r	   get_memory_info-   s    zFakeCUDAContext.get_memory_infoc                 C   s   t j|ddS )z
        Allocates memory on the simulated device
        At present, there is no division between simulated
        host memory and simulated device memory.
        u1)Zdtype)npZndarray)r   szr   r   r	   memalloc5   s    zFakeCUDAContext.memallocFc                 C   s
   |  |S )zAllocates memory on the host)r%   )r   r$   ZmappedZportablewcr   r   r	   memhostalloc=   s    zFakeCUDAContext.memhostallocN)FFF)r   r   r   __doc__r
   r   r   r   propertyr   r   r   r   r!   r%   r'   r   r   r   r	   r      s   


r   c                   @   sD   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Ze	d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                 C   s   t df| _d| _d S )Nr   F)r   lstclosedr   r   r   r	   r
   H   s    zFakeDeviceList.__init__c                 C   s   d| _ | j| S )NFr,   r+   )r   devnumr   r   r	   __getitem__L   s    zFakeDeviceList.__getitem__c                 C   s   d dd | jD S )Nz, c                 S   s   g | ]}t |qS r   )str).0dr   r   r	   
<listcomp>Q   s     z*FakeDeviceList.__str__.<locals>.<listcomp>)joinr+   r   r   r   r	   r   P   s    zFakeDeviceList.__str__c                 C   s
   t | jS r   )iterr+   r   r   r   r	   __iter__S   s    zFakeDeviceList.__iter__c                 C   s
   t | jS r   )lenr+   r   r   r   r	   __len__V   s    zFakeDeviceList.__len__c                 C   s   | j r
d S | jd S )Nr   r-   r   r   r   r	   currentY   s    zFakeDeviceList.currentN)r   r   r   r(   r
   r/   r   r6   r8   r)   r9   r   r   r   r	   r*   B   s   r*   c                   C   s   dt d _d S )NTr   )gpusr,   r   r   r   r	   r   c   s    r   c                 C   s   t | S r   )r   )r.   r   r   r	   get_contextg   s    r;   c                 C   s   | S )zP
    In the simulator, a context is always "available", so this is a no-op.
    r   )funcr   r   r	   require_contextk   s    r=   )r   )numpyr#   collectionsr   r   r   r   r*   r:   r   r;   r=   r   r   r   r	   <module>   s   
6
