@@ -44,7 +44,9 @@ def __init__(self, ast=None, integral_type=None, oriented=False,
4444 subdomain_id = None , domain_number = None ,
4545 coefficient_numbers = (),
4646 needs_cell_sizes = False ,
47- flop_count = 0 ):
47+ tabulations = None ,
48+ flop_count = 0 ,
49+ name = None ):
4850 # Defaults
4951 self .ast = ast
5052 self .integral_type = integral_type
@@ -53,7 +55,9 @@ def __init__(self, ast=None, integral_type=None, oriented=False,
5355 self .subdomain_id = subdomain_id
5456 self .coefficient_numbers = coefficient_numbers
5557 self .needs_cell_sizes = needs_cell_sizes
58+ self .tabulations = tabulations
5659 self .flop_count = flop_count
60+ self .name = name
5761 super (Kernel , self ).__init__ ()
5862
5963
@@ -123,13 +127,9 @@ def __init__(self, integral_data_info, scalar_type, fem_scalar_type,
123127 dont_split = (), diagonal = False ):
124128 """Initialise a kernel builder."""
125129 integral_type = integral_data_info .integral_type
126- subdomain_id = integral_data_info .subdomain_id
127- domain_number = integral_data_info .domain_number
128130 super (KernelBuilder , self ).__init__ (scalar_type , integral_type .startswith ("interior_facet" ))
129131 self .fem_scalar_type = fem_scalar_type
130132
131- self .kernel = Kernel (integral_type = integral_type , subdomain_id = subdomain_id ,
132- domain_number = domain_number )
133133 self .diagonal = diagonal
134134 self .local_tensor = None
135135 self .coordinates_arg = None
@@ -213,7 +213,6 @@ def set_coefficients(self, integral_data, form_data):
213213 for i , coefficient in enumerate (coefficients ):
214214 self .coefficient_args .append (
215215 self ._coefficient (coefficient , "w_%d" % i ))
216- self .kernel .coefficient_numbers = tuple (self .integral_data_info .coefficient_numbers )
217216
218217 def register_requirements (self , ir ):
219218 """Inspect what is referenced by the IR that needs to be
@@ -233,36 +232,38 @@ def construct_kernel(self, name, ctx):
233232 impero_c , oriented , needs_cell_sizes , tabulations = self .compile_gem (ctx )
234233 if impero_c is None :
235234 return self .construct_empty_kernel (name )
236- self .kernel .oriented = oriented
237- self .kernel .needs_cell_sizes = needs_cell_sizes
238- self .kernel .tabulations = tabulations
239-
240- index_names = get_index_names (ctx ['quadrature_indices' ], self .argument_multiindices , ctx ['index_cache' ])
241- body = generate_coffee (impero_c , index_names , self .scalar_type )
242-
235+ info = self .integral_data_info
243236 args = [self .local_tensor , self .coordinates_arg ]
244- if self . kernel . oriented :
237+ if oriented :
245238 args .append (cell_orientations_coffee_arg )
246- if self . kernel . needs_cell_sizes :
239+ if needs_cell_sizes :
247240 args .append (self .cell_sizes_arg )
248241 args .extend (self .coefficient_args )
249- if self . kernel .integral_type in ["exterior_facet" , "exterior_facet_vert" ]:
242+ if info .integral_type in ["exterior_facet" , "exterior_facet_vert" ]:
250243 args .append (coffee .Decl ("unsigned int" ,
251244 coffee .Symbol ("facet" , rank = (1 ,)),
252245 qualifiers = ["const" ]))
253- elif self . kernel .integral_type in ["interior_facet" , "interior_facet_vert" ]:
246+ elif info .integral_type in ["interior_facet" , "interior_facet_vert" ]:
254247 args .append (coffee .Decl ("unsigned int" ,
255248 coffee .Symbol ("facet" , rank = (2 ,)),
256249 qualifiers = ["const" ]))
257-
258- for name_ , shape in self .kernel .tabulations :
250+ for name_ , shape in tabulations :
259251 args .append (coffee .Decl (self .scalar_type , coffee .Symbol (
260252 name_ , rank = shape ), qualifiers = ["const" ]))
261-
262- self .kernel .name = name
263- self .kernel .ast = KernelBuilderBase .construct_kernel (self , name , args , body )
264- self .kernel .flop_count = count_flops (impero_c )
265- return self .kernel
253+ index_names = get_index_names (ctx ['quadrature_indices' ], self .argument_multiindices , ctx ['index_cache' ])
254+ body = generate_coffee (impero_c , index_names , self .scalar_type )
255+ ast = KernelBuilderBase .construct_kernel (self , name , args , body )
256+ flop_count = count_flops (impero_c ) # Estimated total flops for this kernel.
257+ return Kernel (ast = ast ,
258+ integral_type = info .integral_type ,
259+ subdomain_id = info .subdomain_id ,
260+ domain_number = info .domain_number ,
261+ coefficient_numbers = info .coefficient_numbers ,
262+ oriented = oriented ,
263+ needs_cell_sizes = needs_cell_sizes ,
264+ tabulations = tabulations ,
265+ flop_count = flop_count ,
266+ name = name )
266267
267268 def construct_empty_kernel (self , name ):
268269 """Return None, since Firedrake needs no empty kernels.
0 commit comments