+
    ;i_n                     >   R t ^ RIt^ RIHt ^ RIt^ RIt^ RIHt ^ RIt	^ RI
HtHt ^ RIHtHtHtHt ^ RIHtHtHtHtHtHtHt ^ RIHtHtHt ^ RIHt ^ R	I H!t! ^ R
IH"t"H#t#H$t$ ^ RI%H&t& ^ RI'H(t( ^ RIH)t) ^ RI*H+t+H,t, ^ RI-H.t. ^ RI/H0t0H1t1 ^ RI2H3t3 ^ RI
H4t4 ^ RI5H6t7 ^ RI8H9t: ^ RI;H<t< ^ RIH=t= ^ RI>H?t?H@t@ ^ RIAHBtBHCtC ^ RIDHEtE  ! R R]4      tF]F]R&    ! R R]+4      tG]1! 4       tH ! R R]&4      tI ! R  R!]!4      tJ]J! R4      tK ! R" R#]4      tL]L]]R,          &    ! R$ R%]4      tM]M]]R,          &   ]HP                  ]P                  4      R& 4       tP]HP                  ]P                  ]P                  4      R' 4       tT]HP                  ]P                  4      R( 4       tU]HP                  ]P                  4      R) 4       tW]! RR*7      R+ 4       tX]! ]P                  RR*7      R, 4       tZ ! R- R.]4      t[ ! R/ R0]4      t\]]R18X  d   ]P                  ! 4        R# R# )2a  This tests the target extension API to ensure that rudimentary expected
behaviours are present and correct. It uses a piece of fake hardware as a
target, the Dummy Processing Unit (DPU), to do this. The DPU borrows a lot from
the CPU but is part of the GPU class of target. The DPU target has deliberately
strange implementations of fundamental operations so as to make it identifiable
in testing.N)TestCase)cached_property)njittypes)overloadoverload_attributeoverload_classmethod	intrinsic)JitDecoratortarget_registrydispatcher_registryjit_registrytarget_overrideGPUresolve_dispatcher_from_str)utilsfastmathpasserrors)
Dispatcher)TargetDescriptor)cputypingcgutils)BaseContext)global_compiler_lock)callconv)
CPUCodegenJITCodeLibrary)PyCallWrapper)RegistryLoaderRegistry)typeof)_dynfunc)ir)rtsys)compiler)CompilerBaseDefaultPassBuilder)FunctionPassregister_pass)PreLowerStripPhisc                       ] tR t^3tRtR# )DPU N)__name__
__module____qualname____firstlineno____static_attributes__r-       _/var/www/html/photoedit/myenv/lib/python3.14/site-packages/numba/tests/test_target_extension.pyr,   r,   3   s    r3   r,   dpuc                   <   a  ] tR t^>t o ]tR tR tR tR t	Rt
V tR# )JITDPUCodegenc                   V P                  4       VR &   \        P                  P                  4       P                  pVP                  R4      '       d   RpMVP                  R4      '       d   RpMRpW1R&   RVR&   V P                  VR	&   \        P                  ! \        P                  P                  4      pR
VP                  9   d   RVR
&   R# R# )r   x86staticppcpicdefaultreloc
jitdefault	codemodelfeaturesjitTN)_get_host_cpu_namellTargetfrom_default_triplename
startswith_tm_featuresr   pysignaturecreate_target_machine
parameters)selfoptionsarchreloc_modelsigs   &&   r4   _customize_tm_options#JITDPUCodegen._customize_tm_optionsC   s    002yy,,.33??5!!"K__U##K#K&+ #//
 		 ? ?@CNN"!GEN #r3   c                "    V P                  4       # N)_get_host_cpu_featuresrM   s   &r4   _customize_tm_features$JITDPUCodegen._customize_tm_featuresZ   s    **,,r3   c                <    V P                   P                  V4       R # rU   )_engine
add_module)rM   modules   &&r4   _add_moduleJITDPUCodegen._add_module^   s    'r3   c                    V P                   P                  V4      p\        P                  ^,          P	                  V4      p\        P                  ! \        V4      4      V^ &   R# )zbSet the environment address.

Update the GlobalVariable named *env_name* to the address of *env*.
N)r[   get_global_value_addressctypesc_void_pfrom_addressid)rM   env_nameenvgvaddrenvptrs   &&&  r4   set_envJITDPUCodegen.set_enva   sG    
 66x@//A%33F;OOBsG,q	r3   r-   N)r.   r/   r0   r1   r   _library_classrR   rX   r^   rj   r2   __classdictcell____classdict__s   @r4   r7   r7   >   s%      $N".-(- -r3   r7   c                      a  ] tR t^qt o RtR t]R 4       tR t]	R 4       t
R t]R 4       tR tR	 tR
 tR tRR ltR tR tRtV tR# )
