2 * Note: this file was generated by the Gromacs sse4_1_double kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
33 #include "gmx_math_x86_sse4_1_double.h"
34 #include "kernelutil_x86_sse4_1_double.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_VF_sse4_1_double
38 * Electrostatics interaction: Coulomb
39 * VdW interaction: CubicSplineTable
40 * Geometry: Water4-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_VF_sse4_1_double
45 (t_nblist * gmx_restrict nlist,
46 rvec * gmx_restrict xx,
47 rvec * gmx_restrict ff,
48 t_forcerec * gmx_restrict fr,
49 t_mdatoms * gmx_restrict mdatoms,
50 nb_kernel_data_t * gmx_restrict kernel_data,
51 t_nrnb * gmx_restrict nrnb)
53 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
54 * just 0 for non-waters.
55 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
56 * jnr indices corresponding to data put in the four positions in the SIMD register.
58 int i_shift_offset,i_coord_offset,outeriter,inneriter;
59 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
61 int j_coord_offsetA,j_coord_offsetB;
62 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
64 real *shiftvec,*fshift,*x,*f;
65 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
67 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
69 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
71 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
73 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
74 int vdwjidx0A,vdwjidx0B;
75 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
76 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
77 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
78 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
79 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
80 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
83 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
86 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
87 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
89 __m128i ifour = _mm_set1_epi32(4);
90 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
92 __m128d dummy_mask,cutoff_mask;
93 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
94 __m128d one = _mm_set1_pd(1.0);
95 __m128d two = _mm_set1_pd(2.0);
101 jindex = nlist->jindex;
103 shiftidx = nlist->shift;
105 shiftvec = fr->shift_vec[0];
106 fshift = fr->fshift[0];
107 facel = _mm_set1_pd(fr->epsfac);
108 charge = mdatoms->chargeA;
109 nvdwtype = fr->ntype;
111 vdwtype = mdatoms->typeA;
113 vftab = kernel_data->table_vdw->data;
114 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
116 /* Setup water-specific parameters */
117 inr = nlist->iinr[0];
118 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
119 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
120 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
121 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
123 /* Avoid stupid compiler warnings */
131 /* Start outer loop over neighborlists */
132 for(iidx=0; iidx<nri; iidx++)
134 /* Load shift vector for this list */
135 i_shift_offset = DIM*shiftidx[iidx];
137 /* Load limits for loop over neighbors */
138 j_index_start = jindex[iidx];
139 j_index_end = jindex[iidx+1];
141 /* Get outer coordinate index */
143 i_coord_offset = DIM*inr;
145 /* Load i particle coords and add shift vector */
146 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
147 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
149 fix0 = _mm_setzero_pd();
150 fiy0 = _mm_setzero_pd();
151 fiz0 = _mm_setzero_pd();
152 fix1 = _mm_setzero_pd();
153 fiy1 = _mm_setzero_pd();
154 fiz1 = _mm_setzero_pd();
155 fix2 = _mm_setzero_pd();
156 fiy2 = _mm_setzero_pd();
157 fiz2 = _mm_setzero_pd();
158 fix3 = _mm_setzero_pd();
159 fiy3 = _mm_setzero_pd();
160 fiz3 = _mm_setzero_pd();
162 /* Reset potential sums */
163 velecsum = _mm_setzero_pd();
164 vvdwsum = _mm_setzero_pd();
166 /* Start inner kernel loop */
167 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
170 /* Get j neighbor index, and coordinate index */
173 j_coord_offsetA = DIM*jnrA;
174 j_coord_offsetB = DIM*jnrB;
176 /* load j atom coordinates */
177 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
180 /* Calculate displacement vector */
181 dx00 = _mm_sub_pd(ix0,jx0);
182 dy00 = _mm_sub_pd(iy0,jy0);
183 dz00 = _mm_sub_pd(iz0,jz0);
184 dx10 = _mm_sub_pd(ix1,jx0);
185 dy10 = _mm_sub_pd(iy1,jy0);
186 dz10 = _mm_sub_pd(iz1,jz0);
187 dx20 = _mm_sub_pd(ix2,jx0);
188 dy20 = _mm_sub_pd(iy2,jy0);
189 dz20 = _mm_sub_pd(iz2,jz0);
190 dx30 = _mm_sub_pd(ix3,jx0);
191 dy30 = _mm_sub_pd(iy3,jy0);
192 dz30 = _mm_sub_pd(iz3,jz0);
194 /* Calculate squared distance and things based on it */
195 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
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 rinv00 = gmx_mm_invsqrt_pd(rsq00);
201 rinv10 = gmx_mm_invsqrt_pd(rsq10);
202 rinv20 = gmx_mm_invsqrt_pd(rsq20);
203 rinv30 = gmx_mm_invsqrt_pd(rsq30);
205 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
206 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
207 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
209 /* Load parameters for j particles */
210 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
211 vdwjidx0A = 2*vdwtype[jnrA+0];
212 vdwjidx0B = 2*vdwtype[jnrB+0];
214 fjx0 = _mm_setzero_pd();
215 fjy0 = _mm_setzero_pd();
216 fjz0 = _mm_setzero_pd();
218 /**************************
219 * CALCULATE INTERACTIONS *
220 **************************/
222 r00 = _mm_mul_pd(rsq00,rinv00);
224 /* Compute parameters for interactions between i and j atoms */
225 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
226 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
228 /* Calculate table index by multiplying r with table scale and truncate to integer */
229 rt = _mm_mul_pd(r00,vftabscale);
230 vfitab = _mm_cvttpd_epi32(rt);
231 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
232 vfitab = _mm_slli_epi32(vfitab,3);
234 /* CUBIC SPLINE TABLE DISPERSION */
235 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
236 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
237 GMX_MM_TRANSPOSE2_PD(Y,F);
238 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
239 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
240 GMX_MM_TRANSPOSE2_PD(G,H);
241 Heps = _mm_mul_pd(vfeps,H);
242 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
243 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
244 vvdw6 = _mm_mul_pd(c6_00,VV);
245 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
246 fvdw6 = _mm_mul_pd(c6_00,FF);
248 /* CUBIC SPLINE TABLE REPULSION */
249 vfitab = _mm_add_epi32(vfitab,ifour);
250 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
251 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
252 GMX_MM_TRANSPOSE2_PD(Y,F);
253 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
254 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
255 GMX_MM_TRANSPOSE2_PD(G,H);
256 Heps = _mm_mul_pd(vfeps,H);
257 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
258 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
259 vvdw12 = _mm_mul_pd(c12_00,VV);
260 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
261 fvdw12 = _mm_mul_pd(c12_00,FF);
262 vvdw = _mm_add_pd(vvdw12,vvdw6);
263 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
265 /* Update potential sum for this i atom from the interaction with this j atom. */
266 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
270 /* Calculate temporary vectorial force */
271 tx = _mm_mul_pd(fscal,dx00);
272 ty = _mm_mul_pd(fscal,dy00);
273 tz = _mm_mul_pd(fscal,dz00);
275 /* Update vectorial force */
276 fix0 = _mm_add_pd(fix0,tx);
277 fiy0 = _mm_add_pd(fiy0,ty);
278 fiz0 = _mm_add_pd(fiz0,tz);
280 fjx0 = _mm_add_pd(fjx0,tx);
281 fjy0 = _mm_add_pd(fjy0,ty);
282 fjz0 = _mm_add_pd(fjz0,tz);
284 /**************************
285 * CALCULATE INTERACTIONS *
286 **************************/
288 /* Compute parameters for interactions between i and j atoms */
289 qq10 = _mm_mul_pd(iq1,jq0);
291 /* COULOMB ELECTROSTATICS */
292 velec = _mm_mul_pd(qq10,rinv10);
293 felec = _mm_mul_pd(velec,rinvsq10);
295 /* Update potential sum for this i atom from the interaction with this j atom. */
296 velecsum = _mm_add_pd(velecsum,velec);
300 /* Calculate temporary vectorial force */
301 tx = _mm_mul_pd(fscal,dx10);
302 ty = _mm_mul_pd(fscal,dy10);
303 tz = _mm_mul_pd(fscal,dz10);
305 /* Update vectorial force */
306 fix1 = _mm_add_pd(fix1,tx);
307 fiy1 = _mm_add_pd(fiy1,ty);
308 fiz1 = _mm_add_pd(fiz1,tz);
310 fjx0 = _mm_add_pd(fjx0,tx);
311 fjy0 = _mm_add_pd(fjy0,ty);
312 fjz0 = _mm_add_pd(fjz0,tz);
314 /**************************
315 * CALCULATE INTERACTIONS *
316 **************************/
318 /* Compute parameters for interactions between i and j atoms */
319 qq20 = _mm_mul_pd(iq2,jq0);
321 /* COULOMB ELECTROSTATICS */
322 velec = _mm_mul_pd(qq20,rinv20);
323 felec = _mm_mul_pd(velec,rinvsq20);
325 /* Update potential sum for this i atom from the interaction with this j atom. */
326 velecsum = _mm_add_pd(velecsum,velec);
330 /* Calculate temporary vectorial force */
331 tx = _mm_mul_pd(fscal,dx20);
332 ty = _mm_mul_pd(fscal,dy20);
333 tz = _mm_mul_pd(fscal,dz20);
335 /* Update vectorial force */
336 fix2 = _mm_add_pd(fix2,tx);
337 fiy2 = _mm_add_pd(fiy2,ty);
338 fiz2 = _mm_add_pd(fiz2,tz);
340 fjx0 = _mm_add_pd(fjx0,tx);
341 fjy0 = _mm_add_pd(fjy0,ty);
342 fjz0 = _mm_add_pd(fjz0,tz);
344 /**************************
345 * CALCULATE INTERACTIONS *
346 **************************/
348 /* Compute parameters for interactions between i and j atoms */
349 qq30 = _mm_mul_pd(iq3,jq0);
351 /* COULOMB ELECTROSTATICS */
352 velec = _mm_mul_pd(qq30,rinv30);
353 felec = _mm_mul_pd(velec,rinvsq30);
355 /* Update potential sum for this i atom from the interaction with this j atom. */
356 velecsum = _mm_add_pd(velecsum,velec);
360 /* Calculate temporary vectorial force */
361 tx = _mm_mul_pd(fscal,dx30);
362 ty = _mm_mul_pd(fscal,dy30);
363 tz = _mm_mul_pd(fscal,dz30);
365 /* Update vectorial force */
366 fix3 = _mm_add_pd(fix3,tx);
367 fiy3 = _mm_add_pd(fiy3,ty);
368 fiz3 = _mm_add_pd(fiz3,tz);
370 fjx0 = _mm_add_pd(fjx0,tx);
371 fjy0 = _mm_add_pd(fjy0,ty);
372 fjz0 = _mm_add_pd(fjz0,tz);
374 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
376 /* Inner loop uses 143 flops */
383 j_coord_offsetA = DIM*jnrA;
385 /* load j atom coordinates */
386 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
389 /* Calculate displacement vector */
390 dx00 = _mm_sub_pd(ix0,jx0);
391 dy00 = _mm_sub_pd(iy0,jy0);
392 dz00 = _mm_sub_pd(iz0,jz0);
393 dx10 = _mm_sub_pd(ix1,jx0);
394 dy10 = _mm_sub_pd(iy1,jy0);
395 dz10 = _mm_sub_pd(iz1,jz0);
396 dx20 = _mm_sub_pd(ix2,jx0);
397 dy20 = _mm_sub_pd(iy2,jy0);
398 dz20 = _mm_sub_pd(iz2,jz0);
399 dx30 = _mm_sub_pd(ix3,jx0);
400 dy30 = _mm_sub_pd(iy3,jy0);
401 dz30 = _mm_sub_pd(iz3,jz0);
403 /* Calculate squared distance and things based on it */
404 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
405 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
406 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
407 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
409 rinv00 = gmx_mm_invsqrt_pd(rsq00);
410 rinv10 = gmx_mm_invsqrt_pd(rsq10);
411 rinv20 = gmx_mm_invsqrt_pd(rsq20);
412 rinv30 = gmx_mm_invsqrt_pd(rsq30);
414 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
415 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
416 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
418 /* Load parameters for j particles */
419 jq0 = _mm_load_sd(charge+jnrA+0);
420 vdwjidx0A = 2*vdwtype[jnrA+0];
422 fjx0 = _mm_setzero_pd();
423 fjy0 = _mm_setzero_pd();
424 fjz0 = _mm_setzero_pd();
426 /**************************
427 * CALCULATE INTERACTIONS *
428 **************************/
430 r00 = _mm_mul_pd(rsq00,rinv00);
432 /* Compute parameters for interactions between i and j atoms */
433 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
435 /* Calculate table index by multiplying r with table scale and truncate to integer */
436 rt = _mm_mul_pd(r00,vftabscale);
437 vfitab = _mm_cvttpd_epi32(rt);
438 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
439 vfitab = _mm_slli_epi32(vfitab,3);
441 /* CUBIC SPLINE TABLE DISPERSION */
442 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
443 F = _mm_setzero_pd();
444 GMX_MM_TRANSPOSE2_PD(Y,F);
445 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
446 H = _mm_setzero_pd();
447 GMX_MM_TRANSPOSE2_PD(G,H);
448 Heps = _mm_mul_pd(vfeps,H);
449 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
450 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
451 vvdw6 = _mm_mul_pd(c6_00,VV);
452 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
453 fvdw6 = _mm_mul_pd(c6_00,FF);
455 /* CUBIC SPLINE TABLE REPULSION */
456 vfitab = _mm_add_epi32(vfitab,ifour);
457 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
458 F = _mm_setzero_pd();
459 GMX_MM_TRANSPOSE2_PD(Y,F);
460 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
461 H = _mm_setzero_pd();
462 GMX_MM_TRANSPOSE2_PD(G,H);
463 Heps = _mm_mul_pd(vfeps,H);
464 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
465 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
466 vvdw12 = _mm_mul_pd(c12_00,VV);
467 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
468 fvdw12 = _mm_mul_pd(c12_00,FF);
469 vvdw = _mm_add_pd(vvdw12,vvdw6);
470 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
472 /* Update potential sum for this i atom from the interaction with this j atom. */
473 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
474 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
478 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
480 /* Calculate temporary vectorial force */
481 tx = _mm_mul_pd(fscal,dx00);
482 ty = _mm_mul_pd(fscal,dy00);
483 tz = _mm_mul_pd(fscal,dz00);
485 /* Update vectorial force */
486 fix0 = _mm_add_pd(fix0,tx);
487 fiy0 = _mm_add_pd(fiy0,ty);
488 fiz0 = _mm_add_pd(fiz0,tz);
490 fjx0 = _mm_add_pd(fjx0,tx);
491 fjy0 = _mm_add_pd(fjy0,ty);
492 fjz0 = _mm_add_pd(fjz0,tz);
494 /**************************
495 * CALCULATE INTERACTIONS *
496 **************************/
498 /* Compute parameters for interactions between i and j atoms */
499 qq10 = _mm_mul_pd(iq1,jq0);
501 /* COULOMB ELECTROSTATICS */
502 velec = _mm_mul_pd(qq10,rinv10);
503 felec = _mm_mul_pd(velec,rinvsq10);
505 /* Update potential sum for this i atom from the interaction with this j atom. */
506 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
507 velecsum = _mm_add_pd(velecsum,velec);
511 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
513 /* Calculate temporary vectorial force */
514 tx = _mm_mul_pd(fscal,dx10);
515 ty = _mm_mul_pd(fscal,dy10);
516 tz = _mm_mul_pd(fscal,dz10);
518 /* Update vectorial force */
519 fix1 = _mm_add_pd(fix1,tx);
520 fiy1 = _mm_add_pd(fiy1,ty);
521 fiz1 = _mm_add_pd(fiz1,tz);
523 fjx0 = _mm_add_pd(fjx0,tx);
524 fjy0 = _mm_add_pd(fjy0,ty);
525 fjz0 = _mm_add_pd(fjz0,tz);
527 /**************************
528 * CALCULATE INTERACTIONS *
529 **************************/
531 /* Compute parameters for interactions between i and j atoms */
532 qq20 = _mm_mul_pd(iq2,jq0);
534 /* COULOMB ELECTROSTATICS */
535 velec = _mm_mul_pd(qq20,rinv20);
536 felec = _mm_mul_pd(velec,rinvsq20);
538 /* Update potential sum for this i atom from the interaction with this j atom. */
539 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
540 velecsum = _mm_add_pd(velecsum,velec);
544 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
546 /* Calculate temporary vectorial force */
547 tx = _mm_mul_pd(fscal,dx20);
548 ty = _mm_mul_pd(fscal,dy20);
549 tz = _mm_mul_pd(fscal,dz20);
551 /* Update vectorial force */
552 fix2 = _mm_add_pd(fix2,tx);
553 fiy2 = _mm_add_pd(fiy2,ty);
554 fiz2 = _mm_add_pd(fiz2,tz);
556 fjx0 = _mm_add_pd(fjx0,tx);
557 fjy0 = _mm_add_pd(fjy0,ty);
558 fjz0 = _mm_add_pd(fjz0,tz);
560 /**************************
561 * CALCULATE INTERACTIONS *
562 **************************/
564 /* Compute parameters for interactions between i and j atoms */
565 qq30 = _mm_mul_pd(iq3,jq0);
567 /* COULOMB ELECTROSTATICS */
568 velec = _mm_mul_pd(qq30,rinv30);
569 felec = _mm_mul_pd(velec,rinvsq30);
571 /* Update potential sum for this i atom from the interaction with this j atom. */
572 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
573 velecsum = _mm_add_pd(velecsum,velec);
577 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
579 /* Calculate temporary vectorial force */
580 tx = _mm_mul_pd(fscal,dx30);
581 ty = _mm_mul_pd(fscal,dy30);
582 tz = _mm_mul_pd(fscal,dz30);
584 /* Update vectorial force */
585 fix3 = _mm_add_pd(fix3,tx);
586 fiy3 = _mm_add_pd(fiy3,ty);
587 fiz3 = _mm_add_pd(fiz3,tz);
589 fjx0 = _mm_add_pd(fjx0,tx);
590 fjy0 = _mm_add_pd(fjy0,ty);
591 fjz0 = _mm_add_pd(fjz0,tz);
593 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
595 /* Inner loop uses 143 flops */
598 /* End of innermost loop */
600 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
601 f+i_coord_offset,fshift+i_shift_offset);
604 /* Update potential energies */
605 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
606 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
608 /* Increment number of inner iterations */
609 inneriter += j_index_end - j_index_start;
611 /* Outer loop uses 26 flops */
614 /* Increment number of outer iterations */
617 /* Update outer/inner flops */
619 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*143);
622 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_sse4_1_double
623 * Electrostatics interaction: Coulomb
624 * VdW interaction: CubicSplineTable
625 * Geometry: Water4-Particle
626 * Calculate force/pot: Force
629 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_sse4_1_double
630 (t_nblist * gmx_restrict nlist,
631 rvec * gmx_restrict xx,
632 rvec * gmx_restrict ff,
633 t_forcerec * gmx_restrict fr,
634 t_mdatoms * gmx_restrict mdatoms,
635 nb_kernel_data_t * gmx_restrict kernel_data,
636 t_nrnb * gmx_restrict nrnb)
638 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
639 * just 0 for non-waters.
640 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
641 * jnr indices corresponding to data put in the four positions in the SIMD register.
643 int i_shift_offset,i_coord_offset,outeriter,inneriter;
644 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
646 int j_coord_offsetA,j_coord_offsetB;
647 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
649 real *shiftvec,*fshift,*x,*f;
650 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
652 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
654 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
656 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
658 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
659 int vdwjidx0A,vdwjidx0B;
660 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
661 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
662 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
663 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
664 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
665 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
668 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
671 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
672 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
674 __m128i ifour = _mm_set1_epi32(4);
675 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
677 __m128d dummy_mask,cutoff_mask;
678 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
679 __m128d one = _mm_set1_pd(1.0);
680 __m128d two = _mm_set1_pd(2.0);
686 jindex = nlist->jindex;
688 shiftidx = nlist->shift;
690 shiftvec = fr->shift_vec[0];
691 fshift = fr->fshift[0];
692 facel = _mm_set1_pd(fr->epsfac);
693 charge = mdatoms->chargeA;
694 nvdwtype = fr->ntype;
696 vdwtype = mdatoms->typeA;
698 vftab = kernel_data->table_vdw->data;
699 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
701 /* Setup water-specific parameters */
702 inr = nlist->iinr[0];
703 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
704 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
705 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
706 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
708 /* Avoid stupid compiler warnings */
716 /* Start outer loop over neighborlists */
717 for(iidx=0; iidx<nri; iidx++)
719 /* Load shift vector for this list */
720 i_shift_offset = DIM*shiftidx[iidx];
722 /* Load limits for loop over neighbors */
723 j_index_start = jindex[iidx];
724 j_index_end = jindex[iidx+1];
726 /* Get outer coordinate index */
728 i_coord_offset = DIM*inr;
730 /* Load i particle coords and add shift vector */
731 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
732 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
734 fix0 = _mm_setzero_pd();
735 fiy0 = _mm_setzero_pd();
736 fiz0 = _mm_setzero_pd();
737 fix1 = _mm_setzero_pd();
738 fiy1 = _mm_setzero_pd();
739 fiz1 = _mm_setzero_pd();
740 fix2 = _mm_setzero_pd();
741 fiy2 = _mm_setzero_pd();
742 fiz2 = _mm_setzero_pd();
743 fix3 = _mm_setzero_pd();
744 fiy3 = _mm_setzero_pd();
745 fiz3 = _mm_setzero_pd();
747 /* Start inner kernel loop */
748 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
751 /* Get j neighbor index, and coordinate index */
754 j_coord_offsetA = DIM*jnrA;
755 j_coord_offsetB = DIM*jnrB;
757 /* load j atom coordinates */
758 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
761 /* Calculate displacement vector */
762 dx00 = _mm_sub_pd(ix0,jx0);
763 dy00 = _mm_sub_pd(iy0,jy0);
764 dz00 = _mm_sub_pd(iz0,jz0);
765 dx10 = _mm_sub_pd(ix1,jx0);
766 dy10 = _mm_sub_pd(iy1,jy0);
767 dz10 = _mm_sub_pd(iz1,jz0);
768 dx20 = _mm_sub_pd(ix2,jx0);
769 dy20 = _mm_sub_pd(iy2,jy0);
770 dz20 = _mm_sub_pd(iz2,jz0);
771 dx30 = _mm_sub_pd(ix3,jx0);
772 dy30 = _mm_sub_pd(iy3,jy0);
773 dz30 = _mm_sub_pd(iz3,jz0);
775 /* Calculate squared distance and things based on it */
776 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
777 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
778 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
779 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
781 rinv00 = gmx_mm_invsqrt_pd(rsq00);
782 rinv10 = gmx_mm_invsqrt_pd(rsq10);
783 rinv20 = gmx_mm_invsqrt_pd(rsq20);
784 rinv30 = gmx_mm_invsqrt_pd(rsq30);
786 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
787 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
788 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
790 /* Load parameters for j particles */
791 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
792 vdwjidx0A = 2*vdwtype[jnrA+0];
793 vdwjidx0B = 2*vdwtype[jnrB+0];
795 fjx0 = _mm_setzero_pd();
796 fjy0 = _mm_setzero_pd();
797 fjz0 = _mm_setzero_pd();
799 /**************************
800 * CALCULATE INTERACTIONS *
801 **************************/
803 r00 = _mm_mul_pd(rsq00,rinv00);
805 /* Compute parameters for interactions between i and j atoms */
806 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
807 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
809 /* Calculate table index by multiplying r with table scale and truncate to integer */
810 rt = _mm_mul_pd(r00,vftabscale);
811 vfitab = _mm_cvttpd_epi32(rt);
812 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
813 vfitab = _mm_slli_epi32(vfitab,3);
815 /* CUBIC SPLINE TABLE DISPERSION */
816 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
817 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
818 GMX_MM_TRANSPOSE2_PD(Y,F);
819 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
820 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
821 GMX_MM_TRANSPOSE2_PD(G,H);
822 Heps = _mm_mul_pd(vfeps,H);
823 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
824 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
825 fvdw6 = _mm_mul_pd(c6_00,FF);
827 /* CUBIC SPLINE TABLE REPULSION */
828 vfitab = _mm_add_epi32(vfitab,ifour);
829 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
830 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
831 GMX_MM_TRANSPOSE2_PD(Y,F);
832 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
833 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
834 GMX_MM_TRANSPOSE2_PD(G,H);
835 Heps = _mm_mul_pd(vfeps,H);
836 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
837 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
838 fvdw12 = _mm_mul_pd(c12_00,FF);
839 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
843 /* Calculate temporary vectorial force */
844 tx = _mm_mul_pd(fscal,dx00);
845 ty = _mm_mul_pd(fscal,dy00);
846 tz = _mm_mul_pd(fscal,dz00);
848 /* Update vectorial force */
849 fix0 = _mm_add_pd(fix0,tx);
850 fiy0 = _mm_add_pd(fiy0,ty);
851 fiz0 = _mm_add_pd(fiz0,tz);
853 fjx0 = _mm_add_pd(fjx0,tx);
854 fjy0 = _mm_add_pd(fjy0,ty);
855 fjz0 = _mm_add_pd(fjz0,tz);
857 /**************************
858 * CALCULATE INTERACTIONS *
859 **************************/
861 /* Compute parameters for interactions between i and j atoms */
862 qq10 = _mm_mul_pd(iq1,jq0);
864 /* COULOMB ELECTROSTATICS */
865 velec = _mm_mul_pd(qq10,rinv10);
866 felec = _mm_mul_pd(velec,rinvsq10);
870 /* Calculate temporary vectorial force */
871 tx = _mm_mul_pd(fscal,dx10);
872 ty = _mm_mul_pd(fscal,dy10);
873 tz = _mm_mul_pd(fscal,dz10);
875 /* Update vectorial force */
876 fix1 = _mm_add_pd(fix1,tx);
877 fiy1 = _mm_add_pd(fiy1,ty);
878 fiz1 = _mm_add_pd(fiz1,tz);
880 fjx0 = _mm_add_pd(fjx0,tx);
881 fjy0 = _mm_add_pd(fjy0,ty);
882 fjz0 = _mm_add_pd(fjz0,tz);
884 /**************************
885 * CALCULATE INTERACTIONS *
886 **************************/
888 /* Compute parameters for interactions between i and j atoms */
889 qq20 = _mm_mul_pd(iq2,jq0);
891 /* COULOMB ELECTROSTATICS */
892 velec = _mm_mul_pd(qq20,rinv20);
893 felec = _mm_mul_pd(velec,rinvsq20);
897 /* Calculate temporary vectorial force */
898 tx = _mm_mul_pd(fscal,dx20);
899 ty = _mm_mul_pd(fscal,dy20);
900 tz = _mm_mul_pd(fscal,dz20);
902 /* Update vectorial force */
903 fix2 = _mm_add_pd(fix2,tx);
904 fiy2 = _mm_add_pd(fiy2,ty);
905 fiz2 = _mm_add_pd(fiz2,tz);
907 fjx0 = _mm_add_pd(fjx0,tx);
908 fjy0 = _mm_add_pd(fjy0,ty);
909 fjz0 = _mm_add_pd(fjz0,tz);
911 /**************************
912 * CALCULATE INTERACTIONS *
913 **************************/
915 /* Compute parameters for interactions between i and j atoms */
916 qq30 = _mm_mul_pd(iq3,jq0);
918 /* COULOMB ELECTROSTATICS */
919 velec = _mm_mul_pd(qq30,rinv30);
920 felec = _mm_mul_pd(velec,rinvsq30);
924 /* Calculate temporary vectorial force */
925 tx = _mm_mul_pd(fscal,dx30);
926 ty = _mm_mul_pd(fscal,dy30);
927 tz = _mm_mul_pd(fscal,dz30);
929 /* Update vectorial force */
930 fix3 = _mm_add_pd(fix3,tx);
931 fiy3 = _mm_add_pd(fiy3,ty);
932 fiz3 = _mm_add_pd(fiz3,tz);
934 fjx0 = _mm_add_pd(fjx0,tx);
935 fjy0 = _mm_add_pd(fjy0,ty);
936 fjz0 = _mm_add_pd(fjz0,tz);
938 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
940 /* Inner loop uses 132 flops */
947 j_coord_offsetA = DIM*jnrA;
949 /* load j atom coordinates */
950 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
953 /* Calculate displacement vector */
954 dx00 = _mm_sub_pd(ix0,jx0);
955 dy00 = _mm_sub_pd(iy0,jy0);
956 dz00 = _mm_sub_pd(iz0,jz0);
957 dx10 = _mm_sub_pd(ix1,jx0);
958 dy10 = _mm_sub_pd(iy1,jy0);
959 dz10 = _mm_sub_pd(iz1,jz0);
960 dx20 = _mm_sub_pd(ix2,jx0);
961 dy20 = _mm_sub_pd(iy2,jy0);
962 dz20 = _mm_sub_pd(iz2,jz0);
963 dx30 = _mm_sub_pd(ix3,jx0);
964 dy30 = _mm_sub_pd(iy3,jy0);
965 dz30 = _mm_sub_pd(iz3,jz0);
967 /* Calculate squared distance and things based on it */
968 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
969 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
970 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
971 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
973 rinv00 = gmx_mm_invsqrt_pd(rsq00);
974 rinv10 = gmx_mm_invsqrt_pd(rsq10);
975 rinv20 = gmx_mm_invsqrt_pd(rsq20);
976 rinv30 = gmx_mm_invsqrt_pd(rsq30);
978 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
979 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
980 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
982 /* Load parameters for j particles */
983 jq0 = _mm_load_sd(charge+jnrA+0);
984 vdwjidx0A = 2*vdwtype[jnrA+0];
986 fjx0 = _mm_setzero_pd();
987 fjy0 = _mm_setzero_pd();
988 fjz0 = _mm_setzero_pd();
990 /**************************
991 * CALCULATE INTERACTIONS *
992 **************************/
994 r00 = _mm_mul_pd(rsq00,rinv00);
996 /* Compute parameters for interactions between i and j atoms */
997 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
999 /* Calculate table index by multiplying r with table scale and truncate to integer */
1000 rt = _mm_mul_pd(r00,vftabscale);
1001 vfitab = _mm_cvttpd_epi32(rt);
1002 vfeps = _mm_sub_pd(rt,_mm_round_pd(rt, _MM_FROUND_FLOOR));
1003 vfitab = _mm_slli_epi32(vfitab,3);
1005 /* CUBIC SPLINE TABLE DISPERSION */
1006 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
1007 F = _mm_setzero_pd();
1008 GMX_MM_TRANSPOSE2_PD(Y,F);
1009 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
1010 H = _mm_setzero_pd();
1011 GMX_MM_TRANSPOSE2_PD(G,H);
1012 Heps = _mm_mul_pd(vfeps,H);
1013 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
1014 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
1015 fvdw6 = _mm_mul_pd(c6_00,FF);
1017 /* CUBIC SPLINE TABLE REPULSION */
1018 vfitab = _mm_add_epi32(vfitab,ifour);
1019 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
1020 F = _mm_setzero_pd();
1021 GMX_MM_TRANSPOSE2_PD(Y,F);
1022 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
1023 H = _mm_setzero_pd();
1024 GMX_MM_TRANSPOSE2_PD(G,H);
1025 Heps = _mm_mul_pd(vfeps,H);
1026 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
1027 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
1028 fvdw12 = _mm_mul_pd(c12_00,FF);
1029 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
1033 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1035 /* Calculate temporary vectorial force */
1036 tx = _mm_mul_pd(fscal,dx00);
1037 ty = _mm_mul_pd(fscal,dy00);
1038 tz = _mm_mul_pd(fscal,dz00);
1040 /* Update vectorial force */
1041 fix0 = _mm_add_pd(fix0,tx);
1042 fiy0 = _mm_add_pd(fiy0,ty);
1043 fiz0 = _mm_add_pd(fiz0,tz);
1045 fjx0 = _mm_add_pd(fjx0,tx);
1046 fjy0 = _mm_add_pd(fjy0,ty);
1047 fjz0 = _mm_add_pd(fjz0,tz);
1049 /**************************
1050 * CALCULATE INTERACTIONS *
1051 **************************/
1053 /* Compute parameters for interactions between i and j atoms */
1054 qq10 = _mm_mul_pd(iq1,jq0);
1056 /* COULOMB ELECTROSTATICS */
1057 velec = _mm_mul_pd(qq10,rinv10);
1058 felec = _mm_mul_pd(velec,rinvsq10);
1062 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1064 /* Calculate temporary vectorial force */
1065 tx = _mm_mul_pd(fscal,dx10);
1066 ty = _mm_mul_pd(fscal,dy10);
1067 tz = _mm_mul_pd(fscal,dz10);
1069 /* Update vectorial force */
1070 fix1 = _mm_add_pd(fix1,tx);
1071 fiy1 = _mm_add_pd(fiy1,ty);
1072 fiz1 = _mm_add_pd(fiz1,tz);
1074 fjx0 = _mm_add_pd(fjx0,tx);
1075 fjy0 = _mm_add_pd(fjy0,ty);
1076 fjz0 = _mm_add_pd(fjz0,tz);
1078 /**************************
1079 * CALCULATE INTERACTIONS *
1080 **************************/
1082 /* Compute parameters for interactions between i and j atoms */
1083 qq20 = _mm_mul_pd(iq2,jq0);
1085 /* COULOMB ELECTROSTATICS */
1086 velec = _mm_mul_pd(qq20,rinv20);
1087 felec = _mm_mul_pd(velec,rinvsq20);
1091 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1093 /* Calculate temporary vectorial force */
1094 tx = _mm_mul_pd(fscal,dx20);
1095 ty = _mm_mul_pd(fscal,dy20);
1096 tz = _mm_mul_pd(fscal,dz20);
1098 /* Update vectorial force */
1099 fix2 = _mm_add_pd(fix2,tx);
1100 fiy2 = _mm_add_pd(fiy2,ty);
1101 fiz2 = _mm_add_pd(fiz2,tz);
1103 fjx0 = _mm_add_pd(fjx0,tx);
1104 fjy0 = _mm_add_pd(fjy0,ty);
1105 fjz0 = _mm_add_pd(fjz0,tz);
1107 /**************************
1108 * CALCULATE INTERACTIONS *
1109 **************************/
1111 /* Compute parameters for interactions between i and j atoms */
1112 qq30 = _mm_mul_pd(iq3,jq0);
1114 /* COULOMB ELECTROSTATICS */
1115 velec = _mm_mul_pd(qq30,rinv30);
1116 felec = _mm_mul_pd(velec,rinvsq30);
1120 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1122 /* Calculate temporary vectorial force */
1123 tx = _mm_mul_pd(fscal,dx30);
1124 ty = _mm_mul_pd(fscal,dy30);
1125 tz = _mm_mul_pd(fscal,dz30);
1127 /* Update vectorial force */
1128 fix3 = _mm_add_pd(fix3,tx);
1129 fiy3 = _mm_add_pd(fiy3,ty);
1130 fiz3 = _mm_add_pd(fiz3,tz);
1132 fjx0 = _mm_add_pd(fjx0,tx);
1133 fjy0 = _mm_add_pd(fjy0,ty);
1134 fjz0 = _mm_add_pd(fjz0,tz);
1136 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1138 /* Inner loop uses 132 flops */
1141 /* End of innermost loop */
1143 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1144 f+i_coord_offset,fshift+i_shift_offset);
1146 /* Increment number of inner iterations */
1147 inneriter += j_index_end - j_index_start;
1149 /* Outer loop uses 24 flops */
1152 /* Increment number of outer iterations */
1155 /* Update outer/inner flops */
1157 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*132);