o
    i;                     @   sd   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	 d	eZed
kr0e  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                   @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zeddd Z	dS )	TestPrintc                 C   s2   t jd|g}tj|d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cp r   _/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/numba/cuda/tests/cudapy/test_print.pyrun_codeN   s   zTestPrint.run_codec                 C   sP   |  t\}}dd | D }dgd dd tdD  }| t|| d S )Nc                 S      g | ]}|  qS r   strip.0liner   r   r   
<listcomp>V       z*TestPrint.test_cuhello.<locals>.<listcomp>z-42   c                 S      g | ]}d | qS )z%d 999r   r   ir   r   r   r   W   r   )r   cuhello_usecase
splitlinesrangeassertEqualsorted)r   output_actualexpectedr   r   r   test_cuhelloT   s   zTestPrint.test_cuhelloc                 C   s*   |  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_casesr   r   r   test_printfloat\   s   zTestPrint.test_printfloatc                 C   s"   |  t\}}| | d d S )N )r   printempty_usecaser&   r   )r   r(   r)   r   r   r   test_printemptyb   s   zTestPrint.test_printemptyc                 C   sH   |  t\}}dd |dD }dd tdD }| t|| d S )Nc                 S   r   r   r   r   r   r   r   r   h   r   z)TestPrint.test_string.<locals>.<listcomp>Tc                 S   r    )z%d hop! 999r   r!   r   r   r   r   i   r      )r   printstring_usecaser$   r%   r&   r'   )r   r(   r)   linesr+   r   r   r   test_stringf   s   zTestPrint.test_stringz"cudasim can print unlimited outputc                 C   sF   |  t\}}ddd tdD }| || d}| || d S )N c                 S   s   g | ]}d qS )z%lldr   )r   r)   r   r   r   r   v   s    z0TestPrint.test_too_many_args.<locals>.<listcomp>!   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%   r.   )r   r(   errorsexpected_fmt_stringwarn_msgr   r   r   test_too_many_argsl   s
   zTestPrint.test_too_many_argsN)
__name__
__module____qualname__r   r,   r0   r3   r7   r   r?   r   r   r   r   r   J   s    r   __main__)numba.cuda.testingr   r   r   r	   unittestr#   r-   r5   r2   r:   r   r@   mainr   r   r   r   <module>   s    5