DPUContextTc                8    V P                   P                  V4      # rU   )_internal_codegen_create_empty_module)rM   rG   s   &&r4   create_moduleDPUContext.create_moduleu   s    %%::4@@r3   c                r    \        R 4      V n        \        P                  ! V 4       V P	                  4        R# )z
numba.execN)r7   rs   r$   
initializerefreshrW   s   &r4   initDPUContext.initx   s&    !.|!<r3   c                    \         p V P                  V,          pV P	                  V4       V P
                  P                  4        R #   \         d    \        T4      pY P                  T&    LSi ; irU   )dpu_function_registry_registriesKeyErrorr   install_registrytyping_contextry   )rM   registryloaders   &  r4   ry   DPUContext.refresh   si    (	0%%h/F 	h' 	##%  	0#H-F)/X&	0s   A $A/.A/c                .    V P                   P                  # rU   )rs   target_datarW   s   &r4   r   DPUContext.target_data   s    %%111r3   c                    V P                   # rU   rs   rW   s   &r4   codegenDPUContext.codegen   s    %%%r3   c                .    \         P                  ! V 4      # rU   )r   CPUCallConvrW   s   &r4   	call_convDPUContext.call_conv   s    ##D))r3   c                    \         P                  ! W\        P                  R,          4      p\        P
                  ! WVRR7      # )z
From the given *envptr* (a pointer to a _dynfunc.Environment object),
get a EnvBody allowing structured access to environment fields.
offsetof_env_bodyT)refcast_ref)r   pointer_addr"   
_impl_infor   EnvBody)rM   builderri   body_ptrs   &&& r4   get_env_bodyDPUContext.get_env_body   s:    
 &&X001DE
 {{4hFFr3   c                V   V P                  VP                  V P                  V P                  4      4      pVP	                  V4      pV P                  V4      pVP                  W0P                  P                  R 7       V P                  W4      pVP                  V P                  WS4      # ))	debug_msg)declare_env_globalr]   get_env_namefndescloadget_python_apiemit_environment_sentryrf   r   get_env_managerenvironment)rM   r   envgvenvargpyapienv_bodys   &&    r4   r   DPUContext.get_env_manager   s    ''NND--dkk:
 e$##G,%%kk22 	& 	
 $$W5$$T%5%5xHHr3   c                `    \         P                  ! VV\        P                  R,          VR7      # )zf
From the given *genptr* (a pointer to a _dynfunc.Generator object),
get a pointer to its state area.
offsetof_generator_state)return_type)r   r   r"   r   )rM   r   genptrr   s   &&&&r4   get_generator_stateDPUContext.get_generator_state   s/    
 "" :;#	
 	
r3   c                    V P                   '       d!   \        P                  ! WP                   4       VP                  \        P
                  4       R # rU   )fastmathr   rewrite_moduleadd_linking_libraryr$   library)rM   modr   s   &&&r4   post_loweringDPUContext.post_lowering   s/    ==='']];##EMM2r3   c           
     0   V P                  R 4      pV P                  P                  VP                  VP                  4      p\
        P                  ! WgVP                  4      p\        V VVVVVVR7      p	V	P                  4        VP                  V4       R# )wrapper)call_helperrelease_gilN)ru   r   get_function_typerestypeargtypesllirFunctionllvm_func_namer   buildadd_ir_module)
rM   r   r   rg   r   r   wrapper_modulefntywrapper_calleer   s
   &&&&&&    r4   create_cpython_wrapper!DPUContext.create_cpython_wrapper   s     ++I6~~//P&"7"7
  ##
 	n-r3   c                    R # rU   r-   )rM   r   r   rg   r   s   &&&&&r4   create_cfunc_wrapperDPUContext.create_cfunc_wrapper   s    r3   c                F   VP                  VP                  4      pRVP                  : 2p\        P                  ! VP                  4       VP                  P                  R4      R,          VVVV34      pVP                  P                  V P                  V4      V4       V# )z
Returns
-------
(cfunc, fnptr)

- cfunc
    callable function (Can be None)
- fnptr
    callable function address
- env
    an execution environment (from _dynfunc)
zcompiled wrapper for .)
get_pointer_to_functionllvm_cpython_wrapper_namequalnamer"   make_functionlookup_modulesplitr   rj   r   )rM   r   r   rg   fnptrdoccfuncs   &&&&   r4   get_executableDPUContext.get_executable   s     //,,
 ,2??<&&  "OO!!#&r*J
 	 1 1& 93?r3   r   N)F)r.   r/   r0   r1   allow_dynamic_globalsru   r   rz   ry   propertyr   r   r   r   r   r   r   r   r   r   r   r2   rm   rn   s   @r4   rq   rq   q   s      A  
& 2 2& * *G
I

3.( r3   rq   c                   x   a  ] tR t^t o ]P
                  t]R 4       t]R 4       t	]
R 4       t]
R 4       tRtV tR# )	DPUTargetc                B    \        V P                  V P                  4      # rU   )rq   r   _target_namerW   s   &r4   _toplevel_target_context"DPUTarget._toplevel_target_context   s     $--t/@/@AAr3   c                ,    \         P                  ! 4       # rU   )r   ContextrW   s   &r4   _toplevel_typing_context"DPUTarget._toplevel_typing_context  s     ~~r3   c                    V P                   # )z%
The target context for DPU targets.
)r   rW   s   &r4   target_contextDPUTarget.target_context      
 ,,,r3   c                    V P                   # )z%
The typing context for CPU targets.
)r   rW   s   &r4   r   DPUTarget.typing_context  r   r3   r-   N)r.   r/   r0   r1   r   CPUTargetOptionsrN   r   r   r   r   r   r   r2   rm   rn   s   @r4   r   r      s`     ""GB B     - - - -r3   r   c                   6   a a ] tR tRt o]tV 3R ltRtVtV ;t	# )DPUDispatcheri  c                   < \        R 4      ;_uu_ 4        \        SV `	  V4      uuRRR4       #   + '       g   i     R# ; i)r5   N)r   supercompile)rM   rQ   	__class__s   &&r4   r   DPUDispatcher.compile  s)    U##7?3' $###s	   /A 	r-   )
r.   r/   r0   r1   
dpu_targettargetdescrr   r2   rm   __classcell__)r   ro   s   @@r4   r   r     s     K( (r3   r   c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )djiti*  c                    Wn         W n        R # rU   )_args_kwargs)rM   argskwargss   &*,r4   __init__djit.__init__+  s    
r3   c                    \        V4      ^8  g   Q hV'       d   V^ ,          pMV P                  ^ ,          pW n        V P                  4       # )   )lenr   py_funcdispatcher_wrapper)rM   r   funcs   &* r4   __call__djit.__call__/  s?    4y1}}7D::a=D&&((r3   c                2    \         \        R,          ,          # )z
Returns the dispatcher
r5   )r   r   rW   s   &r4   get_dispatcherdjit.get_dispatcher9  s     #?5#9::r3   c                    V P                  4       p/ pR V P                  9   d   RVR &   \        P                  pRV P                  9   d   V P                  R,          pV! V P                  VVR7      # )nopythonTpipeline_class)r  targetoptionsr  )r	  r   r%   Compilerr  )rM   disptoptr  s   &   r4   r  djit.dispatcher_wrapper?  sm    ""$%#D "**t||+!\\*:;NLL)
 	
