File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919#ifdef NEXT_MPI
2020 #include < mpi.h>
2121#endif
22+ #include < chrono>
23+ #include < fstream>
2224
2325inline void Step (ParticleSystem &ps, real dt) {
2426 if (ps.size () == 0 ) return ;
2527
28+ #ifdef NEXT_BENCHMARK
29+ auto t_start = std::chrono::high_resolution_clock::now ();
30+ #endif
31+
2632 const real theta = real (0.5 );
2733 const real half = dt * real (0.5 );
2834 const int N = static_cast <int >(ps.size ());
@@ -181,4 +187,18 @@ inline void Step(ParticleSystem &ps, real dt) {
181187 MPI_Waitall (3 , reqs4, MPI_STATUSES_IGNORE);
182188#endif
183189 }
190+
191+ #ifdef NEXT_BENCHMARK
192+ auto t_end = std::chrono::high_resolution_clock::now ();
193+ double elapsed_ms = std::chrono::duration<double , std::milli>(t_end - t_start).count ();
194+
195+ int rank = 0 ;
196+ #ifdef NEXT_MPI
197+ MPI_Comm_rank (MPI_COMM_WORLD, &rank);
198+ #endif
199+ if (rank == 0 ) {
200+ std::ofstream log (" log.txt" , std::ios::app);
201+ log << " Step time: " << elapsed_ms << " ms" << std::endl;
202+ }
203+ #endif
184204}
You can’t perform that action at this time.
0 commit comments