Removed simple.h from nb_kernel_sse2_XX
[gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sse2_double / nb_kernel_ElecEwSh_VdwNone_GeomW4P1_sse2_double.c
blobe83f56148fa75f12e39fd8b12aaceeb2994e678a
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015, 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.
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.
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.
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.
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.
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.
36 * Note: this file was generated by the GROMACS sse2_double kernel generator.
38 #include "gmxpre.h"
40 #include "config.h"
42 #include <math.h>
44 #include "../nb_kernel.h"
45 #include "gromacs/math/vec.h"
46 #include "gromacs/legacyheaders/nrnb.h"
48 #include "gromacs/simd/math_x86_sse2_double.h"
49 #include "kernelutil_x86_sse2_double.h"
52 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW4P1_VF_sse2_double
53 * Electrostatics interaction: Ewald
54 * VdW interaction: None
55 * Geometry: Water4-Particle
56 * Calculate force/pot: PotentialAndForce
58 void
59 nb_kernel_ElecEwSh_VdwNone_GeomW4P1_VF_sse2_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)
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 SSE double precision, e.g. for the two different
71 * jnr indices corresponding to data put in the four positions in the SIMD register.
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 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81 int vdwioffset1;
82 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
83 int vdwioffset2;
84 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
85 int vdwioffset3;
86 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
87 int vdwjidx0A,vdwjidx0B;
88 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
90 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
91 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
92 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
93 real *charge;
94 __m128i ewitab;
95 __m128d ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
96 real *ewtab;
97 __m128d dummy_mask,cutoff_mask;
98 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
99 __m128d one = _mm_set1_pd(1.0);
100 __m128d two = _mm_set1_pd(2.0);
101 x = xx[0];
102 f = ff[0];
104 nri = nlist->nri;
105 iinr = nlist->iinr;
106 jindex = nlist->jindex;
107 jjnr = nlist->jjnr;
108 shiftidx = nlist->shift;
109 gid = nlist->gid;
110 shiftvec = fr->shift_vec[0];
111 fshift = fr->fshift[0];
112 facel = _mm_set1_pd(fr->epsfac);
113 charge = mdatoms->chargeA;
115 sh_ewald = _mm_set1_pd(fr->ic->sh_ewald);
116 ewtab = fr->ic->tabq_coul_FDV0;
117 ewtabscale = _mm_set1_pd(fr->ic->tabq_scale);
118 ewtabhalfspace = _mm_set1_pd(0.5/fr->ic->tabq_scale);
120 /* Setup water-specific parameters */
121 inr = nlist->iinr[0];
122 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
123 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
124 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
126 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
127 rcutoff_scalar = fr->rcoulomb;
128 rcutoff = _mm_set1_pd(rcutoff_scalar);
129 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
131 /* Avoid stupid compiler warnings */
132 jnrA = jnrB = 0;
133 j_coord_offsetA = 0;
134 j_coord_offsetB = 0;
136 outeriter = 0;
137 inneriter = 0;
139 /* Start outer loop over neighborlists */
140 for(iidx=0; iidx<nri; iidx++)
142 /* Load shift vector for this list */
143 i_shift_offset = DIM*shiftidx[iidx];
145 /* Load limits for loop over neighbors */
146 j_index_start = jindex[iidx];
147 j_index_end = jindex[iidx+1];
149 /* Get outer coordinate index */
150 inr = iinr[iidx];
151 i_coord_offset = DIM*inr;
153 /* Load i particle coords and add shift vector */
154 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
155 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
157 fix1 = _mm_setzero_pd();
158 fiy1 = _mm_setzero_pd();
159 fiz1 = _mm_setzero_pd();
160 fix2 = _mm_setzero_pd();
161 fiy2 = _mm_setzero_pd();
162 fiz2 = _mm_setzero_pd();
163 fix3 = _mm_setzero_pd();
164 fiy3 = _mm_setzero_pd();
165 fiz3 = _mm_setzero_pd();
167 /* Reset potential sums */
168 velecsum = _mm_setzero_pd();
170 /* Start inner kernel loop */
171 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
174 /* Get j neighbor index, and coordinate index */
175 jnrA = jjnr[jidx];
176 jnrB = jjnr[jidx+1];
177 j_coord_offsetA = DIM*jnrA;
178 j_coord_offsetB = DIM*jnrB;
180 /* load j atom coordinates */
181 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
182 &jx0,&jy0,&jz0);
184 /* Calculate displacement vector */
185 dx10 = _mm_sub_pd(ix1,jx0);
186 dy10 = _mm_sub_pd(iy1,jy0);
187 dz10 = _mm_sub_pd(iz1,jz0);
188 dx20 = _mm_sub_pd(ix2,jx0);
189 dy20 = _mm_sub_pd(iy2,jy0);
190 dz20 = _mm_sub_pd(iz2,jz0);
191 dx30 = _mm_sub_pd(ix3,jx0);
192 dy30 = _mm_sub_pd(iy3,jy0);
193 dz30 = _mm_sub_pd(iz3,jz0);
195 /* Calculate squared distance and things based on it */
196 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
197 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
198 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
200 rinv10 = gmx_mm_invsqrt_pd(rsq10);
201 rinv20 = gmx_mm_invsqrt_pd(rsq20);
202 rinv30 = gmx_mm_invsqrt_pd(rsq30);
204 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
205 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
206 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
208 /* Load parameters for j particles */
209 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
211 fjx0 = _mm_setzero_pd();
212 fjy0 = _mm_setzero_pd();
213 fjz0 = _mm_setzero_pd();
215 /**************************
216 * CALCULATE INTERACTIONS *
217 **************************/
219 if (gmx_mm_any_lt(rsq10,rcutoff2))
222 r10 = _mm_mul_pd(rsq10,rinv10);
224 /* Compute parameters for interactions between i and j atoms */
225 qq10 = _mm_mul_pd(iq1,jq0);
227 /* EWALD ELECTROSTATICS */
229 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
230 ewrt = _mm_mul_pd(r10,ewtabscale);
231 ewitab = _mm_cvttpd_epi32(ewrt);
232 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
233 ewitab = _mm_slli_epi32(ewitab,2);
234 ewtabF = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
235 ewtabD = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,1) );
236 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
237 ewtabV = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
238 ewtabFn = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,1) +2);
239 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
240 felec = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
241 velec = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
242 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_sub_pd(rinv10,sh_ewald),velec));
243 felec = _mm_mul_pd(_mm_mul_pd(qq10,rinv10),_mm_sub_pd(rinvsq10,felec));
245 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
247 /* Update potential sum for this i atom from the interaction with this j atom. */
248 velec = _mm_and_pd(velec,cutoff_mask);
249 velecsum = _mm_add_pd(velecsum,velec);
251 fscal = felec;
253 fscal = _mm_and_pd(fscal,cutoff_mask);
255 /* Calculate temporary vectorial force */
256 tx = _mm_mul_pd(fscal,dx10);
257 ty = _mm_mul_pd(fscal,dy10);
258 tz = _mm_mul_pd(fscal,dz10);
260 /* Update vectorial force */
261 fix1 = _mm_add_pd(fix1,tx);
262 fiy1 = _mm_add_pd(fiy1,ty);
263 fiz1 = _mm_add_pd(fiz1,tz);
265 fjx0 = _mm_add_pd(fjx0,tx);
266 fjy0 = _mm_add_pd(fjy0,ty);
267 fjz0 = _mm_add_pd(fjz0,tz);
271 /**************************
272 * CALCULATE INTERACTIONS *
273 **************************/
275 if (gmx_mm_any_lt(rsq20,rcutoff2))
278 r20 = _mm_mul_pd(rsq20,rinv20);
280 /* Compute parameters for interactions between i and j atoms */
281 qq20 = _mm_mul_pd(iq2,jq0);
283 /* EWALD ELECTROSTATICS */
285 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
286 ewrt = _mm_mul_pd(r20,ewtabscale);
287 ewitab = _mm_cvttpd_epi32(ewrt);
288 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
289 ewitab = _mm_slli_epi32(ewitab,2);
290 ewtabF = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
291 ewtabD = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,1) );
292 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
293 ewtabV = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
294 ewtabFn = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,1) +2);
295 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
296 felec = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
297 velec = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
298 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_sub_pd(rinv20,sh_ewald),velec));
299 felec = _mm_mul_pd(_mm_mul_pd(qq20,rinv20),_mm_sub_pd(rinvsq20,felec));
301 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
303 /* Update potential sum for this i atom from the interaction with this j atom. */
304 velec = _mm_and_pd(velec,cutoff_mask);
305 velecsum = _mm_add_pd(velecsum,velec);
307 fscal = felec;
309 fscal = _mm_and_pd(fscal,cutoff_mask);
311 /* Calculate temporary vectorial force */
312 tx = _mm_mul_pd(fscal,dx20);
313 ty = _mm_mul_pd(fscal,dy20);
314 tz = _mm_mul_pd(fscal,dz20);
316 /* Update vectorial force */
317 fix2 = _mm_add_pd(fix2,tx);
318 fiy2 = _mm_add_pd(fiy2,ty);
319 fiz2 = _mm_add_pd(fiz2,tz);
321 fjx0 = _mm_add_pd(fjx0,tx);
322 fjy0 = _mm_add_pd(fjy0,ty);
323 fjz0 = _mm_add_pd(fjz0,tz);
327 /**************************
328 * CALCULATE INTERACTIONS *
329 **************************/
331 if (gmx_mm_any_lt(rsq30,rcutoff2))
334 r30 = _mm_mul_pd(rsq30,rinv30);
336 /* Compute parameters for interactions between i and j atoms */
337 qq30 = _mm_mul_pd(iq3,jq0);
339 /* EWALD ELECTROSTATICS */
341 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
342 ewrt = _mm_mul_pd(r30,ewtabscale);
343 ewitab = _mm_cvttpd_epi32(ewrt);
344 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
345 ewitab = _mm_slli_epi32(ewitab,2);
346 ewtabF = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
347 ewtabD = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,1) );
348 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
349 ewtabV = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
350 ewtabFn = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,1) +2);
351 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
352 felec = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
353 velec = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
354 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_sub_pd(rinv30,sh_ewald),velec));
355 felec = _mm_mul_pd(_mm_mul_pd(qq30,rinv30),_mm_sub_pd(rinvsq30,felec));
357 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
359 /* Update potential sum for this i atom from the interaction with this j atom. */
360 velec = _mm_and_pd(velec,cutoff_mask);
361 velecsum = _mm_add_pd(velecsum,velec);
363 fscal = felec;
365 fscal = _mm_and_pd(fscal,cutoff_mask);
367 /* Calculate temporary vectorial force */
368 tx = _mm_mul_pd(fscal,dx30);
369 ty = _mm_mul_pd(fscal,dy30);
370 tz = _mm_mul_pd(fscal,dz30);
372 /* Update vectorial force */
373 fix3 = _mm_add_pd(fix3,tx);
374 fiy3 = _mm_add_pd(fiy3,ty);
375 fiz3 = _mm_add_pd(fiz3,tz);
377 fjx0 = _mm_add_pd(fjx0,tx);
378 fjy0 = _mm_add_pd(fjy0,ty);
379 fjz0 = _mm_add_pd(fjz0,tz);
383 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
385 /* Inner loop uses 141 flops */
388 if(jidx<j_index_end)
391 jnrA = jjnr[jidx];
392 j_coord_offsetA = DIM*jnrA;
394 /* load j atom coordinates */
395 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
396 &jx0,&jy0,&jz0);
398 /* Calculate displacement vector */
399 dx10 = _mm_sub_pd(ix1,jx0);
400 dy10 = _mm_sub_pd(iy1,jy0);
401 dz10 = _mm_sub_pd(iz1,jz0);
402 dx20 = _mm_sub_pd(ix2,jx0);
403 dy20 = _mm_sub_pd(iy2,jy0);
404 dz20 = _mm_sub_pd(iz2,jz0);
405 dx30 = _mm_sub_pd(ix3,jx0);
406 dy30 = _mm_sub_pd(iy3,jy0);
407 dz30 = _mm_sub_pd(iz3,jz0);
409 /* Calculate squared distance and things based on it */
410 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
411 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
412 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
414 rinv10 = gmx_mm_invsqrt_pd(rsq10);
415 rinv20 = gmx_mm_invsqrt_pd(rsq20);
416 rinv30 = gmx_mm_invsqrt_pd(rsq30);
418 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
419 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
420 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
422 /* Load parameters for j particles */
423 jq0 = _mm_load_sd(charge+jnrA+0);
425 fjx0 = _mm_setzero_pd();
426 fjy0 = _mm_setzero_pd();
427 fjz0 = _mm_setzero_pd();
429 /**************************
430 * CALCULATE INTERACTIONS *
431 **************************/
433 if (gmx_mm_any_lt(rsq10,rcutoff2))
436 r10 = _mm_mul_pd(rsq10,rinv10);
438 /* Compute parameters for interactions between i and j atoms */
439 qq10 = _mm_mul_pd(iq1,jq0);
441 /* EWALD ELECTROSTATICS */
443 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
444 ewrt = _mm_mul_pd(r10,ewtabscale);
445 ewitab = _mm_cvttpd_epi32(ewrt);
446 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
447 ewitab = _mm_slli_epi32(ewitab,2);
448 ewtabF = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
449 ewtabD = _mm_setzero_pd();
450 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
451 ewtabV = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
452 ewtabFn = _mm_setzero_pd();
453 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
454 felec = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
455 velec = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
456 velec = _mm_mul_pd(qq10,_mm_sub_pd(_mm_sub_pd(rinv10,sh_ewald),velec));
457 felec = _mm_mul_pd(_mm_mul_pd(qq10,rinv10),_mm_sub_pd(rinvsq10,felec));
459 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
461 /* Update potential sum for this i atom from the interaction with this j atom. */
462 velec = _mm_and_pd(velec,cutoff_mask);
463 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
464 velecsum = _mm_add_pd(velecsum,velec);
466 fscal = felec;
468 fscal = _mm_and_pd(fscal,cutoff_mask);
470 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
472 /* Calculate temporary vectorial force */
473 tx = _mm_mul_pd(fscal,dx10);
474 ty = _mm_mul_pd(fscal,dy10);
475 tz = _mm_mul_pd(fscal,dz10);
477 /* Update vectorial force */
478 fix1 = _mm_add_pd(fix1,tx);
479 fiy1 = _mm_add_pd(fiy1,ty);
480 fiz1 = _mm_add_pd(fiz1,tz);
482 fjx0 = _mm_add_pd(fjx0,tx);
483 fjy0 = _mm_add_pd(fjy0,ty);
484 fjz0 = _mm_add_pd(fjz0,tz);
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
492 if (gmx_mm_any_lt(rsq20,rcutoff2))
495 r20 = _mm_mul_pd(rsq20,rinv20);
497 /* Compute parameters for interactions between i and j atoms */
498 qq20 = _mm_mul_pd(iq2,jq0);
500 /* EWALD ELECTROSTATICS */
502 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
503 ewrt = _mm_mul_pd(r20,ewtabscale);
504 ewitab = _mm_cvttpd_epi32(ewrt);
505 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
506 ewitab = _mm_slli_epi32(ewitab,2);
507 ewtabF = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
508 ewtabD = _mm_setzero_pd();
509 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
510 ewtabV = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
511 ewtabFn = _mm_setzero_pd();
512 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
513 felec = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
514 velec = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
515 velec = _mm_mul_pd(qq20,_mm_sub_pd(_mm_sub_pd(rinv20,sh_ewald),velec));
516 felec = _mm_mul_pd(_mm_mul_pd(qq20,rinv20),_mm_sub_pd(rinvsq20,felec));
518 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
520 /* Update potential sum for this i atom from the interaction with this j atom. */
521 velec = _mm_and_pd(velec,cutoff_mask);
522 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
523 velecsum = _mm_add_pd(velecsum,velec);
525 fscal = felec;
527 fscal = _mm_and_pd(fscal,cutoff_mask);
529 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
531 /* Calculate temporary vectorial force */
532 tx = _mm_mul_pd(fscal,dx20);
533 ty = _mm_mul_pd(fscal,dy20);
534 tz = _mm_mul_pd(fscal,dz20);
536 /* Update vectorial force */
537 fix2 = _mm_add_pd(fix2,tx);
538 fiy2 = _mm_add_pd(fiy2,ty);
539 fiz2 = _mm_add_pd(fiz2,tz);
541 fjx0 = _mm_add_pd(fjx0,tx);
542 fjy0 = _mm_add_pd(fjy0,ty);
543 fjz0 = _mm_add_pd(fjz0,tz);
547 /**************************
548 * CALCULATE INTERACTIONS *
549 **************************/
551 if (gmx_mm_any_lt(rsq30,rcutoff2))
554 r30 = _mm_mul_pd(rsq30,rinv30);
556 /* Compute parameters for interactions between i and j atoms */
557 qq30 = _mm_mul_pd(iq3,jq0);
559 /* EWALD ELECTROSTATICS */
561 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
562 ewrt = _mm_mul_pd(r30,ewtabscale);
563 ewitab = _mm_cvttpd_epi32(ewrt);
564 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
565 ewitab = _mm_slli_epi32(ewitab,2);
566 ewtabF = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
567 ewtabD = _mm_setzero_pd();
568 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
569 ewtabV = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
570 ewtabFn = _mm_setzero_pd();
571 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
572 felec = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
573 velec = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
574 velec = _mm_mul_pd(qq30,_mm_sub_pd(_mm_sub_pd(rinv30,sh_ewald),velec));
575 felec = _mm_mul_pd(_mm_mul_pd(qq30,rinv30),_mm_sub_pd(rinvsq30,felec));
577 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
579 /* Update potential sum for this i atom from the interaction with this j atom. */
580 velec = _mm_and_pd(velec,cutoff_mask);
581 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
582 velecsum = _mm_add_pd(velecsum,velec);
584 fscal = felec;
586 fscal = _mm_and_pd(fscal,cutoff_mask);
588 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
590 /* Calculate temporary vectorial force */
591 tx = _mm_mul_pd(fscal,dx30);
592 ty = _mm_mul_pd(fscal,dy30);
593 tz = _mm_mul_pd(fscal,dz30);
595 /* Update vectorial force */
596 fix3 = _mm_add_pd(fix3,tx);
597 fiy3 = _mm_add_pd(fiy3,ty);
598 fiz3 = _mm_add_pd(fiz3,tz);
600 fjx0 = _mm_add_pd(fjx0,tx);
601 fjy0 = _mm_add_pd(fjy0,ty);
602 fjz0 = _mm_add_pd(fjz0,tz);
606 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
608 /* Inner loop uses 141 flops */
611 /* End of innermost loop */
613 gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
614 f+i_coord_offset+DIM,fshift+i_shift_offset);
616 ggid = gid[iidx];
617 /* Update potential energies */
618 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
620 /* Increment number of inner iterations */
621 inneriter += j_index_end - j_index_start;
623 /* Outer loop uses 19 flops */
626 /* Increment number of outer iterations */
627 outeriter += nri;
629 /* Update outer/inner flops */
631 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*19 + inneriter*141);
634 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW4P1_F_sse2_double
635 * Electrostatics interaction: Ewald
636 * VdW interaction: None
637 * Geometry: Water4-Particle
638 * Calculate force/pot: Force
640 void
641 nb_kernel_ElecEwSh_VdwNone_GeomW4P1_F_sse2_double
642 (t_nblist * gmx_restrict nlist,
643 rvec * gmx_restrict xx,
644 rvec * gmx_restrict ff,
645 t_forcerec * gmx_restrict fr,
646 t_mdatoms * gmx_restrict mdatoms,
647 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
648 t_nrnb * gmx_restrict nrnb)
650 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
651 * just 0 for non-waters.
652 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
653 * jnr indices corresponding to data put in the four positions in the SIMD register.
655 int i_shift_offset,i_coord_offset,outeriter,inneriter;
656 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
657 int jnrA,jnrB;
658 int j_coord_offsetA,j_coord_offsetB;
659 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
660 real rcutoff_scalar;
661 real *shiftvec,*fshift,*x,*f;
662 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
663 int vdwioffset1;
664 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
665 int vdwioffset2;
666 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
667 int vdwioffset3;
668 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
669 int vdwjidx0A,vdwjidx0B;
670 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
671 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
672 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
673 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
674 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
675 real *charge;
676 __m128i ewitab;
677 __m128d ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
678 real *ewtab;
679 __m128d dummy_mask,cutoff_mask;
680 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
681 __m128d one = _mm_set1_pd(1.0);
682 __m128d two = _mm_set1_pd(2.0);
683 x = xx[0];
684 f = ff[0];
686 nri = nlist->nri;
687 iinr = nlist->iinr;
688 jindex = nlist->jindex;
689 jjnr = nlist->jjnr;
690 shiftidx = nlist->shift;
691 gid = nlist->gid;
692 shiftvec = fr->shift_vec[0];
693 fshift = fr->fshift[0];
694 facel = _mm_set1_pd(fr->epsfac);
695 charge = mdatoms->chargeA;
697 sh_ewald = _mm_set1_pd(fr->ic->sh_ewald);
698 ewtab = fr->ic->tabq_coul_F;
699 ewtabscale = _mm_set1_pd(fr->ic->tabq_scale);
700 ewtabhalfspace = _mm_set1_pd(0.5/fr->ic->tabq_scale);
702 /* Setup water-specific parameters */
703 inr = nlist->iinr[0];
704 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
705 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
706 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
708 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
709 rcutoff_scalar = fr->rcoulomb;
710 rcutoff = _mm_set1_pd(rcutoff_scalar);
711 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
713 /* Avoid stupid compiler warnings */
714 jnrA = jnrB = 0;
715 j_coord_offsetA = 0;
716 j_coord_offsetB = 0;
718 outeriter = 0;
719 inneriter = 0;
721 /* Start outer loop over neighborlists */
722 for(iidx=0; iidx<nri; iidx++)
724 /* Load shift vector for this list */
725 i_shift_offset = DIM*shiftidx[iidx];
727 /* Load limits for loop over neighbors */
728 j_index_start = jindex[iidx];
729 j_index_end = jindex[iidx+1];
731 /* Get outer coordinate index */
732 inr = iinr[iidx];
733 i_coord_offset = DIM*inr;
735 /* Load i particle coords and add shift vector */
736 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
737 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
739 fix1 = _mm_setzero_pd();
740 fiy1 = _mm_setzero_pd();
741 fiz1 = _mm_setzero_pd();
742 fix2 = _mm_setzero_pd();
743 fiy2 = _mm_setzero_pd();
744 fiz2 = _mm_setzero_pd();
745 fix3 = _mm_setzero_pd();
746 fiy3 = _mm_setzero_pd();
747 fiz3 = _mm_setzero_pd();
749 /* Start inner kernel loop */
750 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
753 /* Get j neighbor index, and coordinate index */
754 jnrA = jjnr[jidx];
755 jnrB = jjnr[jidx+1];
756 j_coord_offsetA = DIM*jnrA;
757 j_coord_offsetB = DIM*jnrB;
759 /* load j atom coordinates */
760 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
761 &jx0,&jy0,&jz0);
763 /* Calculate displacement vector */
764 dx10 = _mm_sub_pd(ix1,jx0);
765 dy10 = _mm_sub_pd(iy1,jy0);
766 dz10 = _mm_sub_pd(iz1,jz0);
767 dx20 = _mm_sub_pd(ix2,jx0);
768 dy20 = _mm_sub_pd(iy2,jy0);
769 dz20 = _mm_sub_pd(iz2,jz0);
770 dx30 = _mm_sub_pd(ix3,jx0);
771 dy30 = _mm_sub_pd(iy3,jy0);
772 dz30 = _mm_sub_pd(iz3,jz0);
774 /* Calculate squared distance and things based on it */
775 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
776 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
777 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
779 rinv10 = gmx_mm_invsqrt_pd(rsq10);
780 rinv20 = gmx_mm_invsqrt_pd(rsq20);
781 rinv30 = gmx_mm_invsqrt_pd(rsq30);
783 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
784 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
785 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
787 /* Load parameters for j particles */
788 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
790 fjx0 = _mm_setzero_pd();
791 fjy0 = _mm_setzero_pd();
792 fjz0 = _mm_setzero_pd();
794 /**************************
795 * CALCULATE INTERACTIONS *
796 **************************/
798 if (gmx_mm_any_lt(rsq10,rcutoff2))
801 r10 = _mm_mul_pd(rsq10,rinv10);
803 /* Compute parameters for interactions between i and j atoms */
804 qq10 = _mm_mul_pd(iq1,jq0);
806 /* EWALD ELECTROSTATICS */
808 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
809 ewrt = _mm_mul_pd(r10,ewtabscale);
810 ewitab = _mm_cvttpd_epi32(ewrt);
811 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
812 gmx_mm_load_2pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),ewtab+gmx_mm_extract_epi32(ewitab,1),
813 &ewtabF,&ewtabFn);
814 felec = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
815 felec = _mm_mul_pd(_mm_mul_pd(qq10,rinv10),_mm_sub_pd(rinvsq10,felec));
817 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
819 fscal = felec;
821 fscal = _mm_and_pd(fscal,cutoff_mask);
823 /* Calculate temporary vectorial force */
824 tx = _mm_mul_pd(fscal,dx10);
825 ty = _mm_mul_pd(fscal,dy10);
826 tz = _mm_mul_pd(fscal,dz10);
828 /* Update vectorial force */
829 fix1 = _mm_add_pd(fix1,tx);
830 fiy1 = _mm_add_pd(fiy1,ty);
831 fiz1 = _mm_add_pd(fiz1,tz);
833 fjx0 = _mm_add_pd(fjx0,tx);
834 fjy0 = _mm_add_pd(fjy0,ty);
835 fjz0 = _mm_add_pd(fjz0,tz);
839 /**************************
840 * CALCULATE INTERACTIONS *
841 **************************/
843 if (gmx_mm_any_lt(rsq20,rcutoff2))
846 r20 = _mm_mul_pd(rsq20,rinv20);
848 /* Compute parameters for interactions between i and j atoms */
849 qq20 = _mm_mul_pd(iq2,jq0);
851 /* EWALD ELECTROSTATICS */
853 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
854 ewrt = _mm_mul_pd(r20,ewtabscale);
855 ewitab = _mm_cvttpd_epi32(ewrt);
856 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
857 gmx_mm_load_2pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),ewtab+gmx_mm_extract_epi32(ewitab,1),
858 &ewtabF,&ewtabFn);
859 felec = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
860 felec = _mm_mul_pd(_mm_mul_pd(qq20,rinv20),_mm_sub_pd(rinvsq20,felec));
862 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
864 fscal = felec;
866 fscal = _mm_and_pd(fscal,cutoff_mask);
868 /* Calculate temporary vectorial force */
869 tx = _mm_mul_pd(fscal,dx20);
870 ty = _mm_mul_pd(fscal,dy20);
871 tz = _mm_mul_pd(fscal,dz20);
873 /* Update vectorial force */
874 fix2 = _mm_add_pd(fix2,tx);
875 fiy2 = _mm_add_pd(fiy2,ty);
876 fiz2 = _mm_add_pd(fiz2,tz);
878 fjx0 = _mm_add_pd(fjx0,tx);
879 fjy0 = _mm_add_pd(fjy0,ty);
880 fjz0 = _mm_add_pd(fjz0,tz);
884 /**************************
885 * CALCULATE INTERACTIONS *
886 **************************/
888 if (gmx_mm_any_lt(rsq30,rcutoff2))
891 r30 = _mm_mul_pd(rsq30,rinv30);
893 /* Compute parameters for interactions between i and j atoms */
894 qq30 = _mm_mul_pd(iq3,jq0);
896 /* EWALD ELECTROSTATICS */
898 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
899 ewrt = _mm_mul_pd(r30,ewtabscale);
900 ewitab = _mm_cvttpd_epi32(ewrt);
901 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
902 gmx_mm_load_2pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),ewtab+gmx_mm_extract_epi32(ewitab,1),
903 &ewtabF,&ewtabFn);
904 felec = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
905 felec = _mm_mul_pd(_mm_mul_pd(qq30,rinv30),_mm_sub_pd(rinvsq30,felec));
907 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
909 fscal = felec;
911 fscal = _mm_and_pd(fscal,cutoff_mask);
913 /* Calculate temporary vectorial force */
914 tx = _mm_mul_pd(fscal,dx30);
915 ty = _mm_mul_pd(fscal,dy30);
916 tz = _mm_mul_pd(fscal,dz30);
918 /* Update vectorial force */
919 fix3 = _mm_add_pd(fix3,tx);
920 fiy3 = _mm_add_pd(fiy3,ty);
921 fiz3 = _mm_add_pd(fiz3,tz);
923 fjx0 = _mm_add_pd(fjx0,tx);
924 fjy0 = _mm_add_pd(fjy0,ty);
925 fjz0 = _mm_add_pd(fjz0,tz);
929 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
931 /* Inner loop uses 120 flops */
934 if(jidx<j_index_end)
937 jnrA = jjnr[jidx];
938 j_coord_offsetA = DIM*jnrA;
940 /* load j atom coordinates */
941 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
942 &jx0,&jy0,&jz0);
944 /* Calculate displacement vector */
945 dx10 = _mm_sub_pd(ix1,jx0);
946 dy10 = _mm_sub_pd(iy1,jy0);
947 dz10 = _mm_sub_pd(iz1,jz0);
948 dx20 = _mm_sub_pd(ix2,jx0);
949 dy20 = _mm_sub_pd(iy2,jy0);
950 dz20 = _mm_sub_pd(iz2,jz0);
951 dx30 = _mm_sub_pd(ix3,jx0);
952 dy30 = _mm_sub_pd(iy3,jy0);
953 dz30 = _mm_sub_pd(iz3,jz0);
955 /* Calculate squared distance and things based on it */
956 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
957 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
958 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
960 rinv10 = gmx_mm_invsqrt_pd(rsq10);
961 rinv20 = gmx_mm_invsqrt_pd(rsq20);
962 rinv30 = gmx_mm_invsqrt_pd(rsq30);
964 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
965 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
966 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
968 /* Load parameters for j particles */
969 jq0 = _mm_load_sd(charge+jnrA+0);
971 fjx0 = _mm_setzero_pd();
972 fjy0 = _mm_setzero_pd();
973 fjz0 = _mm_setzero_pd();
975 /**************************
976 * CALCULATE INTERACTIONS *
977 **************************/
979 if (gmx_mm_any_lt(rsq10,rcutoff2))
982 r10 = _mm_mul_pd(rsq10,rinv10);
984 /* Compute parameters for interactions between i and j atoms */
985 qq10 = _mm_mul_pd(iq1,jq0);
987 /* EWALD ELECTROSTATICS */
989 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
990 ewrt = _mm_mul_pd(r10,ewtabscale);
991 ewitab = _mm_cvttpd_epi32(ewrt);
992 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
993 gmx_mm_load_1pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),&ewtabF,&ewtabFn);
994 felec = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
995 felec = _mm_mul_pd(_mm_mul_pd(qq10,rinv10),_mm_sub_pd(rinvsq10,felec));
997 cutoff_mask = _mm_cmplt_pd(rsq10,rcutoff2);
999 fscal = felec;
1001 fscal = _mm_and_pd(fscal,cutoff_mask);
1003 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1005 /* Calculate temporary vectorial force */
1006 tx = _mm_mul_pd(fscal,dx10);
1007 ty = _mm_mul_pd(fscal,dy10);
1008 tz = _mm_mul_pd(fscal,dz10);
1010 /* Update vectorial force */
1011 fix1 = _mm_add_pd(fix1,tx);
1012 fiy1 = _mm_add_pd(fiy1,ty);
1013 fiz1 = _mm_add_pd(fiz1,tz);
1015 fjx0 = _mm_add_pd(fjx0,tx);
1016 fjy0 = _mm_add_pd(fjy0,ty);
1017 fjz0 = _mm_add_pd(fjz0,tz);
1021 /**************************
1022 * CALCULATE INTERACTIONS *
1023 **************************/
1025 if (gmx_mm_any_lt(rsq20,rcutoff2))
1028 r20 = _mm_mul_pd(rsq20,rinv20);
1030 /* Compute parameters for interactions between i and j atoms */
1031 qq20 = _mm_mul_pd(iq2,jq0);
1033 /* EWALD ELECTROSTATICS */
1035 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1036 ewrt = _mm_mul_pd(r20,ewtabscale);
1037 ewitab = _mm_cvttpd_epi32(ewrt);
1038 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
1039 gmx_mm_load_1pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),&ewtabF,&ewtabFn);
1040 felec = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
1041 felec = _mm_mul_pd(_mm_mul_pd(qq20,rinv20),_mm_sub_pd(rinvsq20,felec));
1043 cutoff_mask = _mm_cmplt_pd(rsq20,rcutoff2);
1045 fscal = felec;
1047 fscal = _mm_and_pd(fscal,cutoff_mask);
1049 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1051 /* Calculate temporary vectorial force */
1052 tx = _mm_mul_pd(fscal,dx20);
1053 ty = _mm_mul_pd(fscal,dy20);
1054 tz = _mm_mul_pd(fscal,dz20);
1056 /* Update vectorial force */
1057 fix2 = _mm_add_pd(fix2,tx);
1058 fiy2 = _mm_add_pd(fiy2,ty);
1059 fiz2 = _mm_add_pd(fiz2,tz);
1061 fjx0 = _mm_add_pd(fjx0,tx);
1062 fjy0 = _mm_add_pd(fjy0,ty);
1063 fjz0 = _mm_add_pd(fjz0,tz);
1067 /**************************
1068 * CALCULATE INTERACTIONS *
1069 **************************/
1071 if (gmx_mm_any_lt(rsq30,rcutoff2))
1074 r30 = _mm_mul_pd(rsq30,rinv30);
1076 /* Compute parameters for interactions between i and j atoms */
1077 qq30 = _mm_mul_pd(iq3,jq0);
1079 /* EWALD ELECTROSTATICS */
1081 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1082 ewrt = _mm_mul_pd(r30,ewtabscale);
1083 ewitab = _mm_cvttpd_epi32(ewrt);
1084 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
1085 gmx_mm_load_1pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),&ewtabF,&ewtabFn);
1086 felec = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
1087 felec = _mm_mul_pd(_mm_mul_pd(qq30,rinv30),_mm_sub_pd(rinvsq30,felec));
1089 cutoff_mask = _mm_cmplt_pd(rsq30,rcutoff2);
1091 fscal = felec;
1093 fscal = _mm_and_pd(fscal,cutoff_mask);
1095 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1097 /* Calculate temporary vectorial force */
1098 tx = _mm_mul_pd(fscal,dx30);
1099 ty = _mm_mul_pd(fscal,dy30);
1100 tz = _mm_mul_pd(fscal,dz30);
1102 /* Update vectorial force */
1103 fix3 = _mm_add_pd(fix3,tx);
1104 fiy3 = _mm_add_pd(fiy3,ty);
1105 fiz3 = _mm_add_pd(fiz3,tz);
1107 fjx0 = _mm_add_pd(fjx0,tx);
1108 fjy0 = _mm_add_pd(fjy0,ty);
1109 fjz0 = _mm_add_pd(fjz0,tz);
1113 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1115 /* Inner loop uses 120 flops */
1118 /* End of innermost loop */
1120 gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1121 f+i_coord_offset+DIM,fshift+i_shift_offset);
1123 /* Increment number of inner iterations */
1124 inneriter += j_index_end - j_index_start;
1126 /* Outer loop uses 18 flops */
1129 /* Increment number of outer iterations */
1130 outeriter += nri;
1132 /* Update outer/inner flops */
1134 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*18 + inneriter*120);