r3   )r   r   r  N)
r.   r/   r0   r1   r   r  r	  r  r2   rm   rn   s   @r4   r   r   *  s     );
 
r3   r   c                 "    V P                  4       # rU   )get_dummy_value)contextr   typyvals   &&&&r4   constant_dummyr  [  s    ""$$r3   c                     V P                  WP                  VP                  4      pV P                  WVP                  V4      # rU   )get_constant_genericliteral_typeliteral_valuecast)r  r   fromtytotyvallits   &&&&& r4   literal_int_to_numberr"  a  s>    

&
&$$f&:&:C <<f&9&94@@r3   c                 4    V P                  V4      pV! V4      # rU   get_value_typer  r   r  r  ltys   &&&& r4   	const_intr(  j      

 
 
$Cu:r3   c                 4    V P                  V4      pV! V4      # rU   r$  r&  s   &&&& r4   const_floatr+  q  r)  r3   targetc                     V! W4      pR  pW43# )c                 "    VP                   ! V!  # rU   subcgctxr   tyargsllargss   &&&&r4   r   intrin_add.<locals>.codegen|  s    {{F##r3   r-   tyctxxyrQ   r   s   &&&  r4   
intrin_addr;  x  s    
A'C$ <r3   c                     \        V \        P                  4      '       d(   \        V\        P                  4      '       d   R  pV# R# R# )c                     \        W4      # rU   )r;  )r9  r:  s   &&r4   implol_add.<locals>.impl  s    a##r3   N)
isinstancer   Integer)r9  r:  r>  s   && r4   ol_addrB    s8    !U]]##
1emm(D(D	$  )E#r3   c                   Z   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tRtV tR# )TestTargetHierarchySelectioni  zThis tests that the target hierarchy is scanned in the right order,
that appropriate functions are selected based on what's available and that
the DPU target is distinctly different to the CPUc                &   V P                  \        P                  4       V P                  \        P                  4       V P	                  \        \        P                  4      ^4       V P	                  \        \        P                  4      ^4       R# )zChecks that the DPU registry only contains the things added

This test must be first to execute among all tests in this file to
ensure the no lazily loaded entries are added yet.
N)assertFalser}   	functionsgetattrsassertEqualr  casts	constantsrW   s   &r4   test_0_dpu_registry0TestTargetHierarchySelection.test_0_dpu_registry  sf     	.889.77828891=2<<=qAr3   c                  a R  o\        SRR7      R 4       p\        SRR7      R 4       p\        4       V3R l4       p\        4       V3R l4       pV P                  V! 4       ^4       V P                  V! 4       ^4       R# )	c                     R # rU   r-   r9  s   &r4   my_funcATestTargetHierarchySelection.test_specialise_gpu.<locals>.my_func      r3   genericr,  c                     R  pV# )c                     ^V ,           #    r-   rP  s   &r4   r>  STestTargetHierarchySelection.test_specialise_gpu.<locals>.ol_my_func1.<locals>.impl      1ur3   r-   r9  r>  s   & r4   ol_my_func1ETestTargetHierarchySelection.test_specialise_gpu.<locals>.ol_my_func1       Kr3   gpuc                     R  pV# )c                     ^
V ,           # 
   r-   rP  s   &r4   r>  STestTargetHierarchySelection.test_specialise_gpu.<locals>.ol_my_func2.<locals>.impl      Avr3   r-   r[  s   & r4   ol_my_func2ETestTargetHierarchySelection.test_specialise_gpu.<locals>.ol_my_func2       Kr3   c                     < S ! ^4      #    r-   rQ  s   r4   dpu_fooATestTargetHierarchySelection.test_specialise_gpu.<locals>.dpu_foo      1:r3   c                     < S ! ^4      # rj  r-   rl  s   r4   cpu_fooATestTargetHierarchySelection.test_specialise_gpu.<locals>.cpu_foo  ro  r3   Nr   r   r   assertPreciseEqual)rM   r\  rf  rm  rq  rQ  s   &    @r4   test_specialise_gpu0TestTargetHierarchySelection.test_specialise_gpu  s    	 
')	,	 
-	 
'%	(	 
)	 
	 
	 
	 
	
 		1-	1-r3   c                (  a R  o\        SRR7      R 4       p\        SRR7      R 4       p\        SRR7      R 4       p\        4       V3R l4       p\        4       V3R	 l4       pV P                  V! 4       ^]4       V P                  V! 4       ^4       R
