§
    1@Äj»  ã                   óŒ   — 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_cudasimNz‹from numba import cuda

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

cuhello[2, 3]()
cuda.synchronize()
z�from numba import cuda

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

printfloat[1, 1]()
cuda.synchronize()
zŒfrom 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       úSC:\Projects\Historical\venv\Lib\site-packages\numba/cuda/tests/cudapy/test_print.pyÚrun_codezTestPrint.run_codeN   sO   € åŒ~˜t TÐ*ˆÝŒ^˜C¨¸DÈÐMÑMÔMˆØŒy×ÒÑ!Ô! 2¤9×#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Ð!A°1 (¨Q¡,Ð!AÐ!AÐ!Ar   )r   Úcuhello_usecaseÚ
splitlinesÚrangeÚassertEqualÚsorted)r   ÚoutputÚ_ÚactualÚexpecteds        r   Útest_cuhellozTestPrint.test_cuhelloT   s   € Ø—M’M¥/Ñ2Ô2‰	ˆ�Ø?Ð?¨6×+<Ò+<Ñ+>Ô+>Ð?Ñ?Ô?ˆØ�7˜Q‘;Ð!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   € Ø—M’MÕ"4Ñ5Ô5‰	ˆ�à.Ð0@ÐAˆØ�Š�f—l’l‘n”n nÑ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<   € Ø—M’MÕ"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¨!�M AÑ%Ð8Ð8Ð8r   é   )r   Úprintstring_usecaser(   r)   r*   r+   )r   r,   r-   Úlinesr/   s        r   Útest_stringzTestPrint.test_stringf   st   € Ø—M’MÕ"5Ñ6Ô6‰	ˆ�ØBÐB¨&×*;Ò*;¸DÑ*AÔ*AÐBÑBÔBˆØ8Ð8­u°Q©x¬xÐ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Ð'B°1¨Ð'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   € ð ŸšÕ'=Ñ>Ô>‰ˆ�ð "ŸhšhÐ'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ÒÐØ€H„M�O„O€O€O€Oð Ðr   