
    i                     j   S SK r S SKrS SKrS SKJr  S SKJr  S SKJrJ	r	J
r
  S SKJr  S SKJr  S SKJr  S SKr\" \5      R$                  r\S-  S	-  r " S
 S\\5      r " S S\5      rS rS rS rS rS rS rS rS rS rS r S r!S r"S r#S r$S r%S r&S r'S r(S  r)S! r*S" r+ " S# S$\,5      r-g)%    N)SerialMixin)get_conda_ctk)driverdeviceslibs)config)TestCase)Pathtestsdatac                   *    \ rS rSrSrS rS rS rSrg)CUDATestCase   a  
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                     [         R                  U l        [         R                  U l        S[         l        S[         l        g )Nr   )r   CUDA_LOW_OCCUPANCY_WARNINGS_low_occupancy_warningsCUDA_WARN_ON_IMPLICIT_COPY_warn_on_implicit_copyselfs    M/var/www/html/trading/venv/lib/python3.13/site-packages/numba/cuda/testing.pysetUpCUDATestCase.setUp   s0    '-'I'I$&,&G&G# ./*,-)    c                 X    U R                   [        l        U R                  [        l        g N)r   r   r   r   r   r   s    r   tearDownCUDATestCase.tearDown"   s    -1-I-I*,0,G,G)r   c                     [         R                  " 5       R                  R                  n[        R
                  R                  US9nUR                  (       a  U R                  U5        g g )N)cc)	r   get_contextdevicecompute_capabilityr   LinkernewltoskipTest)r   reasonr    linkers       r   skip_if_ltoCUDATestCase.skip_if_lto&   sM       "))<<""b")::MM&! r   )r   r   N)	__name__