# )c                     R # rU   r-   rP  s   &r4   rQ  ATestTargetHierarchySelection.test_specialise_dpu.<locals>.my_func  rS  r3   rT  r,  c                     R  pV# )c                     ^V ,           # rW  r-   rP  s   &r4   r>  STestTargetHierarchySelection.test_specialise_dpu.<locals>.ol_my_func1.<locals>.impl  rZ  r3   r-   r[  s   & r4   r\  ETestTargetHierarchySelection.test_specialise_dpu.<locals>.ol_my_func1  r^  r3   r_  c                     R  pV# )c                     ^
V ,           # rb  r-   rP  s   &r4   r>  STestTargetHierarchySelection.test_specialise_dpu.<locals>.ol_my_func2.<locals>.impl  re  r3   r-   r[  s   & r4   rf  ETestTargetHierarchySelection.test_specialise_dpu.<locals>.ol_my_func2  rh  r3   r5   c                     R  pV# )c                     ^dV ,           # )d   r-   rP  s   &r4   r>  STestTargetHierarchySelection.test_specialise_dpu.<locals>.ol_my_func3.<locals>.impl  s    Qwr3   r-   r[  s   & r4   ol_my_func3ETestTargetHierarchySelection.test_specialise_dpu.<locals>.ol_my_func3  s     Kr3   c                     < S ! ^4      # rj  r-   rl  s   r4   rm  ATestTargetHierarchySelection.test_specialise_dpu.<locals>.dpu_foo  ro  r3   c                     < S ! ^4      # rj  r-   rl  s   r4   rq  ATestTargetHierarchySelection.test_specialise_dpu.<locals>.cpu_foo  ro  r3   Nrs  )rM   r\  rf  r  rm  rq  rQ  s   &     @r4   test_specialise_dpu0TestTargetHierarchySelection.test_specialise_dpu  s    	 
')	,	 
-	 
'%	(	 
)	 
'%	(	 
)	 
	 
	 
	 
	
 		2.	1-r3   c                z  a R  o\        SRR7      R 4       p\        RR7      V3R l4       p\        P                  \        P                  3pV P                  V4      ;_uu_ 4       pV! 4        RRR4       . ROpV F(  pV P                  V\        XP                  4      4       K*  	  R#   + '       g   i     LD; i)	c                     R # rU   r-   rP  s   &r4   rQ  JTestTargetHierarchySelection.test_no_specialisation_found.<locals>.my_func  rS  r3   cudar,  c                     R  # )c                     R # rU   r-   rP  s   &r4   <lambda>dTestTargetHierarchySelection.test_no_specialisation_found.<locals>.ol_my_func_cuda.<locals>.<lambda>  s    Tr3   r-   rP  s   &r4   ol_my_func_cudaRTestTargetHierarchySelection.test_no_specialisation_found.<locals>.ol_my_func_cuda  s    !!r3   Tr  c                     < S ! ^4       R# )rX  Nr-   rl  s   r4   rm  JTestTargetHierarchySelection.test_no_specialisation_found.<locals>.dpu_foo  s
    AJr3   N)8Function resolution cannot find any matches for functionz-test_no_specialisation_found.<locals>.my_funczfor the current target:z''numba.tests.test_target_extension.DPU')	r   r   r   UnsupportedErrorTypingErrorassertRaisesassertInstr	exception)rM   r  rm  acceptraisesmsgsmsgrQ  s   &      @r4   test_no_specialisation_found9TestTargetHierarchySelection.test_no_specialisation_found  s    	 
