U
    hâËd
  ã                   @   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   ú]/home/sam/Atlas/atlas_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
