
    xKg;                         d dl mZmZ d dlZd dlZd dlZdZdZdZdZ	dZ
 G d d	e      Zed
k(  r ej                          yy)    )CUDATestCaseskip_on_cudasimNzfrom numba import cuda

@cuda.jit
def cuhello():
    i = cuda.grid(1)
    print(i, 999)
    print(-42)

cuhello[2, 3]()
cuda.synchronize()
zfrom numba import cuda

@cuda.jit
def printfloat():
    i = cuda.grid(1)
    print(i, 23, 34.75, 321)

printfloat[1, 1]()
cuda.synchronize()
zfrom numba import cuda

@cuda.jit
def printstring():
    i = cuda.grid(1)
    print(i, "hop!", 999)

printstring[1, 3]()
cuda.synchronize()
zgfrom numba import cuda

@cuda.jit
def printempty():
    print()

printempty[1, 1]()
cuda.synchronize()
a  from numba import cuda
import numpy as np

@cuda.jit
def print_too_many(r):
    print(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10],
          r[11], r[12], r[13], r[14], r[15], r[16], r[17], r[18], r[19], r[20],
          r[21], r[22], r[23], r[24], r[25], r[26], r[27], r[28], r[29], r[30],
          r[31], r[32])

print_too_many[1, 1](np.arange(33))
cuda.synchronize()
c                   F    e Zd Zd Zd Zd Zd Zd Z ed      d        Z	y)		TestPrintc                     t         j                  d|g}t        j                  |ddd      }|j                  j                         |j                  j                         fS )z9Runs code in a subprocess and returns the captured outputz-c<   T)timeoutcapture_outputcheck)sys
executable
subprocessrunstdoutdecodestderr)selfcodecmdcps       f/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/cuda/tests/cudapy/test_print.pyrun_codezTestPrint.run_codeN   sK    ~~tT*^^CDMyy!299#3#3#555    c                    | j                  t              \  }}|j                         D cg c]  }|j                          }}dgdz  t	        d      D cg c]  }d|z  	 c}z   }| j                  t        |      |       y c c}w c c}w )Nz-42   z%d 999)r   cuhello_usecase
splitlinesstriprangeassertEqualsorted)r   output_lineactualiexpecteds          r   test_cuhellozTestPrint.test_cuhelloT   s    MM/2	+1+<+<+>?+>4$**,+>?7Q;a!A1(Q,!AA 	2	 @!As   BBc                 |    | j                  t              \  }}ddg}| j                  |j                         |       y )Nz0 23 34.750000 321z0 23 34.75 321)r   printfloat_usecaseassertInr   )r   r"   r#   expected_casess       r   test_printfloatzTestPrint.test_printfloat\   s4    MM"45	.0@Afllnn5r   c                 t    | j                  t              \  }}| j                  |j                         d       y )N )r   printempty_usecaser    r   )r   r"   r#   s      r   test_printemptyzTestPrint.test_printemptyb   s+    MM"45	,r   c                    | j                  t              \  }}|j                  d      D cg c]  }|j                          }}t	        d      D cg c]  }d|z  	 }}| j                  t        |      |       y c c}w c c}w )NT   z%d hop! 999)r   printstring_usecaser   r   r   r    r!   )r   r"   r#   r$   linesr&   r'   s          r   test_stringzTestPrint.test_stringf   sv    MM"56	*0*;*;D*AB*A$*AB/4Qx8x!MA%x81 C8s   A<Bz"cudasim can print unlimited outputc                     | j                  t              \  }}dj                  t        d      D cg c]  }d c}      }| j	                  ||       d}| j	                  ||       y c c}w )N !   z%lldzjCUDA print() cannot print more than 32 items. The raw format string will be emitted by the kernel instead.)r   print_too_many_usecasejoinr   r+   )r   r"   errorsr#   expected_fmt_stringwarn_msgs         r   test_too_many_argszTestPrint.test_too_many_argsl   sf     '=> "hhb	'B	1	'BC)62Kh' (Cs   	A(N)
__name__
__module____qualname__r   r(   r-   r1   r6   r   r?    r   r   r   r   J   s5    636-2 9:( ;(r   r   __main__)numba.cuda.testingr   r   r   r   unittestr   r*   r4   r0   r:   r   r@   mainrC   r   r   <module>rH      s_    <  
 
 
 	   2( 2(j zHMMO r   