o
    Tæ«då
  ã                   @   sæ   d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ e
ƒ ZejZe e d¡¡Zed	d
„ ƒZe ej¡e ej¡dd„ ƒƒZe ej¡dd„ ƒZe ej¡dd„ ƒZeee ej¡ƒdd„ ƒZ dS )é    )Úsingledispatch)Úir)ÚtypesÚcgutils)ÚNumbaWarning)ÚRegistry)Ú	nvvmutils)Úwarné   c                 C   s   t d| f ƒ‚)zµ
    Handle printing of a single value of the given Numba type.
    A (format string, [list of arguments]) is returned that will allow
    forming the final printf()-like call.
    z,printing unimplemented for values of type %s)ÚNotImplementedError)ÚtyÚcontextÚbuilderÚval© r   úg/home/ncw/WWW/www-new/content/articles/pi-bbp/venv/lib/python3.10/site-packages/numba/cuda/printimpl.pyÚ
print_item   s   ÿr   c                 C   s:   | t jv rd}t j}nd}t j}| ||| |¡}||gfS )Nz%lluz%lld)r   Úunsigned_domainÚuint64Úint64Úcast)r   r   r   r   ÚrawfmtÚdsttypeÚlldr   r   r   Úint_print_impl   s   

r   c                 C   s   |  ||| tj¡}d|gfS )Nz%f)r   r   Úfloat64)r   r   r   r   r   r   r   r   Úreal_print_impl)   s   
r   c                 C   s.   | j }t|tƒs
J ‚d}| ||¡}||gfS )Nz%s)Úliteral_valueÚ
isinstanceÚstrÚinsert_string_const_addrspace)r   r   r   ÚsigvalÚpyvalr   r   r   r   r   Úconst_print_impl/   s
   
r#   c                 C   sÜ   t  |j¡}g }g }tt|j|ƒƒD ]\}\}}	t|| ||	ƒ\}
}| |
¡ | |¡ qd 	|¡d }t
|ƒdkrFd}t|tƒ | dd¡}|  ||¡}t ||¡}t ||¡}t  |j¡}| ||| |t¡f¡ |  ¡ S )z½This function is a generic 'print' wrapper for arbitrary types.
    It dispatches to the appropriate 'print' implementations above
    depending on the detected real types in the signature.ú Ú
é    zjCUDA print() cannot print more than 32 items. The raw format string will be emitted by the kernel instead.ú%z%%)r   Údeclare_vprintÚmoduleÚ	enumerateÚzipÚargsr   ÚappendÚextendÚjoinÚlenr	   r   Úreplacer    r   Úmake_anonymous_structÚalloca_once_valueÚcallÚbitcastÚvoidptrÚget_dummy_value)r   r   Úsigr,   ÚvprintÚformatsÚvaluesÚiÚargtypeÚargvalÚargfmtÚargvalsr   ÚmsgÚfmtÚarrayÚarrayptrr   r   r   Úprint_varargs8   s$   

rE   N)!Ú	functoolsr   Úllvmliter   Ú
numba.corer   r   Únumba.core.errorsr   Únumba.core.imputilsr   Ú
numba.cudar   Úwarningsr	   ÚregistryÚlowerÚPointerTypeÚIntTyper6   r   ÚregisterÚIntegerÚIntegerLiteralr   ÚFloatr   ÚStringLiteralr#   ÚprintÚVarArgÚAnyrE   r   r   r   r   Ú<module>   s*    