'&	)	" 
*	" 
t		 
	
 ))6+=+=>v&&&I ';
 CMM#s6#3#345  '&s   &B**B:	c                   V P                  \        P                  4      ;_uu_ 4       p\        R R7      R 4       pV! 4        RRR4       RpV P	                  V\        XP                  4      4       R#   + '       g   i     L9; i)invalid_silicon)_targetc                      R # rU   r-   r-   r3   r4   fooATestTargetHierarchySelection.test_invalid_target_jit.<locals>.foo
  s    r3   N1No target is registered against 'invalid_silicon')r  r   NonexistentTargetErrorr   r  r  r  )rM   r  r  r  s   &   r4   test_invalid_target_jit4TestTargetHierarchySelection.test_invalid_target_jit  si    v<<==+, - E > Bc3v//01 >=s   A33B	c                4  a R  oV P                  \        P                  4      ;_uu_ 4       p\        SRR7      R 4       p\        V3R l4       pV! 4        RRR4       RpV P                  V\        XP                  4      4       R#   + '       g   i     L9; i)c                      R # rU   r-   r-   r3   r4   barFTestTargetHierarchySelection.test_invalid_target_overload.<locals>.bar  rS  r3   r  r,  c                      R  # )c                      R # rU   r-   r-   r3   r4   r  [TestTargetHierarchySelection.test_invalid_target_overload.<locals>.ol_bar.<locals>.<lambda>  s    r3   r-   r-   r3   r4   ol_barITestTargetHierarchySelection.test_invalid_target_overload.<locals>.ol_bar  s    $$r3   c                     < S ! 4        R # rU   r-   )r  s   r4   r  FTestTargetHierarchySelection.test_invalid_target_overload.<locals>.foo  s    r3   Nr  )r  r   r  r   r   r  r  r  )rM   r  r  r  r  r  s   &    @r4   test_invalid_target_overload9TestTargetHierarchySelection.test_invalid_target_overload  s    	
 v<<==c"34% 5%   E > Bc3v//01 >=s   *BB	c                B  aaa \        RR7      R 4       o\        RR7      R 4       o\        RR7      R 4       o\        V3R l4       pV P                  V! 4       ^4       \        V3R	 l4       pV P                  V! 4       ^4       \        V3R
 l4       p\        P                  \        P
                  3pV P                  V4      ;_uu_ 4       pV! 4        RRR4       . ROpV F(  pV P                  V\        XP                  4      4       K*  	  \        RR7      V3R l4       pV P                  V! 4       R4       \        RR7      V3R l4       p	V P                  V	! 4       ^4       \        RR7      V3R l4       p
\        P                  \        P
                  3pV P                  V4      ;_uu_ 4       pV
! 4        RRR4       . ROpV F(  pV P                  V\        XP                  4      4       K*  	  R#   + '       g   i     EL-; i  + '       g   i     LX; i)z
Test to make sure that targets can share generic implementations and
cannot reach implementations that are not in their target hierarchy.
rT  r,  c                     V! W4      pR  pW43# )c                 "    VP                   ! V!  # rU   )mulr2  s   &&&&r4   r   cTestTargetHierarchySelection.test_intrinsic_selection.<locals>.intrin_math_generic.<locals>.codegen3      {{F++r3   r-   r7  s   &&&  r4   intrin_math_genericRTestTargetHierarchySelection.test_intrinsic_selection.<locals>.intrin_math_generic/      A'C, <r3   r5   c                     V! W4      pR  pW43# )c                 "    VP                   ! V!  # rU   r0  r2  s   &&&&r4   r   _TestTargetHierarchySelection.test_intrinsic_selection.<locals>.intrin_math_dpu.<locals>.codegen<  r  r3   r-   r7  s   &&&  r4   intrin_math_dpuNTestTargetHierarchySelection.test_intrinsic_selection.<locals>.intrin_math_dpu8  r  r3   r   c                     V! W4      pR  pW43# )c                 "    VP                   ! V!  # rU   )addr2  s   &&&&r4   r   _TestTargetHierarchySelection.test_intrinsic_selection.<locals>.intrin_math_cpu.<locals>.codegenE  r  r3   r-   r7  s   &&&  r4   intrin_math_cpuNTestTargetHierarchySelection.test_intrinsic_selection.<locals>.intrin_math_cpuA  r  r3   c                     < S ! ^^4      #    r-   r  s   r4   cpu_foo_specificOTestTargetHierarchySelection.test_intrinsic_selection.<locals>.cpu_foo_specificK      "1a((r3   c                     < S ! ^^4      # r  r-   r  s   r4   cpu_foo_genericNTestTargetHierarchySelection.test_intrinsic_selection.<locals>.cpu_foo_genericR      &q!,,r3   c                     < S ! ^^4      # r  r-   r  s   r4   cpu_foo_dpuJTestTargetHierarchySelection.test_intrinsic_selection.<locals>.cpu_foo_dpuY  r  r3   NTr  c                     < S ! ^^4      # r  r-   r  s   r4   dpu_foo_specificOTestTargetHierarchySelection.test_intrinsic_selection.<locals>.dpu_foo_specifich  r  r3   c                     < S ! ^^4      # r  r-   r  s   r4   dpu_foo_genericNTestTargetHierarchySelection.test_intrinsic_selection.<locals>.dpu_foo_generico  r  r3   c                     < S ! ^^4      # r  r-   r  s   r4   dpu_foo_cpuJTestTargetHierarchySelection.test_intrinsic_selection.<locals>.dpu_foo_cpuv  r  r3   )r  zintrinsic intrin_math_dpufor the current targetr   )r  zintrinsic intrin_math_cpur  )r	   r   rI  r   r  r  r  r  r  r  r   )rM   r  r  r  r  r  r  r  r  r  r  r  r  r  s   &          @@@r4   test_intrinsic_selection5TestTargetHierarchySelection.test_intrinsic_selection(  s    
)	$	  
%	  
%	 	  
!	  
%	 	  
!	  
	) 
	) 	)+Q/ 
	- 
	- 	*B/ 
	) 
	) ))6+=+=>v&&&M '+ CMM#s6#3#345  
