[AMBER-Developers] Faster NetFrc

From: Scott Le Grand <varelse2005.gmail.com>
Date: Thu, 21 May 2020 17:29:30 -0700

Hey guys,
Back as an AMBER developer and one of the first things I'd like to do is
optimize netfrc.

Fixed point conservative forces have no net force. They automagically
cancel out 100%. So we can ignore everything except non-conserved forces.

The only non-conserved force I know of is the Ewald Gradient Sum. So if I
add up the net force there, and handle it upon either force reduction or
update, I can eliminate two passes on memory and the two kernels currently
dedicated to adding and then subtracting them.

But... Are there any other non-conserved forces?

And... It looks like the FORTRAN and the CUDA code do different things.
FORTRAN simply averages the forces and subtracts. But CUDA only averages
over atoms with force thresholds above a predefined small amount. What's up
with that?

    if (netfrc .gt. 0 .and. onstep) then

      if (ti_mode .eq. 0) then
        do i = 1, atm_cnt
          net_frcs(:) = net_frcs(:) + frc(:, i)
        end do

        ! Now do the correction:

        net_frcs(:) = net_frcs(:) / dble(atm_cnt - numextra)

        do i = 1, atm_cnt
          frc(:, i) = frc(:, i) - net_frcs(:)
        end do
        do i = 1, atm_cnt
          ti_net_frcs(1, :) = ti_net_frcs(1, :) + ti_nb_frc(1, :, i)
          ti_net_frcs(2, :) = ti_net_frcs(2, :) + ti_nb_frc(2, :, i)
        end do

        ti_net_frcs(1,:) =
        ti_net_frcs(2,:) =
        net_frcs(:) = ti_net_frcs(1,:) + ti_net_frcs(2,:)

        do i = 1, atm_cnt
          ! This matches how sander removes netfrcs in TI runs
          if (ti_lst(1,i) .ne. 0) then
            frc(:, i) = frc(:, i) - ti_net_frcs(1,:)
          else if (ti_lst(2,i) .ne. 0) then
            frc(:, i) = frc(:, i) - ti_net_frcs(2,:)
            frc(:, i) = frc(:, i) - net_frcs(:)
          end if
        end do
      end if
      ! Any extra points must have their 0.d0 forces reset...

      if (numextra .gt. 0 .and. frameon .ne. 0) &
        call zero_extra_pnts_vec(frc, ep_frames, gbl_frame_cnt)

    end if

GTI path:
  while (pos < cSim.atoms) {
    PMEFloat fx = converter(pX[pos], ONEOVERFORCESCALE);
    PMEFloat fy = converter(pY[pos], ONEOVERFORCESCALE);
    PMEFloat fz = converter(pZ[pos], ONEOVERFORCESCALE);
    if (abs(fx) > small || abs(fy) > small || abs(fz) > small) {
      pX[pos] -= nfX;
      pY[pos] -= nfY;
      pZ[pos] -= nfZ;
    pos += increment;

AMBER-Developers mailing list
Received on Thu May 21 2020 - 17:30:02 PDT
Custom Search