1-
1+ # NO VIBE CODING
22
33from mpi4py import MPI
44from petsc4py import PETSc
@@ -72,7 +72,7 @@ def extract_integration_domains(form: ufl.Form)->tuple[ufl.Form, dict[dolfinx.fe
7272 entities = dolfinx .cpp .mesh .exterior_facet_indices (tag .topology )
7373 else :
7474 num_entities_local = tag .topology .index_map (edim ).size_local
75- entities = np .arange (num_entities_local )
75+ entities = np .arange (num_entities_local , dtype = np . int32 )
7676 integration_entities = dolfinx .cpp .fem .compute_integration_domains (dfx_type , tag .topology , entities )
7777 else :
7878
@@ -164,7 +164,7 @@ def marker(x):
164164
165165
166166 start = time .perf_counter ()
167- num_batches = 1000
167+ num_batches = 100
168168 Fs = create_batched_form (F , num_batches = num_batches )
169169 b_batched = dolfinx .fem .petsc .create_vector (V )
170170 for Fi in Fs :
@@ -179,5 +179,19 @@ def marker(x):
179179 b_ref .ghostUpdate (addv = PETSc .InsertMode .ADD , mode = PETSc .ScatterMode .REVERSE )
180180 end_ref = time .perf_counter ()
181181
182+ coeffs = dolfinx .fem .pack_coefficients (F_ref )
183+ max_mem = 0
184+ for key , value in coeffs .items ():
185+ if value .nbytes > max_mem :
186+ max_mem = value .nbytes
187+
188+ max_mem_b = 0
189+ for i in range (num_batches ):
190+ batched_coeff = dolfinx .fem .pack_coefficients (Fs [i ])
191+ for key , value in batched_coeff .items ():
192+ if max_mem_b < value .nbytes :
193+ max_mem_b = value .nbytes
194+
195+ print (max_mem , max_mem_b , max_mem / max_mem_b )
182196 print (f"Batched { end - start } , Ref { end_ref - start_ref } " )
183197 np .testing .assert_allclose (b_ref .array , b_batched .array )
0 commit comments