Skip to content

Commit 01a5c7b

Browse files
Flush timers (#165)
1 parent b264f2f commit 01a5c7b

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

src/cgpoisson_problem.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ cgpoisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order,
6363
fem::create_functionspace(mesh, dolfinx_element));
6464

6565
t0.stop();
66+
t0.flush();
6667

6768
common::Timer t1("ZZZ Assemble");
6869

@@ -94,6 +95,7 @@ cgpoisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order,
9495

9596
auto bc = std::make_shared<fem::DirichletBC<T>>(u0, bdofs);
9697
t2.stop();
98+
t2.flush();
9799

98100
// Define coefficients
99101
common::Timer t3("ZZZ Create RHS function");
@@ -122,6 +124,7 @@ cgpoisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order,
122124
return {f, {f.size()}};
123125
});
124126
t3.stop();
127+
t3.flush();
125128

126129
std::vector form_poisson_L
127130
= {form_Poisson_L1, form_Poisson_L2, form_Poisson_L3};

src/elasticity_problem.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
111111
fem::create_functionspace(mesh, dolfinx_element));
112112

113113
t0.stop();
114+
t0.flush();
114115

115116
common::Timer t0a("ZZZ Create boundary conditions");
116117

@@ -144,6 +145,7 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
144145
auto bc = std::make_shared<const fem::DirichletBC<T>>(u0, bdofs);
145146

146147
t0a.stop();
148+
t0a.flush();
147149

148150
common::Timer t0b("ZZZ Create RHS function");
149151

@@ -174,6 +176,7 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
174176
});
175177

176178
t0b.stop();
179+
t0b.flush();
177180

178181
common::Timer t0c("ZZZ Create forms");
179182

@@ -187,6 +190,7 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
187190
auto a = std::make_shared<const fem::Form<T, double>>(fem::create_form<T>(
188191
*form_elasticity_a.at(order - 1), {V, V}, {}, {}, {}, {}));
189192
t0c.stop();
193+
t0c.flush();
190194

191195
// Create matrices and vector, and assemble system
192196
std::shared_ptr<la::petsc::Matrix> A = std::make_shared<la::petsc::Matrix>(
@@ -206,6 +210,7 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
206210
MatAssemblyBegin(A->mat(), MAT_FINAL_ASSEMBLY);
207211
MatAssemblyEnd(A->mat(), MAT_FINAL_ASSEMBLY);
208212
t2.stop();
213+
t2.flush();
209214

210215
// Wrap la::Vector with Petsc Vec
211216
la::Vector<T> b(L->function_spaces()[0]->dofmap()->index_map,
@@ -223,6 +228,7 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
223228
b.scatter_rev(std::plus<>());
224229
bc->set(b.mutable_array(), std::nullopt);
225230
t3.stop();
231+
t3.flush();
226232

227233
common::Timer t4("ZZZ Create near-nullspace");
228234

@@ -235,6 +241,7 @@ elastic::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
235241
MatNullSpaceDestroy(&ns);
236242

237243
t4.stop();
244+
t4.flush();
238245

239246
std::function<int(fem::Function<T>&, const la::Vector<T>&)> solver_function
240247
= [A](fem::Function<T>& u, const la::Vector<T>& b)

src/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,14 @@ void solve(int argc, char* argv[])
140140
ndofs_per_node);
141141
}
142142
t0.stop();
143+
t0.flush();
143144

144145
dolfinx::common::Timer t_ent(
145146
"ZZZ Create facets and facet->cell connectivity");
146147
mesh->topology_mutable()->create_entities(2);
147148
mesh->topology_mutable()->create_connectivity(2, 3);
148149
t_ent.stop();
150+
t_ent.flush();
149151

150152
if (problem_type == "poisson")
151153
{
@@ -206,6 +208,7 @@ void solve(int argc, char* argv[])
206208
dolfinx::common::Timer t5("ZZZ Solve");
207209
int num_iter = solver_function(*u, *b);
208210
t5.stop();
211+
t5.flush();
209212

210213
if (output)
211214
{
@@ -216,6 +219,7 @@ void solve(int argc, char* argv[])
216219
file.write_mesh(*mesh);
217220
file.write_function(*u, 0.0);
218221
t6.stop();
222+
t6.flush();
219223
}
220224

221225
// Display timings
@@ -241,14 +245,17 @@ int main(int argc, char* argv[])
241245
dolfinx::common::Timer t0("Init MPI");
242246
MPI_Init(&argc, &argv);
243247
t0.stop();
248+
t0.flush();
244249

245250
dolfinx::common::Timer t1("Init logging");
246251
dolfinx::init_logging(argc, argv);
247252
t1.stop();
253+
t1.flush();
248254

249255
dolfinx::common::Timer t2("Init PETSc");
250256
PetscInitialize(&argc, &argv, nullptr, nullptr);
251257
t2.stop();
258+
t2.flush();
252259

253260
// Set the logging thread name to show the process rank and enable on
254261
// rank 0 (add more here if desired)

src/poisson_problem.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ poisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
4444
fem::create_functionspace(mesh, dolfinx_element));
4545

4646
t0.stop();
47+
t0.flush();
4748

4849
common::Timer t1("ZZZ Assemble");
4950

@@ -75,6 +76,7 @@ poisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
7576

7677
auto bc = std::make_shared<fem::DirichletBC<T>>(u0, bdofs);
7778
t2.stop();
79+
t2.flush();
7880

7981
// Define coefficients
8082
common::Timer t3("ZZZ Create RHS function");
@@ -103,6 +105,7 @@ poisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
103105
return {f, {f.size()}};
104106
});
105107
t3.stop();
108+
t3.flush();
106109

107110
std::vector form_poisson_L
108111
= {form_Poisson_L1, form_Poisson_L2, form_Poisson_L3};
@@ -133,6 +136,7 @@ poisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
133136
MatAssemblyBegin(A->mat(), MAT_FINAL_ASSEMBLY);
134137
MatAssemblyEnd(A->mat(), MAT_FINAL_ASSEMBLY);
135138
t4.stop();
139+
t4.flush();
136140

137141
// Create la::Vector
138142
la::Vector<T> b(L->function_spaces()[0]->dofmap()->index_map,
@@ -150,8 +154,10 @@ poisson::problem(std::shared_ptr<mesh::Mesh<double>> mesh, int order)
150154
b.scatter_rev(std::plus<>());
151155
bc->set(b.mutable_array(), std::nullopt);
152156
t5.stop();
157+
t5.flush();
153158

154159
t1.stop();
160+
t1.flush();
155161

156162
// Create Function to hold solution
157163
auto u = std::make_shared<fem::Function<T>>(V);

0 commit comments

Comments
 (0)