t		) 
	) 	)+R0 
t		- 
	- 	*B/ 
t		) 
	) ))6+=+=>v&&&M '+ CMM#s6#3#345 G '&&: '&s   G:6H:H	H	c                  aa	a
 R  o	\        RR7      V	3R l4       o
\        \        P                  RRRR/R7      V
3R l4       p\	        \
        P                  RRR/R7      R	 4       pR
 o\	        SRRR/R7      R 4       p^ RIHp V! R4      ;_uu_ 4        \        RR7      V3R l4       pV! 4       pRRR4       ^ RI
Hp V P                  XVP                  4       R#   + '       g   i     L4; i)c                 V   VP                   VP                   8X  d   V# VP                   VP                   8  d!   VP                  W P                  V4      4      # VP                  '       d!   VP	                  W P                  V4      4      # VP                  W P                  V4      4      # rU   )bitwidthtruncr%  signedsextzext)r  r   r   r  r  s   &&&&&r4   cast_integerKTestTargetHierarchySelection.test_overload_allocation.<locals>.cast_integer  s    }}/
0}}S*@*@*FGG||C)?)?)EFF ||C)?)?)EFFr3   r5   r,  c                |   < V3R lp^ RI Hp \        P                  ! \        P                  4      pV! WQV4      pWc3# )z;Intrinsic to call into the allocator for Array
            c                    < Vw  rES! WVVP                   ^,          \        P                  4      pV P                  P	                  WV4      pV# rW  )r   r   uint32nrtmeminfo_alloc_aligned)	r  r   	signaturer   	allocsizealign	align_u32meminfor  s	   &&&&    r4   r   \TestTargetHierarchySelection.test_overload_allocation.<locals>.intrin_alloc.<locals>.codegen  sM    %)" )5)2):ELLJ	!++;;G<EGr3   )r  )numba.core.typingr  r   MemInfoPointervoidptr)	typingctxr  r  r   r  miprQ   r  s   &&&    r4   intrin_allocKTestTargetHierarchySelection.test_overload_allocation.<locals>.intrin_alloc  s5    	 4&&u}}5CCE2C<r3   	_allocater  T)r-  jit_optionsc                    < V3R  lpV# )c                    < S! W4      # rU   r-   )clsr  r  r  s   &&&r4   r>  aTestTargetHierarchySelection.test_overload_allocation.<locals>._ol_arr_allocate_dpu.<locals>.impl  s    #I55r3   r-   )r  r  r  r>  r  s   &&& r4   _ol_arr_allocate_dpuSTestTargetHierarchySelection.test_overload_allocation.<locals>._ol_arr_allocate_dpu  s    6Kr3   c                     R  pV# )c                 B    \         P                  P                  V ^4      # rj  )r   Arrayr
  )ns   &r4   r>  ZTestTargetHierarchySelection.test_overload_allocation.<locals>.ol_empty_impl.<locals>.impl  s    {{,,Q22r3   r-   )r  r>  s   & r4   ol_empty_implLTestTargetHierarchySelection.test_overload_allocation.<locals>.ol_empty_impl  s    3Kr3   c                      R # rU   r-   r-   r3   r4   buffer_funcJTestTargetHierarchySelection.test_overload_allocation.<locals>.buffer_func  rS  r3   c                      R  p V # )c                  .    \         P                  ! ^
4      # rb  )npemptyr-   r3   r4   r>  `TestTargetHierarchySelection.test_overload_allocation.<locals>.ol_buffer_func_impl.<locals>.impl  s    xx|#r3   r-   )r>  s    r4   ol_buffer_func_implRTestTargetHierarchySelection.test_overload_allocation.<locals>.ol_buffer_func_impl  s    $Kr3   )r   r  c                     < S ! 4       # rU   r-   )r  s   r4   r  BTestTargetHierarchySelection.test_overload_allocation.<locals>.foo  s    "}$r3   N)r  )r	   r   r   r  r   r  r  numba.core.target_extensionr   r   numba.core.runtimer  assertIsInstanceMemInfo)rM   r  r  r!  r   r  rr  r  r  r  s   &       @@@r4   test_overload_allocation5TestTargetHierarchySelection.test_overload_allocation  s    	G 
%	 	  
!	 & 
ekk;u+5d*;
=	
=	
 
"((5z$6G	H	 
I	
	 
+e*T9J	K	 
L	
 	@ U##4 % !%A	 $
 	+a- $#s   C  C0	c                   V P                  4       w  r\        V! 4       4      p\        VR RR7      R 4       pV P                  \        P
                  R4      ;_uu_ 4        \        \        P                  ! V4      4      R 4       pRRR4       \        \        P                  ! \        P                  R,          V4      4      R 4       pR#   + '       g   i     LM; i)	dpu_onlyr5   r,  c                     R  pV# )c                     ^*# )*   r-   )objs   &r4   impcTestTargetHierarchySelection.test_overload_attribute_target.<locals>.ov_dummy_dpu_attr.<locals>.imp  s    r3   r-   )r1  r2  s   & r4   ov_dummy_dpu_attrVTestTargetHierarchySelection.test_overload_attribute_target.<locals>.ov_dummy_dpu_attr  s     Jr3   zUnknown attribute 'dpu_only'c                     V P                   # rU   r-  rP  s   &r4   illegal_target_attr_use\TestTargetHierarchySelection.test_overload_attribute_target.<locals>.illegal_target_attr_use  s    zz!r3   N:NNrX  c                 $    VP                   V ^ &   R# )    Nr7  )resdummys   &&r4   cuda_target_attr_useYTestTargetHierarchySelection.test_overload_attribute_target.<locals>.cuda_target_attr_use  s    ^^CFr3   )make_dummy_typer!   r   assertRaisesRegexr   r  r   r   int64r   void)rM   MyDummyMyDummyTypemydummy_typer4  r8  r>  s   &      r4   test_overload_attribute_target;TestTargetHierarchySelection.test_overload_attribute_target  s    #335gi(	KE	B	 
C	 ##F$6$6$BD D%++l+," -"D 
ejjS)<8	9	$ 
:	$D Ds   &C

