2 * This file is part of the GROMACS molecular simulation package.
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.
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 sse4_1_double kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_sse4_1_double.h"
48 #include "kernelutil_x86_sse4_1_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_VF_sse4_1_double
52 * Electrostatics interaction: Coulomb
53 * VdW interaction: CubicSplineTable
54 * Geometry: Water4-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_VF_sse4_1_double
59 (t_nblist * gmx_restrict nlist,
60 rvec * gmx_restrict xx,
61 rvec * gmx_restrict ff,
62 t_forcerec * gmx_restrict fr,
63 t_mdatoms * gmx_restrict mdatoms,
64 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65 t_nrnb * gmx_restrict nrnb)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
70 * jnr indices corresponding to data put in the four positions in the SIMD register.
72 int i_shift_offset,i_coord_offset,outeriter,inneriter;
73 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75 int j_coord_offsetA,j_coord_offsetB;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
83 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
85 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
87 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
88 int vdwjidx0A,vdwjidx0B;
89 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
90 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
91 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
92 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
93 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
94 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
97 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
100 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
101 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
103 __m128i ifour = _mm_set1_epi32(4);
104 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
106 __m128d dummy_mask,cutoff_mask;
107 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
108 __m128d one = _mm_set1_pd(1.0);
109 __m128d two = _mm_set1_pd(2.0);
115 jindex = nlist->jindex;
117 shiftidx = nlist->shift;
119 shiftvec = fr->shift_vec[0];
120 fshift = fr->fshift[0];
121 facel = _mm_set1_pd(fr->epsfac);
122 charge = mdatoms->chargeA;
123 nvdwtype = fr->ntype;
125 vdwtype = mdatoms->typeA;
127 vftab = kernel_data->table_vdw->data;
128 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
130 /* Setup water-specific parameters */
131 inr = nlist->iinr[0];
132 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
133 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
134 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
135 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
137 /* Avoid stupid compiler warnings */
145 /* Start outer loop over neighborlists */
146 for(iidx=0; iidx<nri; iidx++)
148 /* Load shift vector for this list */
149 i_shift_offset = DIM*shiftidx[iidx];
151 /* Load limits for loop over neighbors */
152 j_index_start = jindex[iidx];
153 j_index_end = jindex[iidx+1];
155 /* Get outer coordinate index */
157 i_coord_offset = DIM*inr;
159 /* Load i particle coords and add shift vector */
160 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
161 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
163 fix0 = _mm_setzero_pd();
164 fiy0 = _mm_setzero_pd();
165 fiz0 = _mm_setzero_pd();
166 fix1 = _mm_setzero_pd();
167 fiy1 = _mm_setzero_pd();
168 fiz1 = _mm_setzero_pd();
169 fix2 = _mm_setzero_pd();
170 fiy2 = _mm_setzero_pd();
171 fiz2 = _mm_setzero_pd();
172 fix3 = _mm_setzero_pd();
173 fiy3 = _mm_setzero_pd();
174 fiz3 = _mm_setzero_pd();
176 /* Reset potential sums */
177 velecsum = _mm_setzero_pd();
178 vvdwsum = _mm_setzero_pd();
180 /* Start inner kernel loop */
181 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
184 /* Get j neighbor index, and coordinate index */
187 j_coord_offsetA = DIM*jnrA;
188 j_coord_offsetB = DIM*jnrB;
190 /* load j atom coordinates */
191 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
194 /* Calculate displacement vector */
195 dx00 = _mm_sub_pd(ix0,jx0);
196 dy00 = _mm_sub_pd(iy0,jy0);
197 dz00 = _mm_sub_pd(iz0,jz0);
198 dx10 = _mm_sub_pd(ix1,jx0);
199 dy10 = _mm_sub_pd(iy1,jy0);
200 dz10 = _mm_sub_pd(iz1,jz0);
201 dx20 = _mm_sub_pd(ix2,jx0);
202 dy20 = _mm_sub_pd(iy2,jy0);
203 dz20 = _mm_sub_pd(iz2,jz0);
204 dx30 = _mm_sub_pd(ix3,jx0);
205 dy30 = _mm_sub_pd(iy3,jy0);
206 dz30 = _mm_sub_pd(iz3,jz0);
208 /* Calculate squared distance and things based on it */
209 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
210 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
211 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
212 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
214 rinv00 = gmx_mm_invsqrt_pd(rsq00);
215 rinv10 = gmx_mm_invsqrt_pd(rsq10);
216 rinv20 = gmx_mm_invsqrt_pd(rsq20);
217 rinv30 = gmx_mm_invsqrt_pd(rsq30);
219 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
220 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
221 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
223 /* Load parameters for j particles */
224 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
225 vdwjidx0A = 2*vdwtype[jnrA+0];
226 vdwjidx0B = 2*vdwtype[jnrB+0];
228 fjx0 = _mm_setzero_pd();
229 fjy0 = _mm_setzero_pd();
230 fjz0 = _mm_setzero_pd();
232 /**************************
233 * CALCULATE INTERACTIONS *
234 **************************/
236 r00 = _mm_mul_pd(rsq00,rinv00);
238 /* Compute parameters for interactions between i and j atoms */
239 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
240 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
242 /* Calculate table index by multiplying r with table scale and truncate to integer */
243 rt = _mm_mul_pd(r00,vftabscale);
244 vfitab = _mm_cvttpd_epi32(rt);
245 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
246 vfitab = _mm_slli_epi32(vfitab,3);
248 /* CUBIC SPLINE TABLE DISPERSION */
249 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
250 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
251 GMX_MM_TRANSPOSE2_PD(Y,F);
252 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
253 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
254 GMX_MM_TRANSPOSE2_PD(G,H);
255 Heps = _mm_mul_pd(vfeps,H);
256 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
257 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
258 vvdw6 = _mm_mul_pd(c6_00,VV);
259 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
260 fvdw6 = _mm_mul_pd(c6_00,FF);
262 /* CUBIC SPLINE TABLE REPULSION */
263 vfitab = _mm_add_epi32(vfitab,ifour);
264 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
265 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
266 GMX_MM_TRANSPOSE2_PD(Y,F);
267 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
268 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
269 GMX_MM_TRANSPOSE2_PD(G,H);
270 Heps = _mm_mul_pd(vfeps,H);
271 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
272 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
273 vvdw12 = _mm_mul_pd(c12_00,VV);
274 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
275 fvdw12 = _mm_mul_pd(c12_00,FF);
276 vvdw = _mm_add_pd(vvdw12,vvdw6);
277 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
279 /* Update potential sum for this i atom from the interaction with this j atom. */
280 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
284 /* Calculate temporary vectorial force */
285 tx = _mm_mul_pd(fscal,dx00);
286 ty = _mm_mul_pd(fscal,dy00);
287 tz = _mm_mul_pd(fscal,dz00);
289 /* Update vectorial force */
290 fix0 = _mm_add_pd(fix0,tx);
291 fiy0 = _mm_add_pd(fiy0,ty);
292 fiz0 = _mm_add_pd(fiz0,tz);
294 fjx0 = _mm_add_pd(fjx0,tx);
295 fjy0 = _mm_add_pd(fjy0,ty);
296 fjz0 = _mm_add_pd(fjz0,tz);
298 /**************************
299 * CALCULATE INTERACTIONS *
300 **************************/
302 /* Compute parameters for interactions between i and j atoms */
303 qq10 = _mm_mul_pd(iq1,jq0);
305 /* COULOMB ELECTROSTATICS */
306 velec = _mm_mul_pd(qq10,rinv10);
307 felec = _mm_mul_pd(velec,rinvsq10);
309 /* Update potential sum for this i atom from the interaction with this j atom. */
310 velecsum = _mm_add_pd(velecsum,velec);
314 /* Calculate temporary vectorial force */
315 tx = _mm_mul_pd(fscal,dx10);
316 ty = _mm_mul_pd(fscal,dy10);
317 tz = _mm_mul_pd(fscal,dz10);
319 /* Update vectorial force */
320 fix1 = _mm_add_pd(fix1,tx);
321 fiy1 = _mm_add_pd(fiy1,ty);
322 fiz1 = _mm_add_pd(fiz1,tz);
324 fjx0 = _mm_add_pd(fjx0,tx);
325 fjy0 = _mm_add_pd(fjy0,ty);
326 fjz0 = _mm_add_pd(fjz0,tz);
328 /**************************
329 * CALCULATE INTERACTIONS *
330 **************************/
332 /* Compute parameters for interactions between i and j atoms */
333 qq20 = _mm_mul_pd(iq2,jq0);
335 /* COULOMB ELECTROSTATICS */
336 velec = _mm_mul_pd(qq20,rinv20);
337 felec = _mm_mul_pd(velec,rinvsq20);
339 /* Update potential sum for this i atom from the interaction with this j atom. */
340 velecsum = _mm_add_pd(velecsum,velec);
344 /* Calculate temporary vectorial force */
345 tx = _mm_mul_pd(fscal,dx20);
346 ty = _mm_mul_pd(fscal,dy20);
347 tz = _mm_mul_pd(fscal,dz20);
349 /* Update vectorial force */
350 fix2 = _mm_add_pd(fix2,tx);
351 fiy2 = _mm_add_pd(fiy2,ty);
352 fiz2 = _mm_add_pd(fiz2,tz);
354 fjx0 = _mm_add_pd(fjx0,tx);
355 fjy0 = _mm_add_pd(fjy0,ty);
356 fjz0 = _mm_add_pd(fjz0,tz);
358 /**************************
359 * CALCULATE INTERACTIONS *
360 **************************/
362 /* Compute parameters for interactions between i and j atoms */
363 qq30 = _mm_mul_pd(iq3,jq0);
365 /* COULOMB ELECTROSTATICS */
366 velec = _mm_mul_pd(qq30,rinv30);
367 felec = _mm_mul_pd(velec,rinvsq30);
369 /* Update potential sum for this i atom from the interaction with this j atom. */
370 velecsum = _mm_add_pd(velecsum,velec);
374 /* Calculate temporary vectorial force */
375 tx = _mm_mul_pd(fscal,dx30);
376 ty = _mm_mul_pd(fscal,dy30);
377 tz = _mm_mul_pd(fscal,dz30);
379 /* Update vectorial force */
380 fix3 = _mm_add_pd(fix3,tx);
381 fiy3 = _mm_add_pd(fiy3,ty);
382 fiz3 = _mm_add_pd(fiz3,tz);
384 fjx0 = _mm_add_pd(fjx0,tx);
385 fjy0 = _mm_add_pd(fjy0,ty);
386 fjz0 = _mm_add_pd(fjz0,tz);
388 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
390 /* Inner loop uses 143 flops */
397 j_coord_offsetA = DIM*jnrA;
399 /* load j atom coordinates */
400 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
403 /* Calculate displacement vector */
404 dx00 = _mm_sub_pd(ix0,jx0);
405 dy00 = _mm_sub_pd(iy0,jy0);
406 dz00 = _mm_sub_pd(iz0,jz0);
407 dx10 = _mm_sub_pd(ix1,jx0);
408 dy10 = _mm_sub_pd(iy1,jy0);
409 dz10 = _mm_sub_pd(iz1,jz0);
410 dx20 = _mm_sub_pd(ix2,jx0);
411 dy20 = _mm_sub_pd(iy2,jy0);
412 dz20 = _mm_sub_pd(iz2,jz0);
413 dx30 = _mm_sub_pd(ix3,jx0);
414 dy30 = _mm_sub_pd(iy3,jy0);
415 dz30 = _mm_sub_pd(iz3,jz0);
417 /* Calculate squared distance and things based on it */
418 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
419 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
420 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
421 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
423 rinv00 = gmx_mm_invsqrt_pd(rsq00);
424 rinv10 = gmx_mm_invsqrt_pd(rsq10);
425 rinv20 = gmx_mm_invsqrt_pd(rsq20);
426 rinv30 = gmx_mm_invsqrt_pd(rsq30);
428 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
429 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
430 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
432 /* Load parameters for j particles */
433 jq0 = _mm_load_sd(charge+jnrA+0);
434 vdwjidx0A = 2*vdwtype[jnrA+0];
436 fjx0 = _mm_setzero_pd();
437 fjy0 = _mm_setzero_pd();
438 fjz0 = _mm_setzero_pd();
440 /**************************
441 * CALCULATE INTERACTIONS *
442 **************************/
444 r00 = _mm_mul_pd(rsq00,rinv00);
446 /* Compute parameters for interactions between i and j atoms */
447 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
449 /* Calculate table index by multiplying r with table scale and truncate to integer */
450 rt = _mm_mul_pd(r00,vftabscale);
451 vfitab = _mm_cvttpd_epi32(rt);
452 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
453 vfitab = _mm_slli_epi32(vfitab,3);
455 /* CUBIC SPLINE TABLE DISPERSION */
456 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
457 F = _mm_setzero_pd();
458 GMX_MM_TRANSPOSE2_PD(Y,F);
459 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
460 H = _mm_setzero_pd();
461 GMX_MM_TRANSPOSE2_PD(G,H);
462 Heps = _mm_mul_pd(vfeps,H);
463 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
464 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
465 vvdw6 = _mm_mul_pd(c6_00,VV);
466 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
467 fvdw6 = _mm_mul_pd(c6_00,FF);
469 /* CUBIC SPLINE TABLE REPULSION */
470 vfitab = _mm_add_epi32(vfitab,ifour);
471 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
472 F = _mm_setzero_pd();
473 GMX_MM_TRANSPOSE2_PD(Y,F);
474 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
475 H = _mm_setzero_pd();
476 GMX_MM_TRANSPOSE2_PD(G,H);
477 Heps = _mm_mul_pd(vfeps,H);
478 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
479 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
480 vvdw12 = _mm_mul_pd(c12_00,VV);
481 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
482 fvdw12 = _mm_mul_pd(c12_00,FF);
483 vvdw = _mm_add_pd(vvdw12,vvdw6);
484 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
486 /* Update potential sum for this i atom from the interaction with this j atom. */
487 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
488 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
492 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
494 /* Calculate temporary vectorial force */
495 tx = _mm_mul_pd(fscal,dx00);
496 ty = _mm_mul_pd(fscal,dy00);
497 tz = _mm_mul_pd(fscal,dz00);
499 /* Update vectorial force */
500 fix0 = _mm_add_pd(fix0,tx);
501 fiy0 = _mm_add_pd(fiy0,ty);
502 fiz0 = _mm_add_pd(fiz0,tz);
504 fjx0 = _mm_add_pd(fjx0,tx);
505 fjy0 = _mm_add_pd(fjy0,ty);
506 fjz0 = _mm_add_pd(fjz0,tz);
508 /**************************
509 * CALCULATE INTERACTIONS *
510 **************************/
512 /* Compute parameters for interactions between i and j atoms */
513 qq10 = _mm_mul_pd(iq1,jq0);
515 /* COULOMB ELECTROSTATICS */
516 velec = _mm_mul_pd(qq10,rinv10);
517 felec = _mm_mul_pd(velec,rinvsq10);
519 /* Update potential sum for this i atom from the interaction with this j atom. */
520 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
521 velecsum = _mm_add_pd(velecsum,velec);
525 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
527 /* Calculate temporary vectorial force */
528 tx = _mm_mul_pd(fscal,dx10);
529 ty = _mm_mul_pd(fscal,dy10);
530 tz = _mm_mul_pd(fscal,dz10);
532 /* Update vectorial force */
533 fix1 = _mm_add_pd(fix1,tx);
534 fiy1 = _mm_add_pd(fiy1,ty);
535 fiz1 = _mm_add_pd(fiz1,tz);
537 fjx0 = _mm_add_pd(fjx0,tx);
538 fjy0 = _mm_add_pd(fjy0,ty);
539 fjz0 = _mm_add_pd(fjz0,tz);
541 /**************************
542 * CALCULATE INTERACTIONS *
543 **************************/
545 /* Compute parameters for interactions between i and j atoms */
546 qq20 = _mm_mul_pd(iq2,jq0);
548 /* COULOMB ELECTROSTATICS */
549 velec = _mm_mul_pd(qq20,rinv20);
550 felec = _mm_mul_pd(velec,rinvsq20);
552 /* Update potential sum for this i atom from the interaction with this j atom. */
553 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
554 velecsum = _mm_add_pd(velecsum,velec);
558 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
560 /* Calculate temporary vectorial force */
561 tx = _mm_mul_pd(fscal,dx20);
562 ty = _mm_mul_pd(fscal,dy20);
563 tz = _mm_mul_pd(fscal,dz20);
565 /* Update vectorial force */
566 fix2 = _mm_add_pd(fix2,tx);
567 fiy2 = _mm_add_pd(fiy2,ty);
568 fiz2 = _mm_add_pd(fiz2,tz);
570 fjx0 = _mm_add_pd(fjx0,tx);
571 fjy0 = _mm_add_pd(fjy0,ty);
572 fjz0 = _mm_add_pd(fjz0,tz);
574 /**************************
575 * CALCULATE INTERACTIONS *
576 **************************/
578 /* Compute parameters for interactions between i and j atoms */
579 qq30 = _mm_mul_pd(iq3,jq0);
581 /* COULOMB ELECTROSTATICS */
582 velec = _mm_mul_pd(qq30,rinv30);
583 felec = _mm_mul_pd(velec,rinvsq30);
585 /* Update potential sum for this i atom from the interaction with this j atom. */
586 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
587 velecsum = _mm_add_pd(velecsum,velec);
591 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
593 /* Calculate temporary vectorial force */
594 tx = _mm_mul_pd(fscal,dx30);
595 ty = _mm_mul_pd(fscal,dy30);
596 tz = _mm_mul_pd(fscal,dz30);
598 /* Update vectorial force */
599 fix3 = _mm_add_pd(fix3,tx);
600 fiy3 = _mm_add_pd(fiy3,ty);
601 fiz3 = _mm_add_pd(fiz3,tz);
603 fjx0 = _mm_add_pd(fjx0,tx);
604 fjy0 = _mm_add_pd(fjy0,ty);
605 fjz0 = _mm_add_pd(fjz0,tz);
607 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
609 /* Inner loop uses 143 flops */
612 /* End of innermost loop */
614 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
615 f+i_coord_offset,fshift+i_shift_offset);
618 /* Update potential energies */
619 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
620 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
622 /* Increment number of inner iterations */
623 inneriter += j_index_end - j_index_start;
625 /* Outer loop uses 26 flops */
628 /* Increment number of outer iterations */
631 /* Update outer/inner flops */
633 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*143);
636 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_sse4_1_double
637 * Electrostatics interaction: Coulomb
638 * VdW interaction: CubicSplineTable
639 * Geometry: Water4-Particle
640 * Calculate force/pot: Force
643 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_sse4_1_double
644 (t_nblist * gmx_restrict nlist,
645 rvec * gmx_restrict xx,
646 rvec * gmx_restrict ff,
647 t_forcerec * gmx_restrict fr,
648 t_mdatoms * gmx_restrict mdatoms,
649 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
650 t_nrnb * gmx_restrict nrnb)
652 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
653 * just 0 for non-waters.
654 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
655 * jnr indices corresponding to data put in the four positions in the SIMD register.
657 int i_shift_offset,i_coord_offset,outeriter,inneriter;
658 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
660 int j_coord_offsetA,j_coord_offsetB;
661 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
663 real *shiftvec,*fshift,*x,*f;
664 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
666 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
668 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
670 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
672 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
673 int vdwjidx0A,vdwjidx0B;
674 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
675 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
676 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
677 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
678 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
679 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
682 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
685 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
686 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
688 __m128i ifour = _mm_set1_epi32(4);
689 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
691 __m128d dummy_mask,cutoff_mask;
692 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
693 __m128d one = _mm_set1_pd(1.0);
694 __m128d two = _mm_set1_pd(2.0);
700 jindex = nlist->jindex;
702 shiftidx = nlist->shift;
704 shiftvec = fr->shift_vec[0];
705 fshift = fr->fshift[0];
706 facel = _mm_set1_pd(fr->epsfac);
707 charge = mdatoms->chargeA;
708 nvdwtype = fr->ntype;
710 vdwtype = mdatoms->typeA;
712 vftab = kernel_data->table_vdw->data;
713 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
715 /* Setup water-specific parameters */
716 inr = nlist->iinr[0];
717 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
718 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
719 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
720 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
722 /* Avoid stupid compiler warnings */
730 /* Start outer loop over neighborlists */
731 for(iidx=0; iidx<nri; iidx++)
733 /* Load shift vector for this list */
734 i_shift_offset = DIM*shiftidx[iidx];
736 /* Load limits for loop over neighbors */
737 j_index_start = jindex[iidx];
738 j_index_end = jindex[iidx+1];
740 /* Get outer coordinate index */
742 i_coord_offset = DIM*inr;
744 /* Load i particle coords and add shift vector */
745 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
746 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
748 fix0 = _mm_setzero_pd();
749 fiy0 = _mm_setzero_pd();
750 fiz0 = _mm_setzero_pd();
751 fix1 = _mm_setzero_pd();
752 fiy1 = _mm_setzero_pd();
753 fiz1 = _mm_setzero_pd();
754 fix2 = _mm_setzero_pd();
755 fiy2 = _mm_setzero_pd();
756 fiz2 = _mm_setzero_pd();
757 fix3 = _mm_setzero_pd();
758 fiy3 = _mm_setzero_pd();
759 fiz3 = _mm_setzero_pd();
761 /* Start inner kernel loop */
762 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
765 /* Get j neighbor index, and coordinate index */
768 j_coord_offsetA = DIM*jnrA;
769 j_coord_offsetB = DIM*jnrB;
771 /* load j atom coordinates */
772 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
775 /* Calculate displacement vector */
776 dx00 = _mm_sub_pd(ix0,jx0);
777 dy00 = _mm_sub_pd(iy0,jy0);
778 dz00 = _mm_sub_pd(iz0,jz0);
779 dx10 = _mm_sub_pd(ix1,jx0);
780 dy10 = _mm_sub_pd(iy1,jy0);
781 dz10 = _mm_sub_pd(iz1,jz0);
782 dx20 = _mm_sub_pd(ix2,jx0);
783 dy20 = _mm_sub_pd(iy2,jy0);
784 dz20 = _mm_sub_pd(iz2,jz0);
785 dx30 = _mm_sub_pd(ix3,jx0);
786 dy30 = _mm_sub_pd(iy3,jy0);
787 dz30 = _mm_sub_pd(iz3,jz0);
789 /* Calculate squared distance and things based on it */
790 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
791 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
792 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
793 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
795 rinv00 = gmx_mm_invsqrt_pd(rsq00);
796 rinv10 = gmx_mm_invsqrt_pd(rsq10);
797 rinv20 = gmx_mm_invsqrt_pd(rsq20);
798 rinv30 = gmx_mm_invsqrt_pd(rsq30);
800 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
801 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
802 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
804 /* Load parameters for j particles */
805 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
806 vdwjidx0A = 2*vdwtype[jnrA+0];
807 vdwjidx0B = 2*vdwtype[jnrB+0];
809 fjx0 = _mm_setzero_pd();
810 fjy0 = _mm_setzero_pd();
811 fjz0 = _mm_setzero_pd();
813 /**************************
814 * CALCULATE INTERACTIONS *
815 **************************/
817 r00 = _mm_mul_pd(rsq00,rinv00);
819 /* Compute parameters for interactions between i and j atoms */
820 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
821 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
823 /* Calculate table index by multiplying r with table scale and truncate to integer */
824 rt = _mm_mul_pd(r00,vftabscale);
825 vfitab = _mm_cvttpd_epi32(rt);
826 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
827 vfitab = _mm_slli_epi32(vfitab,3);
829 /* CUBIC SPLINE TABLE DISPERSION */
830 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
831 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
832 GMX_MM_TRANSPOSE2_PD(Y,F);
833 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
834 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
835 GMX_MM_TRANSPOSE2_PD(G,H);
836 Heps = _mm_mul_pd(vfeps,H);
837 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
838 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
839 fvdw6 = _mm_mul_pd(c6_00,FF);
841 /* CUBIC SPLINE TABLE REPULSION */
842 vfitab = _mm_add_epi32(vfitab,ifour);
843 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
844 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
845 GMX_MM_TRANSPOSE2_PD(Y,F);
846 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
847 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
848 GMX_MM_TRANSPOSE2_PD(G,H);
849 Heps = _mm_mul_pd(vfeps,H);
850 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
851 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
852 fvdw12 = _mm_mul_pd(c12_00,FF);
853 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
857 /* Calculate temporary vectorial force */
858 tx = _mm_mul_pd(fscal,dx00);
859 ty = _mm_mul_pd(fscal,dy00);
860 tz = _mm_mul_pd(fscal,dz00);
862 /* Update vectorial force */
863 fix0 = _mm_add_pd(fix0,tx);
864 fiy0 = _mm_add_pd(fiy0,ty);
865 fiz0 = _mm_add_pd(fiz0,tz);
867 fjx0 = _mm_add_pd(fjx0,tx);
868 fjy0 = _mm_add_pd(fjy0,ty);
869 fjz0 = _mm_add_pd(fjz0,tz);
871 /**************************
872 * CALCULATE INTERACTIONS *
873 **************************/
875 /* Compute parameters for interactions between i and j atoms */
876 qq10 = _mm_mul_pd(iq1,jq0);
878 /* COULOMB ELECTROSTATICS */
879 velec = _mm_mul_pd(qq10,rinv10);
880 felec = _mm_mul_pd(velec,rinvsq10);
884 /* Calculate temporary vectorial force */
885 tx = _mm_mul_pd(fscal,dx10);
886 ty = _mm_mul_pd(fscal,dy10);
887 tz = _mm_mul_pd(fscal,dz10);
889 /* Update vectorial force */
890 fix1 = _mm_add_pd(fix1,tx);
891 fiy1 = _mm_add_pd(fiy1,ty);
892 fiz1 = _mm_add_pd(fiz1,tz);
894 fjx0 = _mm_add_pd(fjx0,tx);
895 fjy0 = _mm_add_pd(fjy0,ty);
896 fjz0 = _mm_add_pd(fjz0,tz);
898 /**************************
899 * CALCULATE INTERACTIONS *
900 **************************/
902 /* Compute parameters for interactions between i and j atoms */
903 qq20 = _mm_mul_pd(iq2,jq0);
905 /* COULOMB ELECTROSTATICS */
906 velec = _mm_mul_pd(qq20,rinv20);
907 felec = _mm_mul_pd(velec,rinvsq20);
911 /* Calculate temporary vectorial force */
912 tx = _mm_mul_pd(fscal,dx20);
913 ty = _mm_mul_pd(fscal,dy20);
914 tz = _mm_mul_pd(fscal,dz20);
916 /* Update vectorial force */
917 fix2 = _mm_add_pd(fix2,tx);
918 fiy2 = _mm_add_pd(fiy2,ty);
919 fiz2 = _mm_add_pd(fiz2,tz);
921 fjx0 = _mm_add_pd(fjx0,tx);
922 fjy0 = _mm_add_pd(fjy0,ty);
923 fjz0 = _mm_add_pd(fjz0,tz);
925 /**************************
926 * CALCULATE INTERACTIONS *
927 **************************/
929 /* Compute parameters for interactions between i and j atoms */
930 qq30 = _mm_mul_pd(iq3,jq0);
932 /* COULOMB ELECTROSTATICS */
933 velec = _mm_mul_pd(qq30,rinv30);
934 felec = _mm_mul_pd(velec,rinvsq30);
938 /* Calculate temporary vectorial force */
939 tx = _mm_mul_pd(fscal,dx30);
940 ty = _mm_mul_pd(fscal,dy30);
941 tz = _mm_mul_pd(fscal,dz30);
943 /* Update vectorial force */
944 fix3 = _mm_add_pd(fix3,tx);
945 fiy3 = _mm_add_pd(fiy3,ty);
946 fiz3 = _mm_add_pd(fiz3,tz);
948 fjx0 = _mm_add_pd(fjx0,tx);
949 fjy0 = _mm_add_pd(fjy0,ty);
950 fjz0 = _mm_add_pd(fjz0,tz);
952 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
954 /* Inner loop uses 132 flops */
961 j_coord_offsetA = DIM*jnrA;
963 /* load j atom coordinates */
964 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
967 /* Calculate displacement vector */
968 dx00 = _mm_sub_pd(ix0,jx0);
969 dy00 = _mm_sub_pd(iy0,jy0);
970 dz00 = _mm_sub_pd(iz0,jz0);
971 dx10 = _mm_sub_pd(ix1,jx0);
972 dy10 = _mm_sub_pd(iy1,jy0);
973 dz10 = _mm_sub_pd(iz1,jz0);
974 dx20 = _mm_sub_pd(ix2,jx0);
975 dy20 = _mm_sub_pd(iy2,jy0);
976 dz20 = _mm_sub_pd(iz2,jz0);
977 dx30 = _mm_sub_pd(ix3,jx0);
978 dy30 = _mm_sub_pd(iy3,jy0);
979 dz30 = _mm_sub_pd(iz3,jz0);
981 /* Calculate squared distance and things based on it */
982 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
983 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
984 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
985 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
987 rinv00 = gmx_mm_invsqrt_pd(rsq00);
988 rinv10 = gmx_mm_invsqrt_pd(rsq10);
989 rinv20 = gmx_mm_invsqrt_pd(rsq20);
990 rinv30 = gmx_mm_invsqrt_pd(rsq30);
992 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
993 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
994 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
996 /* Load parameters for j particles */
997 jq0 = _mm_load_sd(charge+jnrA+0);
998 vdwjidx0A = 2*vdwtype[jnrA+0];
1000 fjx0 = _mm_setzero_pd();
1001 fjy0 = _mm_setzero_pd();
1002 fjz0 = _mm_setzero_pd();
1004 /**************************
1005 * CALCULATE INTERACTIONS *
1006 **************************/
1008 r00 = _mm_mul_pd(rsq00,rinv00);
1010 /* Compute parameters for interactions between i and j atoms */
1011 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
1013 /* Calculate table index by multiplying r with table scale and truncate to integer */
1014 rt = _mm_mul_pd(r00,vftabscale);
1015 vfitab = _mm_cvttpd_epi32(rt);
1016 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
1017 vfitab = _mm_slli_epi32(vfitab,3);
1019 /* CUBIC SPLINE TABLE DISPERSION */
1020 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
1021 F = _mm_setzero_pd();
1022 GMX_MM_TRANSPOSE2_PD(Y,F);
1023 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
1024 H = _mm_setzero_pd();
1025 GMX_MM_TRANSPOSE2_PD(G,H);
1026 Heps = _mm_mul_pd(vfeps,H);
1027 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
1028 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
1029 fvdw6 = _mm_mul_pd(c6_00,FF);
1031 /* CUBIC SPLINE TABLE REPULSION */
1032 vfitab = _mm_add_epi32(vfitab,ifour);
1033 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
1034 F = _mm_setzero_pd();
1035 GMX_MM_TRANSPOSE2_PD(Y,F);
1036 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
1037 H = _mm_setzero_pd();
1038 GMX_MM_TRANSPOSE2_PD(G,H);
1039 Heps = _mm_mul_pd(vfeps,H);
1040 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
1041 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
1042 fvdw12 = _mm_mul_pd(c12_00,FF);
1043 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
1047 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1049 /* Calculate temporary vectorial force */
1050 tx = _mm_mul_pd(fscal,dx00);
1051 ty = _mm_mul_pd(fscal,dy00);
1052 tz = _mm_mul_pd(fscal,dz00);
1054 /* Update vectorial force */
1055 fix0 = _mm_add_pd(fix0,tx);
1056 fiy0 = _mm_add_pd(fiy0,ty);
1057 fiz0 = _mm_add_pd(fiz0,tz);
1059 fjx0 = _mm_add_pd(fjx0,tx);
1060 fjy0 = _mm_add_pd(fjy0,ty);
1061 fjz0 = _mm_add_pd(fjz0,tz);
1063 /**************************
1064 * CALCULATE INTERACTIONS *
1065 **************************/
1067 /* Compute parameters for interactions between i and j atoms */
1068 qq10 = _mm_mul_pd(iq1,jq0);
1070 /* COULOMB ELECTROSTATICS */
1071 velec = _mm_mul_pd(qq10,rinv10);
1072 felec = _mm_mul_pd(velec,rinvsq10);
1076 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1078 /* Calculate temporary vectorial force */
1079 tx = _mm_mul_pd(fscal,dx10);
1080 ty = _mm_mul_pd(fscal,dy10);
1081 tz = _mm_mul_pd(fscal,dz10);
1083 /* Update vectorial force */
1084 fix1 = _mm_add_pd(fix1,tx);
1085 fiy1 = _mm_add_pd(fiy1,ty);
1086 fiz1 = _mm_add_pd(fiz1,tz);
1088 fjx0 = _mm_add_pd(fjx0,tx);
1089 fjy0 = _mm_add_pd(fjy0,ty);
1090 fjz0 = _mm_add_pd(fjz0,tz);
1092 /**************************
1093 * CALCULATE INTERACTIONS *
1094 **************************/
1096 /* Compute parameters for interactions between i and j atoms */
1097 qq20 = _mm_mul_pd(iq2,jq0);
1099 /* COULOMB ELECTROSTATICS */
1100 velec = _mm_mul_pd(qq20,rinv20);
1101 felec = _mm_mul_pd(velec,rinvsq20);
1105 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1107 /* Calculate temporary vectorial force */
1108 tx = _mm_mul_pd(fscal,dx20);
1109 ty = _mm_mul_pd(fscal,dy20);
1110 tz = _mm_mul_pd(fscal,dz20);
1112 /* Update vectorial force */
1113 fix2 = _mm_add_pd(fix2,tx);
1114 fiy2 = _mm_add_pd(fiy2,ty);
1115 fiz2 = _mm_add_pd(fiz2,tz);
1117 fjx0 = _mm_add_pd(fjx0,tx);
1118 fjy0 = _mm_add_pd(fjy0,ty);
1119 fjz0 = _mm_add_pd(fjz0,tz);
1121 /**************************
1122 * CALCULATE INTERACTIONS *
1123 **************************/
1125 /* Compute parameters for interactions between i and j atoms */
1126 qq30 = _mm_mul_pd(iq3,jq0);
1128 /* COULOMB ELECTROSTATICS */
1129 velec = _mm_mul_pd(qq30,rinv30);
1130 felec = _mm_mul_pd(velec,rinvsq30);
1134 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1136 /* Calculate temporary vectorial force */
1137 tx = _mm_mul_pd(fscal,dx30);
1138 ty = _mm_mul_pd(fscal,dy30);
1139 tz = _mm_mul_pd(fscal,dz30);
1141 /* Update vectorial force */
1142 fix3 = _mm_add_pd(fix3,tx);
1143 fiy3 = _mm_add_pd(fiy3,ty);
1144 fiz3 = _mm_add_pd(fiz3,tz);
1146 fjx0 = _mm_add_pd(fjx0,tx);
1147 fjy0 = _mm_add_pd(fjy0,ty);
1148 fjz0 = _mm_add_pd(fjz0,tz);
1150 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1152 /* Inner loop uses 132 flops */
1155 /* End of innermost loop */
1157 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1158 f+i_coord_offset,fshift+i_shift_offset);
1160 /* Increment number of inner iterations */
1161 inneriter += j_index_end - j_index_start;
1163 /* Outer loop uses 24 flops */
1166 /* Increment number of outer iterations */
1169 /* Update outer/inner flops */
1171 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*132);