__module____qualname____firstlineno____doc__r   r   r*   __static_attributes__ r   r   r   r      s    .H"r   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )ContextResettingTestCase/   z
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U ]  5         SSKJn  U" 5         g )Nr   )reset)superr   numba.cuda.cudadrv.devicesr7   )r   r7   	__class__s     r   r   !ContextResettingTestCase.tearDown7   s    4r   r2   )r,   r-   r.   r/   r0   r   r1   __classcell__)r:   s   @r   r4   r4   /   s     r   r4   c                  V    SSK Jn   SSKJn  U " 5       (       a  UR	                  5         g g )Nr   )is_available)nvvm)
numba.cudar>   numba.cuda.cudadrvr?   get_supported_ccs)cuda_is_availabler?   s     r    ensure_supported_ccs_initializedrD   =   s$    <' 	  r   c                 L    [         R                  " [        R                  U 5      $ )z/Skip this test if running on the CUDA simulator)unittestskipIfr   ENABLE_CUDASIMr(   s    r   skip_on_cudasimrJ   K   s    ??600&99r   c                 L    [         R                  " [        R                  U 5      $ )z*Skip this test if running on CUDA hardware)rF   
skipUnlessr   rH   rI   s    r   skip_unless_cudasimrM   P   s    v44f==r   c                 D    [         R                  " [        5       SLU 5      $ )z8Skip test if the CUDA toolkit was not installed by CondaN)rF   rL   r   rI   s    r   skip_unless_conda_cudatoolkitrO   U   s    }d:FCCr   c                 R    [         R                  " [        R                  S:g  U 5      $ )z$Skip test if an EMM Plugin is in usedefault)rF   rG   r   CUDA_MEMORY_MANAGERrI   s    r   skip_if_external_memmgrrS   Z   s    ??655BFKKr   c                 n    [         R                  " [        R                  R	                  S5      S LU 5      $ )NCUDA_MEMCHECK)rF   rG   osenvirongetrI   s    r   skip_under_cuda_memcheckrY   _   s%    ??2::>>/:$FOOr   c                 `    [         R                  " S5      n[        R                  " US L U 5      $ NnvdisasmshutilwhichrF   rG   r(   nvdisasm_paths     r   skip_without_nvdisasmrb   c   s&    LL,M??=D0&99r   c                 `    [         R                  " S5      n[        R                  " US LU 5      $ r[   r]   r`   s     r   skip_with_nvdisasmrd   h   s&    LL,M??=4f==r   c                     [         R                  " 5       nUR                  S5      =(       d    UR                  S5      n[        R                  " X 5      $ )Narmaarch)platform	processor
startswithrF   rG   )r(   cpuis_arms      r   skip_on_armrm   m   s;    



C^^E"=cnnW&=F??6**r   c                 $   [         R                  R                  [        R                  S5      n[         R                  R                  U5      =(       a    [         R                  R                  U5      nSn[        R                  " X#5      " U 5      $ )Nzcuda.hz-CUDA include dir not available on this system)	rV   pathjoinr   CUDA_INCLUDE_PATHexistsisfilerF   rL   )fncuda_hcuda_h_filer(   s       r   skip_if_cuda_includes_missingrw   s   s]     WW\\&22H=F77>>&)DbggnnV.DK<F{3B77r   c                 L    [         R                  " [        R                  U 5      $ )z5Skip a test if Minor Version Compatibility is enabled)rF   rG   r   'CUDA_ENABLE_MINOR_VERSION_COMPATIBILITYrI   s    r   skip_if_mvc_enabledrz   |   s    ??6II!# #r   c                 v    Sn SS K nSS KnSn[        R                  " US5      " U 5      $ ! [         a     N)f = f)NFr   Tz$Requires cubinlinker and ptxcompiler)cubinlinkerptxcompilerImportErrorrF   rL   )rt   libs_availabler|   r}   s       r   !skip_if_mvc_libraries_unavailabler      sP    N ~EGGIK K  s   
+ 
88c                     [         R                  (       d/  [        R                  " 5       R                  R
                  nX U4:  $ g)NT)r   rH   r   r!   r"   r#   )majorminorr    s      r   cc_X_or_abover      s5        "))<<U^##r   c                 P    [         R                  " [        SS5      S5      " U 5      $ )N   r   zrequires cc >= 5.0rF   rL   r   rt   s    r   skip_unless_cc_50r      "    }Q24HI"MMr   c                 P    [         R                  " [        SS5      S5      " U 5      $ )Nr      zrequires cc >= 5.3r   r   s    r   skip_unless_cc_53r      r   r   c                 P    [         R                  " [        SS5      S5      " U 5      $ )N   r   zrequires cc >= 6.0r   r   s    r   skip_unless_cc_60r      r   r   c                 P    [         R                  " [        SS5      S5      " U 5      $ )N   r   zrequires cc >= 7.5r   r   s    r   skip_unless_cc_75r      r   r   c                 \    [         R                  (       a  U $ [        R                  " U 5      $ r   )r   rH   rF   expectedFailurer   s    r   xfail_unless_cudasimr      s!    	''++r   c                 L    [         R                  " [        R                  U 5      $ r   )rF   rG   r   USE_NV_BINDINGrI   s    r   skip_with_cuda_pythonr      s    ??600&99r   c                      [         R                  (       a  g [        R                  " SSS9n [        R                  " U 5        g! [
         a     gf = f)NF	cudadevrtT)static)r   rH   r   get_cudalibcheck_static_libFileNotFoundError)ro   s    r   cudadevrt_missingr      sL    D9d#   s   +A 
AAc                 L    [         R                  " [        5       S5      " U 5      $ )Nzcudadevrt missing)rF   rG   r   r   s    r   skip_if_cudadevrt_missingr      s    ??,.0CDRHHr   c                       \ rS rSrSrS rSrg)ForeignArray   z
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                 2    Xl         UR                  U l        g r   )_arr__cuda_array_interface__)r   arrs     r   __init__ForeignArray.__init__   s    	(+(D(D%r   )r   r   N)r,   r-   r.   r/   r0   r   r1   r2   r   r   r   r      s    Er   r   ).rV   rh   r^   numba.tests.supportr   numba.cuda.cuda_pathsr   rA   r   r   r   
numba.corer   r	   pathlibr
   rF   __file__parentnumba_cuda_dirtest_data_dirr   r4   rD   rJ   rM   rO   rS   rY   rb   rd   rm   rw   rz   r   r   r   r   r   r   r   r   r   r   objectr   r2   r   r   <module>r      s    	   + / 4 4  (  h&&(61"; "<| !:
>
D
L
P:
>
+8#
KNNNN,:I	E6 	Er   