[gmx-developers] Hacking assembly nb_kernel

Mark Abraham Mark.Abraham at anu.edu.au
Wed May 25 02:40:20 CEST 2011

On 20/05/2011 5:20 PM, Igor Leontyev wrote:
> Where can I learn how to hack assembler optimized nb_kernel routines? 
> I want
> 1) Extract an electric component of force (without vdW)

This is not easy to do efficiently. Computing 1/r should be done only 
once, and so you need to write out intermediate forces. There is a 
"user" pointer in the kernels that you could use to pass in a buffer for 
the non-VDW component of forces (constructed as for the normal force 
array). I'd strongly advise reverse-engineering how the 
solvent-optimized and non-solvent-optimized assembly kernels work first, 
to see how the modification should work, and then implementing the 
"electric force buffer" approach in the generic routine. Only once the 
supporting machinery is working should you touch the assembly kernels. 
Then you'll have to run a heck of a lot of simulations to make this 

> 2) Allow SPC optimized routines to accept different charges for 
> separate water molecules.

You will lose some performance because now the routines have to look up 
the charges for each water molecule (or you have to construct different 
neighbour lists for sets of differently-changed molecules, and expand 
the "optimized solvent" recognition scheme). You can estimate how much 
by just turning off the solvent optimization with the right environment 
variable (see src/gmxlib/nonbonded.c). There is some value from the 
solvent-optimized kernels knowing in advance that there are only three 
atoms per molecule, but I don't know the relative importance of this and 
not having to look up new parameters for each molecule.


> Whatever is simpler to start. In my current realization the assembler 
> optimized routines are called twice (extra call with no vdW to get the 
> electric force) and no SPC optimization, which is yet more efficient 
> than using modified NB_GENERIC routine, but twice less efficient than 
> assembler optimized routines with SPC optimization.
> Thanks,
> Igor Leontyev

More information about the gromacs.org_gmx-developers mailing list