Fix constraints cycle counting
authorSzilárd Páll <pall.szilard@gmail.com>
Wed, 26 Sep 2018 00:47:46 +0000 (03:47 +0300)
committerBerk Hess <hess@kth.se>
Sat, 29 Sep 2018 20:36:26 +0000 (22:36 +0200)
Cycle counter start/stop calls were misplaced after earlier refactoring
of the constraints code.
This change fixes the duoble-counting issues introduced and makde some
minor code simplifications.

Fixes #2652

Change-Id: I5aaed801320b11a848530b97274bc562f34fbcfe

src/gromacs/mdlib/update.cpp
src/gromacs/mdlib/update.h
src/gromacs/mdrun/md.cpp

index 1f1d3b95765977420fe349afedcd3045d4ec02f6..879c2e11ae9aba8d0ee72150e1004fbe28be49a4 100644 (file)
@@ -1450,7 +1450,6 @@ void constrain_velocities(int64_t                        step,
                           real                          *dvdlambda, /* the contribution to be added to the bonded interactions */
                           t_state                       *state,
                           tensor                         vir_part,
-                          gmx_wallcycle_t                wcycle,
                           gmx::Constraints              *constr,
                           gmx_bool                       bCalcVir,
                           bool                           do_log,
@@ -1474,16 +1473,12 @@ void constrain_velocities(int64_t                        step,
         clear_mat(vir_part);
 
         /* Constrain the coordinates upd->xp */
-        wallcycle_start(wcycle, ewcCONSTR);
-        {
-            constr->apply(do_log, do_ene,
-                          step, 1, 1.0,
-                          as_rvec_array(state->x.data()), as_rvec_array(state->v.data()), as_rvec_array(state->v.data()),
-                          state->box,
-                          state->lambda[efptBONDED], dvdlambda,
-                          nullptr, bCalcVir ? &vir_con : nullptr, ConstraintVariable::Velocities);
-        }
-        wallcycle_stop(wcycle, ewcCONSTR);
+        constr->apply(do_log, do_ene,
+                      step, 1, 1.0,
+                      as_rvec_array(state->x.data()), as_rvec_array(state->v.data()), as_rvec_array(state->v.data()),
+                      state->box,
+                      state->lambda[efptBONDED], dvdlambda,
+                      nullptr, bCalcVir ? &vir_con : nullptr, ConstraintVariable::Velocities);
 
         if (bCalcVir)
         {
@@ -1496,7 +1491,6 @@ void constrain_coordinates(int64_t                        step,
                            real                          *dvdlambda, /* the contribution to be added to the bonded interactions */
                            t_state                       *state,
                            tensor                         vir_part,
-                           gmx_wallcycle_t                wcycle,
                            gmx_update_t                  *upd,
                            gmx::Constraints              *constr,
                            gmx_bool                       bCalcVir,
@@ -1515,16 +1509,12 @@ void constrain_coordinates(int64_t                        step,
         clear_mat(vir_part);
 
         /* Constrain the coordinates upd->xp */
-        wallcycle_start(wcycle, ewcCONSTR);
-        {
-            constr->apply(do_log, do_ene,
-                          step, 1, 1.0,
-                          as_rvec_array(state->x.data()), as_rvec_array(upd->xp.data()), nullptr,
-                          state->box,
-                          state->lambda[efptBONDED], dvdlambda,
-                          as_rvec_array(state->v.data()), bCalcVir ? &vir_con : nullptr, ConstraintVariable::Positions);
-        }
-        wallcycle_stop(wcycle, ewcCONSTR);
+        constr->apply(do_log, do_ene,
+                      step, 1, 1.0,
+                      as_rvec_array(state->x.data()), as_rvec_array(upd->xp.data()), nullptr,
+                      state->box,
+                      state->lambda[efptBONDED], dvdlambda,
+                      as_rvec_array(state->v.data()), bCalcVir ? &vir_con : nullptr, ConstraintVariable::Positions);
 
         if (bCalcVir)
         {
@@ -1593,17 +1583,13 @@ update_sd_second_half(int64_t                        step,
         inc_nrnb(nrnb, eNR_UPDATE, homenr);
         wallcycle_stop(wcycle, ewcUPDATE);
 
-        {
-            /* Constrain the coordinates upd->xp for half a time step */
-            wallcycle_start(wcycle, ewcCONSTR);
-            constr->apply(do_log, do_ene,
-                          step, 1, 0.5,
-                          as_rvec_array(state->x.data()), as_rvec_array(upd->xp.data()), nullptr,
-                          state->box,
-                          state->lambda[efptBONDED], dvdlambda,
-                          as_rvec_array(state->v.data()), nullptr, ConstraintVariable::Positions);
-            wallcycle_stop(wcycle, ewcCONSTR);
-        }
+        /* Constrain the coordinates upd->xp for half a time step */
+        constr->apply(do_log, do_ene,
+                      step, 1, 0.5,
+                      as_rvec_array(state->x.data()), as_rvec_array(upd->xp.data()), nullptr,
+                      state->box,
+                      state->lambda[efptBONDED], dvdlambda,
+                      as_rvec_array(state->v.data()), nullptr, ConstraintVariable::Positions);
     }
 }
 
index 1785fb115ba17353343bb09f94544adafc493ccf..f6d78e3e7cdf974f7f7c1255f41936596e23e891 100644 (file)
@@ -142,7 +142,6 @@ void constrain_velocities(int64_t                        step,
                           real                          *dvdlambda, /* the contribution to be added to the bonded interactions */
                           t_state                       *state,
                           tensor                         vir_part,
-                          gmx_wallcycle_t                wcycle,
                           gmx::Constraints              *constr,
                           gmx_bool                       bCalcVir,
                           bool                           do_log,
@@ -152,7 +151,6 @@ void constrain_coordinates(int64_t                        step,
                            real                          *dvdlambda, /* the contribution to be added to the bonded interactions */
                            t_state                       *state,
                            tensor                         vir_part,
-                           gmx_wallcycle_t                wcycle,
                            gmx_update_t                  *upd,
                            gmx::Constraints              *constr,
                            gmx_bool                       bCalcVir,
index a6aa8eab8648344a0bf5e004e3b7c1e3d5bcc4cc..c430b2cf91fd74f3df7af5dc50baadaa67474eb8 100644 (file)
@@ -895,7 +895,7 @@ void gmx::Integrator::do_md()
             constrain_velocities(step, nullptr,
                                  state,
                                  shake_vir,
-                                 wcycle, constr,
+                                 constr,
                                  bCalcVir, do_log, do_ene);
             wallcycle_start(wcycle, ewcUPDATE);
             /* if VV, compute the pressure and constraints */
@@ -1075,7 +1075,7 @@ void gmx::Integrator::do_md()
                 constrain_velocities(step, nullptr,
                                      state,
                                      tmp_vir,
-                                     wcycle, constr,
+                                     constr,
                                      bCalcVir, do_log, do_ene);
             }
         }
@@ -1137,7 +1137,7 @@ void gmx::Integrator::do_md()
 
         constrain_coordinates(step, &dvdl_constr, state,
                               shake_vir,
-                              wcycle, upd, constr,
+                              upd, constr,
                               bCalcVir, do_log, do_ene);
         update_sd_second_half(step, &dvdl_constr, ir, mdatoms, state,
                               cr, nrnb, wcycle, upd, constr, do_log, do_ene);