C	r-   N)r.   r/   r0   r1   __doc__rL  ru  r  r  r  r  r  r*  rG  r2   rm   rn   s   @r4   rD  rD    sC     9B .D(.T68
22*Z6xC.J$ $r3   rD  c                   *   a  ] tR tRt o RtR tRtV tR# )TestTargetOffloadi  a  In this use case the CPU compilation pipeline is extended with a new
compilation pass that runs just prior to lowering. The pass looks for
function calls and when it finds one it sees if there's a DPU function
available that is a valid overload for the function call. If there is one
then it swaps the CPU implementation out for a DPU implementation. This
producing an "offload" effect.
c                  aa R o\        \        P                  RR7      R 4       p\        RR7      R 4       pV P	                  V! ^4      R4       \
        R 4       pV P	                  V! ^4      \        P                  ! ^4      4       \        R R R	7       ! V3R
 lR\        4      4       o ! V3R lR\        4      p\        VR7      R 4       pV P	                  V! ^4      R\        P                  ! ^4      34       R# )Fr5   r,  c                     R  pV# )c                     R # )    ,Ar-   rP  s   &r4   dpu_sin_implQTestTargetOffload.test_basic_offload.<locals>.ol_np_sin_DPU.<locals>.dpu_sin_impl  s    r3   r-   )r9  rP  s   & r4   ol_np_sin_DPU;TestTargetOffload.test_basic_offload.<locals>.ol_np_sin_DPU  s       r3   Tr  c                 .    \         P                  ! V 4      # rU   r  sinrP  s   &r4   r  1TestTargetOffload.test_basic_offload.<locals>.foo      66!9r3   rO  c                 .    \         P                  ! V 4      # rU   rU  rP  s   &r4   r  rW    rX  r3   )mutates_CFGanalysis_onlyc                   8   <a  ] tR tRt o RtR tV3R ltRtV tR# )@TestTargetOffload.test_basic_offload.<locals>.DispatcherSwitcheri  DispatcherSwitcherc                2    \         P                  ! V 4       R # rU   )r(   r   rW   s   &r4   r   ITestTargetOffload.test_basic_offload.<locals>.DispatcherSwitcher.__init__  s    %%d+r3   c                  < VP                   pR pVP                  P                  4        F  pVP                  R4       F  pVP                  VP
                  P                  ,          pRp\        V4      ;_uu_ 4         VP                  VP                  VP                  V,          P                  / 4      p\        V4      p	V	P                  P                  p
