73ecd6b29f4f7062b60e5def3aaa2c9a86e3f1f7
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_sparc64_hpc_ace_double.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
37  */
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "vec.h"
47 #include "nrnb.h"
48
49 #include "kernelutil_sparc64_hpc_ace_double.h"
50
51 /*
52  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_VF_sparc64_hpc_ace_double
53  * Electrostatics interaction: ReactionField
54  * VdW interaction:            LennardJones
55  * Geometry:                   Particle-Particle
56  * Calculate force/pot:        PotentialAndForce
57  */
58 void
59 nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_VF_sparc64_hpc_ace_double
60                     (t_nblist                    * gmx_restrict       nlist,
61                      rvec                        * gmx_restrict          xx,
62                      rvec                        * gmx_restrict          ff,
63                      t_forcerec                  * gmx_restrict          fr,
64                      t_mdatoms                   * gmx_restrict     mdatoms,
65                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
66                      t_nrnb                      * gmx_restrict        nrnb)
67 {
68     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
69      * just 0 for non-waters.
70      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
71      * jnr indices corresponding to data put in the four positions in the SIMD register.
72      */
73     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
74     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75     int              jnrA,jnrB;
76     int              j_coord_offsetA,j_coord_offsetB;
77     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
78     real             rcutoff_scalar;
79     real             *shiftvec,*fshift,*x,*f;
80     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81     int              vdwioffset0;
82     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
83     int              vdwjidx0A,vdwjidx0B;
84     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
85     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
86     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
87     real             *charge;
88     int              nvdwtype;
89     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
90     int              *vdwtype;
91     real             *vdwparam;
92     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
93     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
94     _fjsp_v2r8       itab_tmp;
95     _fjsp_v2r8       dummy_mask,cutoff_mask;
96     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
97     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
98     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
99
100     x                = xx[0];
101     f                = ff[0];
102
103     nri              = nlist->nri;
104     iinr             = nlist->iinr;
105     jindex           = nlist->jindex;
106     jjnr             = nlist->jjnr;
107     shiftidx         = nlist->shift;
108     gid              = nlist->gid;
109     shiftvec         = fr->shift_vec[0];
110     fshift           = fr->fshift[0];
111     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
112     charge           = mdatoms->chargeA;
113     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
114     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
115     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
116     nvdwtype         = fr->ntype;
117     vdwparam         = fr->nbfp;
118     vdwtype          = mdatoms->typeA;
119
120     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
121     rcutoff_scalar   = fr->rcoulomb;
122     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
123     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
124
125     sh_vdw_invrcut6  = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
126     rvdw             = gmx_fjsp_set1_v2r8(fr->rvdw);
127
128     /* Avoid stupid compiler warnings */
129     jnrA = jnrB = 0;
130     j_coord_offsetA = 0;
131     j_coord_offsetB = 0;
132
133     outeriter        = 0;
134     inneriter        = 0;
135
136     /* Start outer loop over neighborlists */
137     for(iidx=0; iidx<nri; iidx++)
138     {
139         /* Load shift vector for this list */
140         i_shift_offset   = DIM*shiftidx[iidx];
141
142         /* Load limits for loop over neighbors */
143         j_index_start    = jindex[iidx];
144         j_index_end      = jindex[iidx+1];
145
146         /* Get outer coordinate index */
147         inr              = iinr[iidx];
148         i_coord_offset   = DIM*inr;
149
150         /* Load i particle coords and add shift vector */
151         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
152
153         fix0             = _fjsp_setzero_v2r8();
154         fiy0             = _fjsp_setzero_v2r8();
155         fiz0             = _fjsp_setzero_v2r8();
156
157         /* Load parameters for i particles */
158         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
159         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
160
161         /* Reset potential sums */
162         velecsum         = _fjsp_setzero_v2r8();
163         vvdwsum          = _fjsp_setzero_v2r8();
164
165         /* Start inner kernel loop */
166         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
167         {
168
169             /* Get j neighbor index, and coordinate index */
170             jnrA             = jjnr[jidx];
171             jnrB             = jjnr[jidx+1];
172             j_coord_offsetA  = DIM*jnrA;
173             j_coord_offsetB  = DIM*jnrB;
174
175             /* load j atom coordinates */
176             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
177                                               &jx0,&jy0,&jz0);
178
179             /* Calculate displacement vector */
180             dx00             = _fjsp_sub_v2r8(ix0,jx0);
181             dy00             = _fjsp_sub_v2r8(iy0,jy0);
182             dz00             = _fjsp_sub_v2r8(iz0,jz0);
183
184             /* Calculate squared distance and things based on it */
185             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
186
187             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
188
189             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
190
191             /* Load parameters for j particles */
192             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
193             vdwjidx0A        = 2*vdwtype[jnrA+0];
194             vdwjidx0B        = 2*vdwtype[jnrB+0];
195
196             /**************************
197              * CALCULATE INTERACTIONS *
198              **************************/
199
200             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
201             {
202
203             /* Compute parameters for interactions between i and j atoms */
204             qq00             = _fjsp_mul_v2r8(iq0,jq0);
205             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
206                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
207
208             /* REACTION-FIELD ELECTROSTATICS */
209             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
210             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
211
212             /* LENNARD-JONES DISPERSION/REPULSION */
213
214             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
215             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
216             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
217             vvdw             = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
218                                            _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
219             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
220
221             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
222
223             /* Update potential sum for this i atom from the interaction with this j atom. */
224             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
225             velecsum         = _fjsp_add_v2r8(velecsum,velec);
226             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
227             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
228
229             fscal            = _fjsp_add_v2r8(felec,fvdw);
230
231             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
232
233             /* Update vectorial force */
234             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
235             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
236             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
237             
238             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
239
240             }
241
242             /* Inner loop uses 57 flops */
243         }
244
245         if(jidx<j_index_end)
246         {
247
248             jnrA             = jjnr[jidx];
249             j_coord_offsetA  = DIM*jnrA;
250
251             /* load j atom coordinates */
252             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
253                                               &jx0,&jy0,&jz0);
254
255             /* Calculate displacement vector */
256             dx00             = _fjsp_sub_v2r8(ix0,jx0);
257             dy00             = _fjsp_sub_v2r8(iy0,jy0);
258             dz00             = _fjsp_sub_v2r8(iz0,jz0);
259
260             /* Calculate squared distance and things based on it */
261             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
262
263             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
264
265             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
266
267             /* Load parameters for j particles */
268             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
269             vdwjidx0A        = 2*vdwtype[jnrA+0];
270
271             /**************************
272              * CALCULATE INTERACTIONS *
273              **************************/
274
275             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
276             {
277
278             /* Compute parameters for interactions between i and j atoms */
279             qq00             = _fjsp_mul_v2r8(iq0,jq0);
280             gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
281
282             /* REACTION-FIELD ELECTROSTATICS */
283             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
284             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
285
286             /* LENNARD-JONES DISPERSION/REPULSION */
287
288             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
289             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
290             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
291             vvdw             = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
292                                            _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
293             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
294
295             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
296
297             /* Update potential sum for this i atom from the interaction with this j atom. */
298             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
299             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
300             velecsum         = _fjsp_add_v2r8(velecsum,velec);
301             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
302             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
303             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
304
305             fscal            = _fjsp_add_v2r8(felec,fvdw);
306
307             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
308
309             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
310
311             /* Update vectorial force */
312             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
313             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
314             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
315             
316             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
317
318             }
319
320             /* Inner loop uses 57 flops */
321         }
322
323         /* End of innermost loop */
324
325         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
326                                               f+i_coord_offset,fshift+i_shift_offset);
327
328         ggid                        = gid[iidx];
329         /* Update potential energies */
330         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
331         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
332
333         /* Increment number of inner iterations */
334         inneriter                  += j_index_end - j_index_start;
335
336         /* Outer loop uses 9 flops */
337     }
338
339     /* Increment number of outer iterations */
340     outeriter        += nri;
341
342     /* Update outer/inner flops */
343
344     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*57);
345 }
346 /*
347  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_F_sparc64_hpc_ace_double
348  * Electrostatics interaction: ReactionField
349  * VdW interaction:            LennardJones
350  * Geometry:                   Particle-Particle
351  * Calculate force/pot:        Force
352  */
353 void
354 nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_F_sparc64_hpc_ace_double
355                     (t_nblist                    * gmx_restrict       nlist,
356                      rvec                        * gmx_restrict          xx,
357                      rvec                        * gmx_restrict          ff,
358                      t_forcerec                  * gmx_restrict          fr,
359                      t_mdatoms                   * gmx_restrict     mdatoms,
360                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
361                      t_nrnb                      * gmx_restrict        nrnb)
362 {
363     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
364      * just 0 for non-waters.
365      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
366      * jnr indices corresponding to data put in the four positions in the SIMD register.
367      */
368     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
369     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
370     int              jnrA,jnrB;
371     int              j_coord_offsetA,j_coord_offsetB;
372     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
373     real             rcutoff_scalar;
374     real             *shiftvec,*fshift,*x,*f;
375     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
376     int              vdwioffset0;
377     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
378     int              vdwjidx0A,vdwjidx0B;
379     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
380     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
381     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
382     real             *charge;
383     int              nvdwtype;
384     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
385     int              *vdwtype;
386     real             *vdwparam;
387     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
388     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
389     _fjsp_v2r8       itab_tmp;
390     _fjsp_v2r8       dummy_mask,cutoff_mask;
391     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
392     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
393     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
394
395     x                = xx[0];
396     f                = ff[0];
397
398     nri              = nlist->nri;
399     iinr             = nlist->iinr;
400     jindex           = nlist->jindex;
401     jjnr             = nlist->jjnr;
402     shiftidx         = nlist->shift;
403     gid              = nlist->gid;
404     shiftvec         = fr->shift_vec[0];
405     fshift           = fr->fshift[0];
406     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
407     charge           = mdatoms->chargeA;
408     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
409     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
410     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
411     nvdwtype         = fr->ntype;
412     vdwparam         = fr->nbfp;
413     vdwtype          = mdatoms->typeA;
414
415     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
416     rcutoff_scalar   = fr->rcoulomb;
417     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
418     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
419
420     sh_vdw_invrcut6  = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
421     rvdw             = gmx_fjsp_set1_v2r8(fr->rvdw);
422
423     /* Avoid stupid compiler warnings */
424     jnrA = jnrB = 0;
425     j_coord_offsetA = 0;
426     j_coord_offsetB = 0;
427
428     outeriter        = 0;
429     inneriter        = 0;
430
431     /* Start outer loop over neighborlists */
432     for(iidx=0; iidx<nri; iidx++)
433     {
434         /* Load shift vector for this list */
435         i_shift_offset   = DIM*shiftidx[iidx];
436
437         /* Load limits for loop over neighbors */
438         j_index_start    = jindex[iidx];
439         j_index_end      = jindex[iidx+1];
440
441         /* Get outer coordinate index */
442         inr              = iinr[iidx];
443         i_coord_offset   = DIM*inr;
444
445         /* Load i particle coords and add shift vector */
446         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
447
448         fix0             = _fjsp_setzero_v2r8();
449         fiy0             = _fjsp_setzero_v2r8();
450         fiz0             = _fjsp_setzero_v2r8();
451
452         /* Load parameters for i particles */
453         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
454         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
455
456         /* Start inner kernel loop */
457         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
458         {
459
460             /* Get j neighbor index, and coordinate index */
461             jnrA             = jjnr[jidx];
462             jnrB             = jjnr[jidx+1];
463             j_coord_offsetA  = DIM*jnrA;
464             j_coord_offsetB  = DIM*jnrB;
465
466             /* load j atom coordinates */
467             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
468                                               &jx0,&jy0,&jz0);
469
470             /* Calculate displacement vector */
471             dx00             = _fjsp_sub_v2r8(ix0,jx0);
472             dy00             = _fjsp_sub_v2r8(iy0,jy0);
473             dz00             = _fjsp_sub_v2r8(iz0,jz0);
474
475             /* Calculate squared distance and things based on it */
476             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
477
478             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
479
480             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
481
482             /* Load parameters for j particles */
483             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
484             vdwjidx0A        = 2*vdwtype[jnrA+0];
485             vdwjidx0B        = 2*vdwtype[jnrB+0];
486
487             /**************************
488              * CALCULATE INTERACTIONS *
489              **************************/
490
491             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
492             {
493
494             /* Compute parameters for interactions between i and j atoms */
495             qq00             = _fjsp_mul_v2r8(iq0,jq0);
496             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
497                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
498
499             /* REACTION-FIELD ELECTROSTATICS */
500             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
501
502             /* LENNARD-JONES DISPERSION/REPULSION */
503
504             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
505             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
506
507             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
508
509             fscal            = _fjsp_add_v2r8(felec,fvdw);
510
511             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
512
513             /* Update vectorial force */
514             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
515             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
516             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
517             
518             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
519
520             }
521
522             /* Inner loop uses 40 flops */
523         }
524
525         if(jidx<j_index_end)
526         {
527
528             jnrA             = jjnr[jidx];
529             j_coord_offsetA  = DIM*jnrA;
530
531             /* load j atom coordinates */
532             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
533                                               &jx0,&jy0,&jz0);
534
535             /* Calculate displacement vector */
536             dx00             = _fjsp_sub_v2r8(ix0,jx0);
537             dy00             = _fjsp_sub_v2r8(iy0,jy0);
538             dz00             = _fjsp_sub_v2r8(iz0,jz0);
539
540             /* Calculate squared distance and things based on it */
541             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
542
543             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
544
545             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
546
547             /* Load parameters for j particles */
548             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
549             vdwjidx0A        = 2*vdwtype[jnrA+0];
550
551             /**************************
552              * CALCULATE INTERACTIONS *
553              **************************/
554
555             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
556             {
557
558             /* Compute parameters for interactions between i and j atoms */
559             qq00             = _fjsp_mul_v2r8(iq0,jq0);
560             gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
561
562             /* REACTION-FIELD ELECTROSTATICS */
563             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
564
565             /* LENNARD-JONES DISPERSION/REPULSION */
566
567             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
568             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
569
570             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
571
572             fscal            = _fjsp_add_v2r8(felec,fvdw);
573
574             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
575
576             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
577
578             /* Update vectorial force */
579             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
580             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
581             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
582             
583             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
584
585             }
586
587             /* Inner loop uses 40 flops */
588         }
589
590         /* End of innermost loop */
591
592         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
593                                               f+i_coord_offset,fshift+i_shift_offset);
594
595         /* Increment number of inner iterations */
596         inneriter                  += j_index_end - j_index_start;
597
598         /* Outer loop uses 7 flops */
599     }
600
601     /* Increment number of outer iterations */
602     outeriter        += nri;
603
604     /* Update outer/inner flops */
605
606     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*40);
607 }