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