[gmx-developers] the function of instruction "(0.5*rinv11*(3.0-((rsq11*rinv11)*rinv11)))" in nb_kernel***_c.c

Mark Abraham Mark.Abraham at anu.edu.au
Tue Apr 27 05:45:37 CEST 2010


On 27/04/10 13:36, execuse wrote:
> Dear,
> I am reading the source code under directory
> src/gmxlib/nonbonded/nb_kernel, I found some instructions like the
> following:
> 191             rinv11           = __frsqrtes(rsq11);
> 192             rinv11           =
> (0.5*rinv11*(3.0-((rsq11*rinv11)*rinv11)));
> 193             rinv12           = __frsqrtes(rsq12);
> 194             rinv12           =
> (0.5*rinv12*(3.0-((rsq12*rinv12)*rinv12)));
> 195             rinv13           = __frsqrtes(rsq13);
> 196             rinv13           =
> (0.5*rinv13*(3.0-((rsq13*rinv13)*rinv13)));
> 197             rinv21           = __frsqrtes(rsq21);
> 198             rinv21           =
> (0.5*rinv21*(3.0-((rsq21*rinv21)*rinv21)));
> 199             rinv22           = __frsqrtes(rsq22);
> 200             rinv22           =
> (0.5*rinv22*(3.0-((rsq22*rinv22)*rinv22)));
> 201             rinv23           = __frsqrtes(rsq23);
> 202             rinv23           =
> (0.5*rinv23*(3.0-((rsq23*rinv23)*rinv23)));
> 203             rinv31           = __frsqrtes(rsq31);
> 204             rinv31           =
> (0.5*rinv31*(3.0-((rsq31*rinv31)*rinv31)));
> 205             rinv32           = __frsqrtes(rsq32);
> 206             rinv32           =
> (0.5*rinv32*(3.0-((rsq32*rinv32)*rinv32)));
> 207             rinv33           = __frsqrtes(rsq33);
> 208             rinv33           =
> (0.5*rinv33*(3.0-((rsq33*rinv33)*rinv33)));
> As the __frsqrtes(rsq11) subroutine returns the reciprocal square root
> of the rsq11, and therefore, 3.0-((rsq11*rinv11)*rinv11) is about 2, and
> 0.5*rinv*2 is about equals to the original rinv11. Does anyone know
> whether GROMACS recalculate rinv11 with the additional instruction?

Certain architectures (e.g. IBM's PPC) implement hardware floating-point 
reciprocal square-root *estimate* operations. These require a 
Newton-Raphson iterate to achieve single-precision accuracy (two for 
double-precision). The second lines are doing that operation.

Mark



More information about the gromacs.org_gmx-developers mailing list