[gmx-developers] slightly odd-looking code

jan rtm443x at googlemail.com
Mon Mar 23 14:58:22 CET 2020


Hi,
I'm a general back-end dev.  Given the situation, and folding at home
using gromacs, I thought I'd poke through the code. I noticed
something unexpected, and was advised to email it here. in edsam.cpp,
this:


void do_linacc(rvec* xcoll, t_edpar* edi)
{
    /* loop over linacc vectors */
    for (int i = 0; i < edi->vecs.linacc.neig; i++)
    {
        /* calculate the projection */
        real proj = projectx(*edi, xcoll, edi->vecs.linacc.vec[i]);


        /* calculate the correction */
        real preFactor = 0.0;
        if (edi->vecs.linacc.stpsz[i] > 0.0)
        {
            if ((proj - edi->vecs.linacc.refproj[i]) < 0.0)
            {
                preFactor = edi->vecs.linacc.refproj[i] - proj;
            }
        }
        if (edi->vecs.linacc.stpsz[i] < 0.0)
        {
            if ((proj - edi->vecs.linacc.refproj[i]) > 0.0)
            {
                preFactor = edi->vecs.linacc.refproj[i] - proj;
            }
        }
       [...]


In both cases it reaches the same code

  preFactor = edi->vecs.linacc.refproj[i] - proj

That surprised me a bit, is it deliberate? If so it may be the code
can be simplified anyway.

That aside, if you're looking for performance I might be able to help.
I don't know the high level stuff *at this point* and my C++ is so
rusty it creaks, but I can brush that up, do profiling and whatnot.
I'm pretty experience, just not in this area.  Speeding things up is
something I've got a track record of (though I usually have a good
feel for the problem domain first, which I don't here)

Would it be of some value for me to try getting more speed? If so,
first thing I'd need is to get this running under cygwin, which I'm
struggling with.

regards

jan


More information about the gromacs.org_gmx-developers mailing list