Ë
    èÿæi  ã                   ój  — d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
 d dlmZ d dlmZ d dlmZ d dlZ ee«      j$                  Zedz  d	z  Z G d
„ dee«      Z G d„ de«      Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d„ Z!d„ Z"d„ Z#d„ Z$d„ Z%d„ Z&d„ Z'd„ Z(d „ Z)d!„ Z*d"„ Z+ G d#„ d$e,«      Z-y)%é    N)ÚSerialMixin)Úget_conda_ctk)ÚdriverÚdevicesÚlibs)Úconfig)ÚTestCase)ÚPathÚtestsÚdatac                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)ÚCUDATestCasea)  
    For tests that use a CUDA device. Test methods in a CUDATestCase must not
    be run out of module order, because the ContextResettingTestCase may reset
    the context and destroy resources used by a normal CUDATestCase if any of
    its tests are run between tests from a CUDATestCase.
    c                 ó„   — t         j                  | _        t         j                  | _        dt         _        dt         _        y )Nr   )r   ÚCUDA_LOW_OCCUPANCY_WARNINGSÚ_low_occupancy_warningsÚCUDA_WARN_ON_IMPLICIT_COPYÚ_warn_on_implicit_copy©Úselfs    úg/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/numba/cuda/testing.pyÚsetUpzCUDATestCase.setUp   s0   € Ü'-×'IÑ'IˆÔ$Ü&,×&GÑ&GˆÔ#ð ./ŒÔ*à,-ŒÕ)ó    c                 óX   — | j                   t        _        | j                  t        _        y ©N)r   r   r   r   r   r   s    r   ÚtearDownzCUDATestCase.tearDown"   s   € Ø-1×-IÑ-IŒÔ*Ø,0×,GÑ,GŒÕ)r   c                 óÐ   — t        j                  «       j                  j                  }t        j
                  j                  |¬«      }|j                  r| j                  |«       y y )N)Úcc)	r   Úget_contextÚdeviceÚcompute_capabilityr   ÚLinkerÚnewÚltoÚskipTest)r   Úreasonr   Úlinkers       r   Úskip_if_ltozCUDATestCase.skip_if_lto&   sM   € ô × Ñ Ó"×)Ñ)×<Ñ<ˆÜ—‘×"Ñ" bÐ"Ó)ˆØ�:Š:Ø�M‰M˜&Õ!ð r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r'   © r   r   r   r      s   „ ñò.òHó"r   r   c                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )ÚContextResettingTestCasea  
    For tests where the context needs to be reset after each test. Typically
    these inspect or modify parts of the context that would usually be expected
    to be internal implementation details (such as the state of allocations and
    deallocations, etc.).
    c                 ó<   •— t         ‰| �  «        ddlm}  |«        y )Nr   )Úreset)Úsuperr   Únumba.cuda.cudadrv.devicesr0   )r   r0   Ú	__class__s     €r   r   z!ContextResettingTestCase.tearDown7   s   ø€ Ü‰ÑÔÝ4Ù�r   )r(   r)   r*   r+   r   Ú__classcell__)r3   s   @r   r.   r.   /   s   ø„ ñ÷ð r   r.   c                  óL   — ddl m}  ddlm}  | «       r|j	                  «        y y )Nr   )Úis_available)Únvvm)Ú
