62abc0e9a12343640ce33e09f0210f098f1447cd
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sparc64_hpc_ace_double / nb_kernel_ElecCSTab_VdwNone_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 #include "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
46
47 #include "kernelutil_sparc64_hpc_ace_double.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwNone_GeomP1P1_VF_sparc64_hpc_ace_double
51  * Electrostatics interaction: CubicSplineTable
52  * VdW interaction:            None
53  * Geometry:                   Particle-Particle
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecCSTab_VdwNone_GeomP1P1_VF_sparc64_hpc_ace_double
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      t_forcerec                  * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67      * just 0 for non-waters.
68      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
69      * jnr indices corresponding to data put in the four positions in the SIMD register.
70      */
71     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
72     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73     int              jnrA,jnrB;
74     int              j_coord_offsetA,j_coord_offsetB;
75     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
76     real             rcutoff_scalar;
77     real             *shiftvec,*fshift,*x,*f;
78     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
79     int              vdwioffset0;
80     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81     int              vdwjidx0A,vdwjidx0B;
82     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
84     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
85     real             *charge;
86     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
87     real             *vftab;
88     _fjsp_v2r8       itab_tmp;
89     _fjsp_v2r8       dummy_mask,cutoff_mask;
90     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
91     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
92     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
93
94     x                = xx[0];
95     f                = ff[0];
96
97     nri              = nlist->nri;
98     iinr             = nlist->iinr;
99     jindex           = nlist->jindex;
100     jjnr             = nlist->jjnr;
101     shiftidx         = nlist->shift;
102     gid              = nlist->gid;
103     shiftvec         = fr->shift_vec[0];
104     fshift           = fr->fshift[0];
105     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
106     charge           = mdatoms->chargeA;
107
108     vftab            = kernel_data->table_elec->data;
109     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_elec->scale);
110
111     /* Avoid stupid compiler warnings */
112     jnrA = jnrB = 0;
113     j_coord_offsetA = 0;
114     j_coord_offsetB = 0;
115
116     outeriter        = 0;
117     inneriter        = 0;
118
119     /* Start outer loop over neighborlists */
120     for(iidx=0; iidx<nri; iidx++)
121     {
122         /* Load shift vector for this list */
123         i_shift_offset   = DIM*shiftidx[iidx];
124
125         /* Load limits for loop over neighbors */
126         j_index_start    = jindex[iidx];
127         j_index_end      = jindex[iidx+1];
128
129         /* Get outer coordinate index */
130         inr              = iinr[iidx];
131         i_coord_offset   = DIM*inr;
132
133         /* Load i particle coords and add shift vector */
134         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
135
136         fix0             = _fjsp_setzero_v2r8();
137         fiy0             = _fjsp_setzero_v2r8();
138         fiz0             = _fjsp_setzero_v2r8();
139
140         /* Load parameters for i particles */
141         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
142
143         /* Reset potential sums */
144         velecsum         = _fjsp_setzero_v2r8();
145
146         /* Start inner kernel loop */
147         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
148         {
149
150             /* Get j neighbor index, and coordinate index */
151             jnrA             = jjnr[jidx];
152             jnrB             = jjnr[jidx+1];
153             j_coord_offsetA  = DIM*jnrA;
154             j_coord_offsetB  = DIM*jnrB;
155
156             /* load j atom coordinates */
157             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
158                                               &jx0,&jy0,&jz0);
159
160             /* Calculate displacement vector */
161             dx00             = _fjsp_sub_v2r8(ix0,jx0);
162             dy00             = _fjsp_sub_v2r8(iy0,jy0);
163             dz00             = _fjsp_sub_v2r8(iz0,jz0);
164
165             /* Calculate squared distance and things based on it */
166             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
167
168             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
169
170             /* Load parameters for j particles */
171             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
172
173             /**************************
174              * CALCULATE INTERACTIONS *
175              **************************/
176
177             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
178
179             /* Compute parameters for interactions between i and j atoms */
180             qq00             = _fjsp_mul_v2r8(iq0,jq0);
181
182             /* Calculate table index by multiplying r with table scale and truncate to integer */
183             rt               = _fjsp_mul_v2r8(r00,vftabscale);
184             itab_tmp         = _fjsp_dtox_v2r8(rt);
185             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
186             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
187             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
188
189             vfconv.i[0]     *= 4;
190             vfconv.i[1]     *= 4;
191
192             /* CUBIC SPLINE TABLE ELECTROSTATICS */
193             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
194             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
195             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
196             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
197             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] +2);
198             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
199             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
200             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
201             velec            = _fjsp_mul_v2r8(qq00,VV);
202             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
203             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,FF),_fjsp_mul_v2r8(vftabscale,rinv00)));
204
205             /* Update potential sum for this i atom from the interaction with this j atom. */
206             velecsum         = _fjsp_add_v2r8(velecsum,velec);
207
208             fscal            = felec;
209
210             /* Update vectorial force */
211             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
212             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
213             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
214             
215             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
216
217             /* Inner loop uses 46 flops */
218         }
219
220         if(jidx<j_index_end)
221         {
222
223             jnrA             = jjnr[jidx];
224             j_coord_offsetA  = DIM*jnrA;
225
226             /* load j atom coordinates */
227             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
228                                               &jx0,&jy0,&jz0);
229
230             /* Calculate displacement vector */
231             dx00             = _fjsp_sub_v2r8(ix0,jx0);
232             dy00             = _fjsp_sub_v2r8(iy0,jy0);
233             dz00             = _fjsp_sub_v2r8(iz0,jz0);
234
235             /* Calculate squared distance and things based on it */
236             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
237
238             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
239
240             /* Load parameters for j particles */
241             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
242
243             /**************************
244              * CALCULATE INTERACTIONS *
245              **************************/
246
247             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
248
249             /* Compute parameters for interactions between i and j atoms */
250             qq00             = _fjsp_mul_v2r8(iq0,jq0);
251
252             /* Calculate table index by multiplying r with table scale and truncate to integer */
253             rt               = _fjsp_mul_v2r8(r00,vftabscale);
254             itab_tmp         = _fjsp_dtox_v2r8(rt);
255             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
256             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
257             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
258
259             vfconv.i[0]     *= 4;
260             vfconv.i[1]     *= 4;
261
262             /* CUBIC SPLINE TABLE ELECTROSTATICS */
263             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
264             F                = _fjsp_setzero_v2r8();
265             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
266             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
267             H                = _fjsp_setzero_v2r8();
268             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
269             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
270             VV               = _fjsp_madd_v2r8(vfeps,Fp,Y);
271             velec            = _fjsp_mul_v2r8(qq00,VV);
272             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
273             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,FF),_fjsp_mul_v2r8(vftabscale,rinv00)));
274
275             /* Update potential sum for this i atom from the interaction with this j atom. */
276             velec            = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
277             velecsum         = _fjsp_add_v2r8(velecsum,velec);
278
279             fscal            = felec;
280
281             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
282
283             /* Update vectorial force */
284             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
285             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
286             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
287             
288             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
289
290             /* Inner loop uses 46 flops */
291         }
292
293         /* End of innermost loop */
294
295         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
296                                               f+i_coord_offset,fshift+i_shift_offset);
297
298         ggid                        = gid[iidx];
299         /* Update potential energies */
300         gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
301
302         /* Increment number of inner iterations */
303         inneriter                  += j_index_end - j_index_start;
304
305         /* Outer loop uses 8 flops */
306     }
307
308     /* Increment number of outer iterations */
309     outeriter        += nri;
310
311     /* Update outer/inner flops */
312
313     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*8 + inneriter*46);
314 }
315 /*
316  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwNone_GeomP1P1_F_sparc64_hpc_ace_double
317  * Electrostatics interaction: CubicSplineTable
318  * VdW interaction:            None
319  * Geometry:                   Particle-Particle
320  * Calculate force/pot:        Force
321  */
322 void
323 nb_kernel_ElecCSTab_VdwNone_GeomP1P1_F_sparc64_hpc_ace_double
324                     (t_nblist                    * gmx_restrict       nlist,
325                      rvec                        * gmx_restrict          xx,
326                      rvec                        * gmx_restrict          ff,
327                      t_forcerec                  * gmx_restrict          fr,
328                      t_mdatoms                   * gmx_restrict     mdatoms,
329                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
330                      t_nrnb                      * gmx_restrict        nrnb)
331 {
332     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
333      * just 0 for non-waters.
334      * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
335      * jnr indices corresponding to data put in the four positions in the SIMD register.
336      */
337     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
338     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
339     int              jnrA,jnrB;
340     int              j_coord_offsetA,j_coord_offsetB;
341     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
342     real             rcutoff_scalar;
343     real             *shiftvec,*fshift,*x,*f;
344     _fjsp_v2r8       tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
345     int              vdwioffset0;
346     _fjsp_v2r8       ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
347     int              vdwjidx0A,vdwjidx0B;
348     _fjsp_v2r8       jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
349     _fjsp_v2r8       dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
350     _fjsp_v2r8       velec,felec,velecsum,facel,crf,krf,krf2;
351     real             *charge;
352     _fjsp_v2r8       rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
353     real             *vftab;
354     _fjsp_v2r8       itab_tmp;
355     _fjsp_v2r8       dummy_mask,cutoff_mask;
356     _fjsp_v2r8       one     = gmx_fjsp_set1_v2r8(1.0);
357     _fjsp_v2r8       two     = gmx_fjsp_set1_v2r8(2.0);
358     union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
359
360     x                = xx[0];
361     f                = ff[0];
362
363     nri              = nlist->nri;
364     iinr             = nlist->iinr;
365     jindex           = nlist->jindex;
366     jjnr             = nlist->jjnr;
367     shiftidx         = nlist->shift;
368     gid              = nlist->gid;
369     shiftvec         = fr->shift_vec[0];
370     fshift           = fr->fshift[0];
371     facel            = gmx_fjsp_set1_v2r8(fr->epsfac);
372     charge           = mdatoms->chargeA;
373
374     vftab            = kernel_data->table_elec->data;
375     vftabscale       = gmx_fjsp_set1_v2r8(kernel_data->table_elec->scale);
376
377     /* Avoid stupid compiler warnings */
378     jnrA = jnrB = 0;
379     j_coord_offsetA = 0;
380     j_coord_offsetB = 0;
381
382     outeriter        = 0;
383     inneriter        = 0;
384
385     /* Start outer loop over neighborlists */
386     for(iidx=0; iidx<nri; iidx++)
387     {
388         /* Load shift vector for this list */
389         i_shift_offset   = DIM*shiftidx[iidx];
390
391         /* Load limits for loop over neighbors */
392         j_index_start    = jindex[iidx];
393         j_index_end      = jindex[iidx+1];
394
395         /* Get outer coordinate index */
396         inr              = iinr[iidx];
397         i_coord_offset   = DIM*inr;
398
399         /* Load i particle coords and add shift vector */
400         gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
401
402         fix0             = _fjsp_setzero_v2r8();
403         fiy0             = _fjsp_setzero_v2r8();
404         fiz0             = _fjsp_setzero_v2r8();
405
406         /* Load parameters for i particles */
407         iq0              = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
408
409         /* Start inner kernel loop */
410         for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
411         {
412
413             /* Get j neighbor index, and coordinate index */
414             jnrA             = jjnr[jidx];
415             jnrB             = jjnr[jidx+1];
416             j_coord_offsetA  = DIM*jnrA;
417             j_coord_offsetB  = DIM*jnrB;
418
419             /* load j atom coordinates */
420             gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
421                                               &jx0,&jy0,&jz0);
422
423             /* Calculate displacement vector */
424             dx00             = _fjsp_sub_v2r8(ix0,jx0);
425             dy00             = _fjsp_sub_v2r8(iy0,jy0);
426             dz00             = _fjsp_sub_v2r8(iz0,jz0);
427
428             /* Calculate squared distance and things based on it */
429             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
430
431             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
432
433             /* Load parameters for j particles */
434             jq0              = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
435
436             /**************************
437              * CALCULATE INTERACTIONS *
438              **************************/
439
440             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
441
442             /* Compute parameters for interactions between i and j atoms */
443             qq00             = _fjsp_mul_v2r8(iq0,jq0);
444
445             /* Calculate table index by multiplying r with table scale and truncate to integer */
446             rt               = _fjsp_mul_v2r8(r00,vftabscale);
447             itab_tmp         = _fjsp_dtox_v2r8(rt);
448             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
449             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
450             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
451
452             vfconv.i[0]     *= 4;
453             vfconv.i[1]     *= 4;
454
455             /* CUBIC SPLINE TABLE ELECTROSTATICS */
456             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
457             F                = _fjsp_load_v2r8( vftab + vfconv.i[1] );
458             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
459             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
460             H                = _fjsp_load_v2r8( vftab + vfconv.i[1] +2);
461             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
462             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
463             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
464             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,FF),_fjsp_mul_v2r8(vftabscale,rinv00)));
465
466             fscal            = felec;
467
468             /* Update vectorial force */
469             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
470             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
471             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
472             
473             gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
474
475             /* Inner loop uses 42 flops */
476         }
477
478         if(jidx<j_index_end)
479         {
480
481             jnrA             = jjnr[jidx];
482             j_coord_offsetA  = DIM*jnrA;
483
484             /* load j atom coordinates */
485             gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
486                                               &jx0,&jy0,&jz0);
487
488             /* Calculate displacement vector */
489             dx00             = _fjsp_sub_v2r8(ix0,jx0);
490             dy00             = _fjsp_sub_v2r8(iy0,jy0);
491             dz00             = _fjsp_sub_v2r8(iz0,jz0);
492
493             /* Calculate squared distance and things based on it */
494             rsq00            = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
495
496             rinv00           = gmx_fjsp_invsqrt_v2r8(rsq00);
497
498             /* Load parameters for j particles */
499             jq0              = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
500
501             /**************************
502              * CALCULATE INTERACTIONS *
503              **************************/
504
505             r00              = _fjsp_mul_v2r8(rsq00,rinv00);
506
507             /* Compute parameters for interactions between i and j atoms */
508             qq00             = _fjsp_mul_v2r8(iq0,jq0);
509
510             /* Calculate table index by multiplying r with table scale and truncate to integer */
511             rt               = _fjsp_mul_v2r8(r00,vftabscale);
512             itab_tmp         = _fjsp_dtox_v2r8(rt);
513             vfeps            = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
514             twovfeps         = _fjsp_add_v2r8(vfeps,vfeps);
515             _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
516
517             vfconv.i[0]     *= 4;
518             vfconv.i[1]     *= 4;
519
520             /* CUBIC SPLINE TABLE ELECTROSTATICS */
521             Y                = _fjsp_load_v2r8( vftab + vfconv.i[0] );
522             F                = _fjsp_setzero_v2r8();
523             GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
524             G                = _fjsp_load_v2r8( vftab + vfconv.i[0] +2);
525             H                = _fjsp_setzero_v2r8();
526             GMX_FJSP_TRANSPOSE2_V2R8(G,H);
527             Fp               = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(vfeps,H,G),F);
528             FF               = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twovfeps,H,G),vfeps,Fp);
529             felec            = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,FF),_fjsp_mul_v2r8(vftabscale,rinv00)));
530
531             fscal            = felec;
532
533             fscal            = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
534
535             /* Update vectorial force */
536             fix0             = _fjsp_madd_v2r8(dx00,fscal,fix0);
537             fiy0             = _fjsp_madd_v2r8(dy00,fscal,fiy0);
538             fiz0             = _fjsp_madd_v2r8(dz00,fscal,fiz0);
539             
540             gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
541
542             /* Inner loop uses 42 flops */
543         }
544
545         /* End of innermost loop */
546
547         gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
548                                               f+i_coord_offset,fshift+i_shift_offset);
549
550         /* Increment number of inner iterations */
551         inneriter                  += j_index_end - j_index_start;
552
553         /* Outer loop uses 7 flops */
554     }
555
556     /* Increment number of outer iterations */
557     outeriter        += nri;
558
559     /* Update outer/inner flops */
560
561     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*42);
562 }