U
    ?h                     @   sD   d dl Z d dlmZmZ edG dd deZedkr@e   dS )    N)CUDATestCaseskip_on_cudasimz4cudasim doesn't support cuda import at non-top-levelc                   @   s   e Zd Zdd ZdS )
TestRandomc                    s  ddl m  ddlm}m dd l} j fdd}d\}}}d\}}}	d\}
}}|| |	 |
 | | }||d	d
} j|||f|jd}||
||f|||	ff || |	 }| 
||d | ||d | ||dk | ||dk d S )Nr   )cuda)create_xoroshiro128p_statesxoroshiro128p_uniform_float32c                    s     d\}}} d\}}}|| | ||  | }t|| jd |D ]H}	t|| jd |D ]0}
t|| jd |D ]}||| |	|
|f< qvq`qJd S )N   r         )gridZgridsizerangeshape)arr
rng_statesZstartxZstartyZstartzZstridexZstrideyZstrideztidijkr   r    [/var/www/html/venv/lib/python3.8/site-packages/numba/cuda/tests/doc_examples/test_random.py	random_3d   s    z-TestRandom.test_ex_3d_grid.<locals>.random_3d)i  i  i  )   r   r   )   r   r   r	   )seed)Zdtypeg\(\?gRQ?g      ?g        )Znumbar   Znumba.cuda.randomr   r   numpyZjitZdevice_arrayZfloat32Zcopy_to_hostZassertGreaterZmeanZ
assertLessZ
assertTrueall)selfr   npr   XYZZbxZbyZbzZgxgygzZnthreadsr   r   Zhost_arrr   r   r   test_ex_3d_grid
   s"    


zTestRandom.test_ex_3d_gridN)__name__
__module____qualname__r$   r   r   r   r   r      s   r   __main__)ZunittestZnumba.cuda.testingr   r   r   r%   mainr   r   r   r   <module>   s
   1