88#include < tbb/combinable.h>
99#include < tbb/enumerable_thread_specific.h>
1010#include < ipc/utils/MaybeParallelFor.hpp>
11- #include < igl/Timer.h>
1211
1312namespace ipc {
1413
@@ -101,9 +100,6 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
101100 const int dim = X.cols ();
102101 const int ndof = X.size ();
103102
104- igl::Timer timer;
105- timer.start ();
106-
107103 const int max_triplets_size = int (1e7 );
108104 const int buffer_size = std::min (max_triplets_size, ndof);
109105 auto storage = ipc::utils::create_thread_storage (LocalThreadMatStorage (buffer_size, ndof, ndof));
@@ -127,9 +123,6 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
127123 local_hess, vids, dim, *(hess_triplets.cache ));
128124 }
129125 });
130-
131- timer.stop ();
132- logger ().trace (" done separate assembly {}s..." , timer.getElapsedTime ());
133126
134127 Eigen::SparseMatrix<double > hess (ndof, ndof);
135128
@@ -143,12 +136,9 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
143136 storages[index++] = &local_storage;
144137 }
145138
146- timer.start ();
147139 utils::maybe_parallel_for (storages.size (), [&](int i) {
148140 storages[i]->cache ->prune ();
149141 });
150- timer.stop ();
151- logger ().trace (" done pruning triplets {}s..." , timer.getElapsedTime ());
152142
153143 if (storage.size () == 0 )
154144 {
@@ -171,42 +161,28 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
171161 assert (storages.size () >= 1 );
172162 if (storages[0 ]->cache ->is_dense ())
173163 {
174- timer.start ();
175164 // Serially merge local storages
176165 Eigen::MatrixXd tmp (hess);
177166 for (const auto &local_storage : storage)
178167 tmp += dynamic_cast <const DenseMatrixCache &>(*local_storage.cache ).mat ();
179168 hess = tmp.sparseView ();
180169 hess.makeCompressed ();
181- timer.stop ();
182-
183- logger ().trace (" Serial assembly time: {}s..." , timer.getElapsedTime ());
184170 }
185171 else if (triplet_count >= triplets.max_size ())
186172 {
187173 // Serial fallback version in case the vector of triplets cannot be allocated
188174
189175 logger ().warn (" Cannot allocate space for triplets, switching to serial assembly." );
190176
191- timer.start ();
192177 // Serially merge local storages
193178 for (LocalThreadMatStorage &local_storage : storage)
194179 hess += local_storage.cache ->get_matrix (false ); // will also prune
195180 hess.makeCompressed ();
196- timer.stop ();
197-
198- logger ().trace (" Serial assembly time: {}s..." , timer.getElapsedTime ());
199181 }
200182 else
201183 {
202- timer.start ();
203184 triplets.resize (triplet_count);
204- timer.stop ();
205185
206- logger ().trace (" done allocate triplets {}s..." , timer.getElapsedTime ());
207- logger ().trace (" Triplets Count: {}" , triplet_count);
208-
209- timer.start ();
210186 // Parallel copy into triplets
211187 utils::maybe_parallel_for (storages.size (), [&](int i) {
212188 const SparseMatrixCache &cache = dynamic_cast <const SparseMatrixCache &>(*storages[i]->cache );
@@ -229,15 +205,8 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
229205 }
230206 });
231207
232- timer.stop ();
233- logger ().trace (" done concatenate triplets {}s..." , timer.getElapsedTime ());
234-
235- timer.start ();
236208 // Sort and assemble
237209 hess.setFromTriplets (triplets.begin (), triplets.end ());
238- timer.stop ();
239-
240- logger ().trace (" done setFromTriplets assembly {}s..." , timer.getElapsedTime ());
241210 }
242211
243212 return hess;
0 commit comments