@@ -125,7 +125,7 @@ def call_conv(self):
125125 def mangler (self , name , argtypes , * , abi_tags = ()):
126126 return itanium_mangler .mangle (name , argtypes , abi_tags = abi_tags )
127127
128- def prepare_cuda_kernel (self , codelib , func_name , argtypes , debug ,
128+ def prepare_cuda_kernel (self , codelib , fndesc , debug ,
129129 nvvm_options , filename , linenum ,
130130 max_registers = None ):
131131 """
@@ -140,51 +140,57 @@ def prepare_cuda_kernel(self, codelib, func_name, argtypes, debug,
140140
141141 codelib: The CodeLibrary containing the device function to wrap
142142 in a kernel call.
143- func_name: The mangled name of the device function.
144- argtypes: An iterable of the types of arguments to the kernel.
143+ fndesc: The FunctionDescriptor of the source function.
145144 debug: Whether to compile with debug.
146145 nvvm_options: Dict of NVVM options used when compiling the new library.
147146 filename: The source filename that the function is contained in.
148147 linenum: The source line that the function is on.
149148 max_registers: The max_registers argument for the code library.
150149 """
151- kernel_name = itanium_mangler .prepend_namespace (func_name , ns = 'cudapy' )
150+ kernel_name = itanium_mangler .prepend_namespace (
151+ fndesc .llvm_func_name , ns = 'cudapy' ,
152+ )
152153 library = self .codegen ().create_library (f'{ codelib .name } _kernel_' ,
153154 entry_name = kernel_name ,
154155 nvvm_options = nvvm_options ,
155156 max_registers = max_registers )
156157 library .add_linking_library (codelib )
157- wrapper = self .generate_kernel_wrapper (library , kernel_name , func_name ,
158- argtypes , debug , filename ,
159- linenum )
158+ wrapper = self .generate_kernel_wrapper (library , fndesc , kernel_name ,
159+ debug , filename , linenum )
160160 return library , wrapper
161161
162- def generate_kernel_wrapper (self , library , kernel_name , func_name ,
163- argtypes , debug , filename , linenum ):
162+ def generate_kernel_wrapper (self , library , fndesc , kernel_name , debug ,
163+ filename , linenum ):
164164 """
165165 Generate the kernel wrapper in the given ``library``.
166- The function being wrapped have the name ``fname`` and argument types
167- ``argtypes``. The wrapper function is returned.
166+ The function being wrapped is described by ``fndesc``.
167+ The wrapper function is returned.
168168 """
169+
170+ argtypes = fndesc .argtypes
169171 arginfo = self .get_arg_packer (argtypes )
170172 argtys = list (arginfo .argument_types )
171173 wrapfnty = ir .FunctionType (ir .VoidType (), argtys )
172174 wrapper_module = self .create_module ("cuda.kernel.wrapper" )
173175 fnty = ir .FunctionType (ir .IntType (32 ),
174176 [self .call_conv .get_return_type (types .pyobject )]
175177 + argtys )
176- func = ir .Function (wrapper_module , fnty , func_name )
178+ func = ir .Function (wrapper_module , fnty , fndesc . llvm_func_name )
177179
178180 prefixed = itanium_mangler .prepend_namespace (func .name , ns = 'cudapy' )
179181 wrapfn = ir .Function (wrapper_module , wrapfnty , prefixed )
180182 builder = ir .IRBuilder (wrapfn .append_basic_block ('' ))
181183
182184 if debug :
183- debuginfo = self .DIBuilder (module = wrapper_module , filepath = filename )
184- debuginfo .mark_subprogram (wrapfn , kernel_name , linenum )
185+ debuginfo = self .DIBuilder (
186+ module = wrapper_module , filepath = filename , cgctx = self ,
187+ )
188+ debuginfo .mark_subprogram (
189+ wrapfn , kernel_name , fndesc .args , argtypes , linenum ,
190+ )
185191 debuginfo .mark_location (builder , linenum )
186192
187- # Define error handling variables
193+ # Define error handling variable
188194 def define_error_gv (postfix ):
189195 name = wrapfn .name + postfix
190196 gv = cgutils .add_global_variable (wrapper_module , ir .IntType (32 ),
0 commit comments