o
    i
                     @   sp   d dl Zd dlmZ eddZ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,total)      c                   @   s    e Zd Zdd Zedd ZdS )FakeCUDADevicec                 C   s
   d| _ d S )Nz(GPU-00000000-0000-0000-0000-000000000000)uuidself r
   b/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/numba/cuda/simulator/cudadrv/devices.py__init__
      
zFakeCUDADevice.__init__c                 C      t S N_SIMULATOR_CCr   r
   r
   r   compute_capability      z!FakeCUDADevice.compute_capabilityN)__name__
__module____qualname__r   propertyr   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 r   )
_device_idr   _device)r	   	device_idr
   r
   r   r      s   zFakeCUDAContext.__init__c                 C      d S r   r
   r   r
   r
   r   	__enter__      zFakeCUDAContext.__enter__c                 C   r   r   r
   )r	   exc_typeexc_valexc_tbr
   r
   r   __exit__   r   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      | j S r   )r   r   r
   r
   r   id$      zFakeCUDAContext.idc                 C   r%   r   )r   r   r
   r
   r   device(   r'   zFakeCUDAContext.devicec                 C   r   r   r   r   r
   r
   r   r   ,   r   z"FakeCUDAContext.compute_capabilityc                 C   r   r   r
   r   r
   r
   r   reset0   r   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_info3   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)dtype)npndarray)r	   szr
   r
   r   memalloc;   s   zFakeCUDAContext.memallocFc                 C   s
   |  |S )zAllocates memory on the host)r2   )r	   r1   mappedportablewcr
   r
   r   memhostallocC   s   
zFakeCUDAContext.memhostallocN)FFF)r   r   r   __doc__r   r   r"   r$   r   r&   r(   r   r)   r,   r2   r6   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   N   s   
zFakeDeviceList.__init__c                 C   s   d| _ | j| S )NFr:   r9   )r	   devnumr
   r
   r   __getitem__R   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>W   s    z*FakeDeviceList.__str__.<locals>.<listcomp>)joinr9   r   r
   r
   r   r$   V   s   zFakeDeviceList.__str__c                 C   
   t | jS r   )iterr9   r   r
   r
   r   __iter__Y   r   zFakeDeviceList.__iter__c                 C   rC   r   )lenr9   r   r
   r
   r   __len__\   r   zFakeDeviceList.__len__c                 C   s   | j rd S | jd S )Nr   r;   r   r
   r
   r   current_   s   
zFakeDeviceList.currentN)r   r   r   r7   r   r=   r$   rE   rG   r   rH   r
   r
   r
   r   r8   H   s    r8   c                   C   s   dt d _d S )NTr   )gpusr:   r
   r
   r
   r   r)   i   s   r)   c                 C   s   t | S r   )r   )r<   r
   r
   r   get_contextm   s   rJ   c                 C   s   | S )zP
    In the simulator, a context is always "available", so this is a no-op.
    r
   )funcr
   r
   r   require_contextq   s   rL   )r   )numpyr/   collectionsr   r   r   r   r   r8   rI   r)   rJ   rL   r
   r
   r
   r   <module>   s    
	6
