
    J/Ph;                         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                     dS dS )    )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                   T    e Zd Zd Zd Zd Zd Zd Z ed          d             Z	dS )		TestPrintc                     t           j        d|g}t          j        |ddd          }|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       b/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/cuda/tests/cudapy/test_print.pyrun_codezTestPrint.run_codeN   sO    ~tT*^CDMMMy!!29#3#3#5#555    c                    |                      t                    \  }}d |                                D             }dgdz  d t          d          D             z   }|                     t          |          |           d S )Nc                 6    g | ]}|                                 S  strip.0lines     r   
<listcomp>z*TestPrint.test_cuhello.<locals>.<listcomp>V   s     ???4$**,,???r   z-42   c                     g | ]}d |z  S )z%d 999r   r    is     r   r"   z*TestPrint.test_cuhello.<locals>.<listcomp>W   s    !A!A!A1(Q,!A!A!Ar   )r   cuhello_usecase
splitlinesrangeassertEqualsorted)r   output_actualexpecteds        r   test_cuhellozTestPrint.test_cuhelloT   s    MM/22	??6+<+<+>+>???7Q;!A!Aa!A!A!AA 	22222r   c                     |                      t                    \  }}ddg}|                     |                                |           d S )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\   sE    MM"455	.0@Afllnnn55555r   c                     |                      t                    \  }}|                     |                                d           d S )N )r   printempty_usecaser*   r   )r   r,   r-   s      r   test_printemptyzTestPrint.test_printemptyb   s<    MM"455	,,,,,r   c                     |                      t                    \  }}d |                    d          D             }d t          d          D             }|                     t          |          |           d S )Nc                 6    g | ]}|                                 S r   r   r   s     r   r"   z)TestPrint.test_string.<locals>.<listcomp>h   s     BBB$BBBr   Tc                     g | ]}d |z  S )z%d hop! 999r   r%   s     r   r"   z)TestPrint.test_string.<locals>.<listcomp>i   s    888!MA%888r      )r   printstring_usecaser(   r)   r*   r+   )r   r,   r-   linesr/   s        r   test_stringzTestPrint.test_stringf   st    MM"566	BB&*;*;D*A*ABBB88uQxx88811111r   z"cudasim can print unlimited outputc                     |                      t                    \  }}d                    d t          d          D                       }|                     ||           d}|                     ||           d S )N c                     g | ]}d S )z%lldr   )r    r-   s     r   r"   z0TestPrint.test_too_many_args.<locals>.<listcomp>v   s    'B'B'B1'B'B'Br   !   zjCUDA print() cannot print more than 32 items. The raw format string will be emitted by the kernel instead.)r   print_too_many_usecasejoinr)   r3   )r   r,   errorsexpected_fmt_stringwarn_msgs        r   test_too_many_argszTestPrint.test_too_many_argsl   sz     '=>> "hh'B'Bb		'B'B'BCC)6222Kh'''''r   N)
__name__
__module____qualname__r   r0   r5   r9   r@   r   rJ   r   r   r   r   r   J   s        6 6 63 3 36 6 6- - -2 2 2 _9::( ( ;:( ( (r   r   __main__)numba.cuda.testingr   r   r   r   unittestr'   r2   r>   r8   rE   r   rK   mainr   r   r   <module>rR      s    < < < < < < < <     



 
 
 	   2( 2( 2( 2( 2( 2( 2( 2(j zHMOOOOO r   