numba.cudar6   Únumba.cuda.cudadrvr7   Úget_supported_ccs)Úcuda_is_availabler7   s     r   Ú ensure_supported_ccs_initializedr<   =   s!   € Ý<Ý'áÔð 	×ÑÕ ð r   c                 óJ   — t        j                  t        j                  | «      S )z/Skip this test if running on the CUDA simulator)ÚunittestÚskipIfr   ÚENABLE_CUDASIM©r%   s    r   Úskip_on_cudasimrB   K   s   € ä�?‰?œ6×0Ñ0°&Ó9Ð9r   c                 óJ   — t        j                  t        j                  | «      S )z*Skip this test if running on CUDA hardware)r>   Ú
skipUnlessr   r@   rA   s    r   Úskip_unless_cudasimrE   P   s   € ä×Ñœv×4Ñ4°fÓ=Ð=r   c                 óB   — t        j                  t        «       du| «      S )z8Skip test if the CUDA toolkit was not installed by CondaN)r>   rD   r   rA   s    r   Úskip_unless_conda_cudatoolkitrG   U   s   € ä×Ñœ}›°dÐ:¸FÓCÐCr   c                 óP   — t        j                  t        j                  dk7  | «      S )z$Skip test if an EMM Plugin is in useÚdefault)r>   r?   r   ÚCUDA_MEMORY_MANAGERrA   s    r   Úskip_if_external_memmgrrK   Z   s   € ä�?‰?œ6×5Ñ5¸ÑBÀFÓKÐKr   c                 ól   — t        j                  t        j                  j	                  d«      d u| «      S )NÚCUDA_MEMCHECK)r>   r?   ÚosÚenvironÚgetrA   s    r   Úskip_under_cuda_memcheckrQ   _   s%   € Ü�?‰?œ2Ÿ:™:Ÿ>™>¨/Ó:À$ÐFÈÓOÐOr   c                 ó\   — t        j                  d«      }t        j                  |d u | «      S ©NÚnvdisasm©ÚshutilÚwhichr>   r?   ©r%   Únvdisasm_paths     r   Úskip_without_nvdisasmrZ   c   s&   € Ü—L‘L Ó,€MÜ�?‰?˜=¨DÐ0°&Ó9Ð9r   c                 ó\   — t        j                  d«      }t        j                  |d u| «      S rS   rU   rX   s     r   Úskip_with_nvdisasmr\   h   s&   € Ü—L‘L Ó,€MÜ�?‰?˜=°Ð4°fÓ=Ð=r   c                 óž   — t        j                  «       }|j                  d«      xs |j                  d«      }t        j                  || «      S )NÚarmÚaarch)ÚplatformÚ	processorÚ
startswithr>   r?   )r%   ÚcpuÚis_arms      r   Úskip_on_armre   m   s=   € Ü
×
Ñ
Ó
€CØ�^‰^˜EÓ"Ò= c§n¡n°WÓ&=€FÜ�?‰?˜6 6Ó*Ð*r   c                 ó  — t         j                  j                  t        j                  d«      }t         j                  j                  |«      xr t         j                  j                  |«      }d} t        j                  ||«      | «      S )Nzcuda.hz-CUDA include dir not available on this system)	rN   ÚpathÚjoinr   ÚCUDA_INCLUDE_PATHÚexistsÚisfiler>   rD   )ÚfnÚcuda_hÚcuda_h_filer%   s       r   Úskip_if_cuda_includes_missingro   s   sa   € ô �W‰W�\‰\œ&×2Ñ2°HÓ=€FÜ—7‘7—>‘> &Ó)ÒD¬b¯g©g¯n©n¸VÓ.D€KØ<€FØ3Œ8×Ñ˜{¨FÓ3°BÓ7Ð7r   c                 óJ   — t        j                  t        j                  | «      S )z5Skip a test if Minor Version Compatibility is enabled)r>   r?   r   Ú'CUDA_ENABLE_MINOR_VERSION_COMPATIBILITYrA   s    r   Úskip_if_mvc_enabledrr   |   s   € ä�?‰?œ6×IÑIØ!ó#ð #r   c                 ór   — d}	 dd l }dd l}d} t        j                  |d«      | «      S # t        $ r Y Œ'w xY w)NFr   Tz$Requires cubinlinker and ptxcompiler)ÚcubinlinkerÚptxcompilerÚImportErrorr>   rD   )rl   Úlibs_availablert   ru   s       r   Ú!skip_if_mvc_libraries_unavailablerx   ‚   sS   € Ø€NðÛÛØˆðGŒ8×Ñ˜~ØEóGØGIóKð Køô ò Ùðús   „
* ª	6µ6c                 ó‚   — t         j                  s/t        j                  «       j                  j
                  }|| |fk\  S y)NT)r   r@   r   r   r   r    )ÚmajorÚminorr   s      r   Úcc_X_or_abover|   �   s7   € Ü× Ò Ü× Ñ Ó"×)Ñ)×<Ñ<ˆØ�e˜U�^Ñ#Ð#àr   c                 óN   —  t        j                  t        dd«      d«      | «      S )Né   r   zrequires cc >= 5.0©r>   rD   r|   ©rl   s    r   Úskip_unless_cc_50r�   —   ó$   € ØIŒ8×Ñœ}¨Q°Ó2Ð4HÓIÈ"ÓMÐMr   c                 óN   —  t        j                  t        dd«      d«      | «      S )Nr~   é   zrequires cc >= 5.3r   r€   s    r   Úskip_unless_cc_53r…   ›   r‚   r   c                 óN   —  t        j                  t        dd«      d«      | «      S )Né   r   zrequires cc >= 6.0r   r€   s    r   Úskip_unless_cc_60rˆ   Ÿ   r‚   r   c                 óN   —  t        j                  t        dd«      d«      | «      S )Né   r~   zrequires cc >= 7.5r   r€   s    r   Úskip_unless_cc_75r‹   £   r‚   r   c                 óP   — t         j                  r| S t        j                  | «      S r   )r   r@   r>   ÚexpectedFailurer€   s    r   Úxfail_unless_cudasimrŽ   §   s!   € Ü×ÒØˆ	ä×'Ñ'¨Ó+Ð+r   c                 óJ   — t        j                  t        j                  | «      S r   )r>   r?   r   ÚUSE_NV_BINDINGrA   s    r   Úskip_with_cuda_pythonr‘   ®   s   € Ü�?‰?œ6×0Ñ0°&Ó9Ð9r   c                  óž   — t         j                  ry	 t        j                  dd¬«      } t        j                  | «       y# t
        $ r Y yw xY w)NFÚ	cudadevrtT)Ústatic)r   r@   r   Úget_cudalibÚcheck_static_libÚFileNotFoundError)rg   s    r   Úcudadevrt_missingr˜   ²   sL   € Ü×ÒØðÜ×Ñ °DÔ9ˆÜ×Ñ˜dÔ#ð øô ò Ùðús   “,A  Á 	AÁAc                 óJ   —  t        j                  t        «       d«      | «      S )Nzcudadevrt missing)r>   r?   r˜   r€   s    r   Úskip_if_cudadevrt_missingrš   ½   s   € ØDŒ8�?‰?Ô,Ó.Ð0CÓDÀRÓHÐHr   c                   ó   — e Zd ZdZd„ Zy)ÚForeignArrayzº
    Class for emulating an array coming from another library through the CUDA
    Array interface. This just hides a DeviceNDArray so that it doesn't look
    like a DeviceNDArray.
    c                 ó4   — || _         |j                  | _        y r   )Ú_arrÚ__cuda_array_interface__)r   Úarrs     r   Ú__init__zForeignArray.__init__È   s   € ØˆŒ	Ø(+×(DÑ(DˆÕ%r   N)r(   r)   r*   r+   r¡   r,   r   r   rœ   rœ   Á   s   „ ñóEr   rœ   ).rN   r`   rV   Únumba.tests.supportr   Únumba.cuda.cuda_pathsr   r9   r   r   r   Ú
numba.corer   r	   Úpathlibr
   r>   Ú__file__ÚparentÚnumba_cuda_dirÚtest_data_dirr   r.   r<   rB   rE   rG   rK   rQ   rZ   r\   re   ro   rr   rx   r|   r�   r…   rˆ   r‹   rŽ   r‘   r˜   rš   Úobjectrœ   r,   r   r   Ú<module>r«      sÞ   ðÛ 	Û Û å +Ý /ß 4Ñ 4Ý Ý (Ý Û á�h“×&Ñ&€Ø Ñ(¨6Ñ1€ô"�; ô "ô<˜|ô ò!ò:ò
>ò
Dò
Lò
Pò:ò
>ò
+ò8ò#ò
KòòNòNòNòNò,ò:òòIô	E�6õ 	Er   