V
P                  Wh4       TP$                  P&                  T
n        Yun        RpRRR4       K  	  K  	  V#   \          d3   pS'       d   RT RT RT 2p\#        T4        Rp?RRR4       EK  Rp?ii ; i  + '       g   i     EK2  ; i)Fcallr5   z+Failed to find and compile an overload for z for z due to NT)func_irblocksvalues
find_exprstypemapr  rG   r   get_call_typer  	calltypesr   r   r   r   get_function	Exceptionprint	targetctx_codelib_stackr-  )rM   staterc  mutatedblkrb  functiontnamerQ   r  hw_ctxer  _DEBUGs   &&           r4   run_passITestTargetOffload.test_basic_offload.<locals>.DispatcherSwitcher.run_pass  sP   --">>002C !$v 6#(==#@ % -U33)&.&<&<$)OO$)OOD$9$>$>$&'"
 (C5'I)-)9)9)H)H & 3 3H B !& > > #1 +0K&*GE 43 !7 3Z 3 $- )#)+88@zug N223)6 %(
 %*#J (' 43) 433s7   =E	?A*D)#E	E)EE	EE	E0r-   N)	r.   r/   r0   r1   _namer   rw  r2   rm   )ro   rv  s   @r4   r^  r]    s     (E,0 0r3   r^  c                   .   <a  ] tR tRt o V3R ltRtV tR# )@TestTargetOffload.test_basic_offload.<locals>.DPUOffloadCompileriB  c                   < \         P                  ! V P                  4      pVP                  S\        4       VP                  4        V.# rU   )r'   define_nopython_pipelinero  add_pass_afterr*   finalize)rM   pmr^  s   & r4   define_pipelinesQTestTargetOffload.test_basic_offload.<locals>.DPUOffloadCompiler.define_pipelinesC  s9    '@@L!!"46GHtr3   r-   N)r.   r/   r0   r1   r  r2   rm   )ro   r^  s   @r4   DPUOffloadCompilerr{  B  s      r3   r  )r  c                 Z    \         P                  ! V 4      \         P                  ! V 4      3# rU   )r  rV  cosrP  s   &r4   r  rW  K  s    66!9bffQi''r3   N)
r   r  rV  r   rt  r   r)   r(   r&   r  )rM   rR  r  r  r^  rv  s   &   @@r4   test_basic_offload$TestTargetOffload.test_basic_offload  s     
"&&	'	  
(	  
t		 
	 	A1 
	 
	 	Aq	2	5	>6	 6	 
?6	r	 	 
/	0	( 
1	( 	A266!9(=>r3   r-   N)r.   r/   r0   r1   rI  r  r2   rm   rn   s   @r4   rK  rK    s     b? b?r3   rK  __main__)_rI  unittestnumba.tests.supportr   rb   operator	functoolsr   numpyr  numbar   r   numba.extendingr   r   r   r	   r%  r
   r   r   r   r   r   r   
numba.corer   r   r   numba.core.dispatcherr   numba.core.descriptorsr   r   r   r   numba.core.baser   numba.core.compiler_lockr   r   numba.core.codegenr   r   numba.core.callwrapperr   numba.core.imputilsr   r    numba.core.typing.typeofr!   r"   llvmlite.bindingbindingrD   llvmliter#   r   r&  r$   r%   numba.core.compilerr&   r'   numba.core.compiler_machineryr(   r)   numba.core.typed_passesr*   r,   r7   r}   rq   r   r   r   r   lower_constantDummyr  
lower_castIntegerLiteralrA  r"  r(  Floatr+  r;  r  rB  rD  rK  r.   mainr-   r3   r4   <module>r     s    (   %  > >   3 2 , 3 + + ' 9  9 0 8 +    $  @ E 5#   
*-J *-\ !
 
E ER-  -: u
(J ( /< OE* +
%
< %
T (,_U# $ %%ekk2% 3%
 !!%"6"6FA GA %%emm4 5 %%ekk2 3 %  
(,,u% &T$8 T$n
k? k?\ zMMO r3   