Valgrind suppression for OS X 10.9
[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,2014, 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 "gromacs/legacyheaders/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_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
281                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
282
283             /* REACTION-FIELD ELECTROSTATICS */
284             velec            = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
285             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
286
287             /* LENNARD-JONES DISPERSION/REPULSION */
288
289             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
290             vvdw6            = _fjsp_mul_v2r8(c6_00,rinvsix);
291             vvdw12           = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
292             vvdw             = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
293                                            _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
294             fvdw             = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
295
296             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
297
298             /* Update potential sum for this i atom from the interaction with this j atom. */
299             velec            = _fjsp_and_v2r8(velec,cutoff_mask);
300             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
301             velecsum         = _fjsp_add_v2r8(velecsum,velec);
302             vvdw             = _fjsp_and_v2r8(vvdw,cutoff_mask);
303             vvdw             = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
304             vvdwsum          = _fjsp_add_v2r8(vvdwsum,vvdw);
305
306             fscal            = _fjsp_add_v2r8(felec,fvdw);
307
308             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
309
310             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
311
312             /* Update vectorial force */
313             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
314             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
315             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
316             
317             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
318
319             }
320
321             /* Inner loop uses 57 flops */
322         }
323
324         /* End of innermost loop */
325
326         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
327                                               f+i_coord_offset,fshift+i_shift_offset);
328
329         ggid                        = gid[iidx];
330         /* Update potential energies */
331         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
332         gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
333
334         /* Increment number of inner iterations */
335         inneriter                  += j_index_end - j_index_start;
336
337         /* Outer loop uses 9 flops */
338     }
339
340     /* Increment number of outer iterations */
341     outeriter        += nri;
342
343     /* Update outer/inner flops */
344
345     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*57);
346 }
347 /*
348  * Gromacs nonbonded kernel:   nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_F_sparc64_hpc_ace_double
349  * Electrostatics interaction: ReactionField
350  * VdW interaction:            LennardJones
351  * Geometry:                   Particle-Particle
352  * Calculate force/pot:        Force
353  */
354 void
355 nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_F_sparc64_hpc_ace_double
356                     (t_nblist                    * gmx_restrict       nlist,
357                      rvec                        * gmx_restrict          xx,
358                      rvec                        * gmx_restrict          ff,
359                      t_forcerec                  * gmx_restrict          fr,
360                      t_mdatoms                   * gmx_restrict     mdatoms,
361                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
362                      t_nrnb                      * gmx_restrict        nrnb)
363 {
364     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
365      * just 0 for non-waters.
366      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
367      * jnr indices corresponding to data put in the four positions in the SIMD register.
368      */
369     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
370     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
371     int              jnrA,jnrB;
372     int              j_coord_offsetA,j_coord_offsetB;
373     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
374     real             rcutoff_scalar;
375     real             *shiftvec,*fshift,*x,*f;
376     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
377     int              vdwioffset0;
378     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
379     int              vdwjidx0A,vdwjidx0B;
380     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
381     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
382     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
383     real             *charge;
384     int              nvdwtype;
385     _fjsp_v2r8       rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
386     int              *vdwtype;
387     real             *vdwparam;
388     _fjsp_v2r8       one_sixth   = gmx_fjsp_set1_v2r8(1.0/6.0);
389     _fjsp_v2r8       one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
390     _fjsp_v2r8       itab_tmp;
391     _fjsp_v2r8       dummy_mask,cutoff_mask;
392     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
393     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
394     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
395
396     x                = xx[0];
397     f                = ff[0];
398
399     nri              = nlist->nri;
400     iinr             = nlist->iinr;
401     jindex           = nlist->jindex;
402     jjnr             = nlist->jjnr;
403     shiftidx         = nlist->shift;
404     gid              = nlist->gid;
405     shiftvec         = fr->shift_vec[0];
406     fshift           = fr->fshift[0];
407     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
408     charge           = mdatoms->chargeA;
409     krf              = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
410     krf2             = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
411     crf              = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
412     nvdwtype         = fr->ntype;
413     vdwparam         = fr->nbfp;
414     vdwtype          = mdatoms->typeA;
415
416     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
417     rcutoff_scalar   = fr->rcoulomb;
418     rcutoff          = gmx_fjsp_set1_v2r8(rcutoff_scalar);
419     rcutoff2         = _fjsp_mul_v2r8(rcutoff,rcutoff);
420
421     sh_vdw_invrcut6  = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
422     rvdw             = gmx_fjsp_set1_v2r8(fr->rvdw);
423
424     /* Avoid stupid compiler warnings */
425     jnrA = jnrB = 0;
426     j_coord_offsetA = 0;
427     j_coord_offsetB = 0;
428
429     outeriter        = 0;
430     inneriter        = 0;
431
432     /* Start outer loop over neighborlists */
433     for(iidx=0; iidx<nri; iidx++)
434     {
435         /* Load shift vector for this list */
436         i_shift_offset   = DIM*shiftidx[iidx];
437
438         /* Load limits for loop over neighbors */
439         j_index_start    = jindex[iidx];
440         j_index_end      = jindex[iidx+1];
441
442         /* Get outer coordinate index */
443         inr              = iinr[iidx];
444         i_coord_offset   = DIM*inr;
445
446         /* Load i particle coords and add shift vector */
447         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
448
449         fix0             = _fjsp_setzero_v2r8();
450         fiy0             = _fjsp_setzero_v2r8();
451         fiz0             = _fjsp_setzero_v2r8();
452
453         /* Load parameters for i particles */
454         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
455         vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
456
457         /* Start inner kernel loop */
458         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
459         {
460
461             /* Get j neighbor index, and coordinate index */
462             jnrA             = jjnr[jidx];
463             jnrB             = jjnr[jidx+1];
464             j_coord_offsetA  = DIM*jnrA;
465             j_coord_offsetB  = DIM*jnrB;
466
467             /* load j atom coordinates */
468             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
469                                               &jx0,&jy0,&jz0);
470
471             /* Calculate displacement vector */
472             dx00             = _fjsp_sub_v2r8(ix0,jx0);
473             dy00             = _fjsp_sub_v2r8(iy0,jy0);
474             dz00             = _fjsp_sub_v2r8(iz0,jz0);
475
476             /* Calculate squared distance and things based on it */
477             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
478
479             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
480
481             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
482
483             /* Load parameters for j particles */
484             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
485             vdwjidx0A        = 2*vdwtype[jnrA+0];
486             vdwjidx0B        = 2*vdwtype[jnrB+0];
487
488             /**************************
489              * CALCULATE INTERACTIONS *
490              **************************/
491
492             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
493             {
494
495             /* Compute parameters for interactions between i and j atoms */
496             qq00             = _fjsp_mul_v2r8(iq0,jq0);
497             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
498                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
499
500             /* REACTION-FIELD ELECTROSTATICS */
501             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
502
503             /* LENNARD-JONES DISPERSION/REPULSION */
504
505             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
506             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
507
508             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
509
510             fscal            = _fjsp_add_v2r8(felec,fvdw);
511
512             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
513
514             /* Update vectorial force */
515             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
516             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
517             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
518             
519             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
520
521             }
522
523             /* Inner loop uses 40 flops */
524         }
525
526         if(jidx<j_index_end)
527         {
528
529             jnrA             = jjnr[jidx];
530             j_coord_offsetA  = DIM*jnrA;
531
532             /* load j atom coordinates */
533             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
534                                               &jx0,&jy0,&jz0);
535
536             /* Calculate displacement vector */
537             dx00             = _fjsp_sub_v2r8(ix0,jx0);
538             dy00             = _fjsp_sub_v2r8(iy0,jy0);
539             dz00             = _fjsp_sub_v2r8(iz0,jz0);
540
541             /* Calculate squared distance and things based on it */
542             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
543
544             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
545
546             rinvsq00         = _fjsp_mul_v2r8(rinv00,rinv00);
547
548             /* Load parameters for j particles */
549             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
550             vdwjidx0A        = 2*vdwtype[jnrA+0];
551
552             /**************************
553              * CALCULATE INTERACTIONS *
554              **************************/
555
556             if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
557             {
558
559             /* Compute parameters for interactions between i and j atoms */
560             qq00             = _fjsp_mul_v2r8(iq0,jq0);
561             gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
562                                          vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
563
564             /* REACTION-FIELD ELECTROSTATICS */
565             felec            = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
566
567             /* LENNARD-JONES DISPERSION/REPULSION */
568
569             rinvsix          = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
570             fvdw             = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
571
572             cutoff_mask      = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
573
574             fscal            = _fjsp_add_v2r8(felec,fvdw);
575
576             fscal            = _fjsp_and_v2r8(fscal,cutoff_mask);
577
578             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
579
580             /* Update vectorial force */
581             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
582             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
583             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
584             
585             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
586
587             }
588
589             /* Inner loop uses 40 flops */
590         }
591
592         /* End of innermost loop */
593
594         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
595                                               f+i_coord_offset,fshift+i_shift_offset);
596
597         /* Increment number of inner iterations */
598         inneriter                  += j_index_end - j_index_start;
599
600         /* Outer loop uses 7 flops */
601     }
602
603     /* Increment number of outer iterations */
604     outeriter        += nri;
605
606     /* Update outer/inner flops */
607
608     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*40);
609 }