<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 15/08/2012 5:46 AM, francesco oteri
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAFQcp-Nn8iLZ8V7pk8OmL1UopzhTehLCxhwtqxPh=Qj1V2NXQg@mail.gmail.com"
      type="cite">Dear gromacs users and developers,
      <div>I have a question related to domain decomposition:</div>
      <div><br>
      </div>
      <div>I have to tun multiple simulation and every step&nbsp;</div>
      <div>1) In the sim X the state of simY (and simY need state from
        sim X)</div>
      <div>2) getting the potential energy</div>
      <div>3) continuing</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>right now I am testing the point1. In particular I exchange
        the state between simulation X and Y two times:</div>
      <div>the first time this permit at simulation X to get the state
        of Y ( and vicecersa) while the second exchange</div>
      <div>restore the original situatation.</div>
    </blockquote>
    <br>
    Seems you don't actually want to exchange states, but rather do a
    computation on a copy of the other state. I'd either<br>
    1) do exchange_state on X into a different t_state from the one with
    which X is simulating (so there is no need to exchange back, since
    doing dd_partition_system a second time requires neighbour searching
    twice and that will kill your scaling even harder)<br>
    2) get Y to do the computation on its coordinates, since swapping
    the result is probably much cheaper than collecting the state,
    communcating the state, doing NS and DD on the state and then
    computing on it. That might mean maintaining multiple t_forcerec or
    gmx_mtop_t, but at least those data structures are likely constant,
    so you only have to communicate them rarely(once?).<br>
    <br>
    <blockquote
cite="mid:CAFQcp-Nn8iLZ8V7pk8OmL1UopzhTehLCxhwtqxPh=Qj1V2NXQg@mail.gmail.com"
      type="cite">
      <div><br>
      </div>
      <div>I inserted the following code between lines</div>
      <div><br>
      </div>
      <div>
        <div>&nbsp; &nbsp;if ((repl_ex_nst &gt; 0) &amp;&amp; (step &gt; 0)
          &amp;&amp; !bLastStep &amp;&amp;</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do_per_step(step,repl_ex_nst))&nbsp;</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
      </div>
      <div><br>
      </div>
      <div>and&nbsp;</div>
      <div><br>
      </div>
      <div>bExchanged = replica_exchange(fplog, cr, repl_ex,
        state_global, enerd-&gt;term, state,step,t);</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>//Performing the first exchange</div>
      <div>
        <div>&nbsp; if (DOMAINDECOMP(cr))</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; {</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>
          &nbsp;dd_collect_state(cr-&gt;dd,state,state_global);</div>
      </div>
      <div><br>
      </div>
      <div>&nbsp;if (MASTER(cr))</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; {<span class="Apple-tab-span" style="white-space:pre">
        </span> <span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;</div>
      <div>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;exchange_state(cr-&gt;ms, Y, state_global);<span
          class="Apple-tab-span" style="white-space:pre"> </span> <span
          class="Apple-tab-span" style="white-space:pre"> </span>&nbsp; &nbsp; &nbsp;</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp;}</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
      <div>
        <div>&nbsp; if (DOMAINDECOMP(cr))&nbsp;</div>
        <div>&nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-tab-span"
            style="white-space:pre"> </span> &nbsp;<span
            class="Apple-tab-span" style="white-space:pre"> </span></div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dd_partition_system(fplog,step,cr,TRUE,1, &nbsp; &nbsp; &nbsp;
          &nbsp; &nbsp;</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          state_global,top_global,ir,&nbsp;</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          state,NULL,mdatoms,top,fr,</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          vsite,shellfc,constr,</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          &nbsp;nrnb,wcycle,FALSE); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
        <div>&nbsp; &nbsp; }</div>
      </div>
      <div><br>
      </div>
      <div>//Now every node should have its part of the Y simulation</div>
      <div>//Getting potential energy</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>//Performing the second exchange</div>
      <div>
        <div>if (MASTER(cr))</div>
        <div>&nbsp; {&nbsp;</div>
        <div>&nbsp; &nbsp; exchange_state(cr-&gt;ms, Y, state_global);<span
            class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;//
          I don't need to &nbsp;call because nothing changed state_global&nbsp;
          dd_collect_state</div>
        <div>&nbsp; }</div>
      </div>
      <div><br>
      </div>
      <div>
        <div>&nbsp; if (DOMAINDECOMP(cr))&nbsp;</div>
        <div>&nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-tab-span"
            style="white-space:pre"> </span>&nbsp;&nbsp;<span
            class="Apple-tab-span" style="white-space:pre"> </span></div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dd_partition_system(fplog,step,cr,TRUE,1, &nbsp; &nbsp; &nbsp;
          &nbsp; &nbsp;</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          state_global,top_global,ir,&nbsp;</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          state,NULL,mdatoms,top,fr,</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          vsite,shellfc,constr,</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          &nbsp;nrnb,wcycle,FALSE); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
        <div>&nbsp; &nbsp; }</div>
      </div>
      <div><br>
      </div>
      <div>//Now state Y is back to simulation Y&nbsp;</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>The problem is that this simple code gives me problem, in
        particular it gives LINCS problem</div>
      <div>in do_force the step after my code is executed.</div>
      <div><br>
      </div>
      <div>Since forcing bNS=TRUE solves the problem, I guess there is
        some issue with neighbor list updating</div>
      <div>but I dont understand why.</div>
      <div><br>
      </div>
      <div>I observed that in, after the last&nbsp;dd_partition_system,
        syste-&gt;natoms had an other value compared with the value</div>
      <div>it has at the before my code is executed.</div>
      <div><br>
      </div>
      <div>What is my error?</div>
    </blockquote>
    <br>
    Particularly with dynamic load balancing, there is no reason that
    the DD for any replica should resemble the DD for any other replica.
    Each processor can have totally different atoms, and a different
    number of atoms, so blindly copying stuff into those data structures
    will lead to the kinds of problems you see. I'd still expect
    problems even if you disable dynamic load balancing. Hence my
    suggestions above.<br>
    <br>
    The implementation of replica exchange in GROMACS scales poorly
    because exchanging coordinates requires subsequent NS and DD. So I'd
    encourage you to avoid that route if you can. Exchanging
    Hamiltonians is much cheaper. I have an implementation of that for
    T-REMD, but it won't see the light of day any time soon.<br>
    <br>
    Mark<br>
  </body>
</html>