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 sse2_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
49 #include "gromacs/simd/math_x86_sse2_double.h"
50 #include "kernelutil_x86_sse2_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_VF_sse2_double
54 * Electrostatics interaction: Coulomb
55 * VdW interaction: CubicSplineTable
56 * Geometry: Water4-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_VF_sse2_double
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
72 * jnr indices corresponding to data put in the four positions in the SIMD register.
74 int i_shift_offset,i_coord_offset,outeriter,inneriter;
75 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
77 int j_coord_offsetA,j_coord_offsetB;
78 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
80 real *shiftvec,*fshift,*x,*f;
81 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
83 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
85 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
87 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
89 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
90 int vdwjidx0A,vdwjidx0B;
91 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
92 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
93 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
94 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
95 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
96 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
99 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
102 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
103 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
105 __m128i ifour = _mm_set1_epi32(4);
106 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
108 __m128d dummy_mask,cutoff_mask;
109 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
110 __m128d one = _mm_set1_pd(1.0);
111 __m128d two = _mm_set1_pd(2.0);
117 jindex = nlist->jindex;
119 shiftidx = nlist->shift;
121 shiftvec = fr->shift_vec[0];
122 fshift = fr->fshift[0];
123 facel = _mm_set1_pd(fr->epsfac);
124 charge = mdatoms->chargeA;
125 nvdwtype = fr->ntype;
127 vdwtype = mdatoms->typeA;
129 vftab = kernel_data->table_vdw->data;
130 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
132 /* Setup water-specific parameters */
133 inr = nlist->iinr[0];
134 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
135 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
136 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
137 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
139 /* Avoid stupid compiler warnings */
147 /* Start outer loop over neighborlists */
148 for(iidx=0; iidx<nri; iidx++)
150 /* Load shift vector for this list */
151 i_shift_offset = DIM*shiftidx[iidx];
153 /* Load limits for loop over neighbors */
154 j_index_start = jindex[iidx];
155 j_index_end = jindex[iidx+1];
157 /* Get outer coordinate index */
159 i_coord_offset = DIM*inr;
161 /* Load i particle coords and add shift vector */
162 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
163 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
165 fix0 = _mm_setzero_pd();
166 fiy0 = _mm_setzero_pd();
167 fiz0 = _mm_setzero_pd();
168 fix1 = _mm_setzero_pd();
169 fiy1 = _mm_setzero_pd();
170 fiz1 = _mm_setzero_pd();
171 fix2 = _mm_setzero_pd();
172 fiy2 = _mm_setzero_pd();
173 fiz2 = _mm_setzero_pd();
174 fix3 = _mm_setzero_pd();
175 fiy3 = _mm_setzero_pd();
176 fiz3 = _mm_setzero_pd();
178 /* Reset potential sums */
179 velecsum = _mm_setzero_pd();
180 vvdwsum = _mm_setzero_pd();
182 /* Start inner kernel loop */
183 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
186 /* Get j neighbor index, and coordinate index */
189 j_coord_offsetA = DIM*jnrA;
190 j_coord_offsetB = DIM*jnrB;
192 /* load j atom coordinates */
193 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
196 /* Calculate displacement vector */
197 dx00 = _mm_sub_pd(ix0,jx0);
198 dy00 = _mm_sub_pd(iy0,jy0);
199 dz00 = _mm_sub_pd(iz0,jz0);
200 dx10 = _mm_sub_pd(ix1,jx0);
201 dy10 = _mm_sub_pd(iy1,jy0);
202 dz10 = _mm_sub_pd(iz1,jz0);
203 dx20 = _mm_sub_pd(ix2,jx0);
204 dy20 = _mm_sub_pd(iy2,jy0);
205 dz20 = _mm_sub_pd(iz2,jz0);
206 dx30 = _mm_sub_pd(ix3,jx0);
207 dy30 = _mm_sub_pd(iy3,jy0);
208 dz30 = _mm_sub_pd(iz3,jz0);
210 /* Calculate squared distance and things based on it */
211 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
212 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
213 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
214 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
216 rinv00 = gmx_mm_invsqrt_pd(rsq00);
217 rinv10 = gmx_mm_invsqrt_pd(rsq10);
218 rinv20 = gmx_mm_invsqrt_pd(rsq20);
219 rinv30 = gmx_mm_invsqrt_pd(rsq30);
221 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
222 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
223 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
225 /* Load parameters for j particles */
226 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
227 vdwjidx0A = 2*vdwtype[jnrA+0];
228 vdwjidx0B = 2*vdwtype[jnrB+0];
230 fjx0 = _mm_setzero_pd();
231 fjy0 = _mm_setzero_pd();
232 fjz0 = _mm_setzero_pd();
234 /**************************
235 * CALCULATE INTERACTIONS *
236 **************************/
238 r00 = _mm_mul_pd(rsq00,rinv00);
240 /* Compute parameters for interactions between i and j atoms */
241 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
242 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
244 /* Calculate table index by multiplying r with table scale and truncate to integer */
245 rt = _mm_mul_pd(r00,vftabscale);
246 vfitab = _mm_cvttpd_epi32(rt);
247 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
248 vfitab = _mm_slli_epi32(vfitab,3);
250 /* CUBIC SPLINE TABLE DISPERSION */
251 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
252 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
253 GMX_MM_TRANSPOSE2_PD(Y,F);
254 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
255 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
256 GMX_MM_TRANSPOSE2_PD(G,H);
257 Heps = _mm_mul_pd(vfeps,H);
258 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
259 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
260 vvdw6 = _mm_mul_pd(c6_00,VV);
261 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
262 fvdw6 = _mm_mul_pd(c6_00,FF);
264 /* CUBIC SPLINE TABLE REPULSION */
265 vfitab = _mm_add_epi32(vfitab,ifour);
266 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
267 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
268 GMX_MM_TRANSPOSE2_PD(Y,F);
269 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
270 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
271 GMX_MM_TRANSPOSE2_PD(G,H);
272 Heps = _mm_mul_pd(vfeps,H);
273 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
274 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
275 vvdw12 = _mm_mul_pd(c12_00,VV);
276 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
277 fvdw12 = _mm_mul_pd(c12_00,FF);
278 vvdw = _mm_add_pd(vvdw12,vvdw6);
279 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
281 /* Update potential sum for this i atom from the interaction with this j atom. */
282 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
286 /* Calculate temporary vectorial force */
287 tx = _mm_mul_pd(fscal,dx00);
288 ty = _mm_mul_pd(fscal,dy00);
289 tz = _mm_mul_pd(fscal,dz00);
291 /* Update vectorial force */
292 fix0 = _mm_add_pd(fix0,tx);
293 fiy0 = _mm_add_pd(fiy0,ty);
294 fiz0 = _mm_add_pd(fiz0,tz);
296 fjx0 = _mm_add_pd(fjx0,tx);
297 fjy0 = _mm_add_pd(fjy0,ty);
298 fjz0 = _mm_add_pd(fjz0,tz);
300 /**************************
301 * CALCULATE INTERACTIONS *
302 **************************/
304 /* Compute parameters for interactions between i and j atoms */
305 qq10 = _mm_mul_pd(iq1,jq0);
307 /* COULOMB ELECTROSTATICS */
308 velec = _mm_mul_pd(qq10,rinv10);
309 felec = _mm_mul_pd(velec,rinvsq10);
311 /* Update potential sum for this i atom from the interaction with this j atom. */
312 velecsum = _mm_add_pd(velecsum,velec);
316 /* Calculate temporary vectorial force */
317 tx = _mm_mul_pd(fscal,dx10);
318 ty = _mm_mul_pd(fscal,dy10);
319 tz = _mm_mul_pd(fscal,dz10);
321 /* Update vectorial force */
322 fix1 = _mm_add_pd(fix1,tx);
323 fiy1 = _mm_add_pd(fiy1,ty);
324 fiz1 = _mm_add_pd(fiz1,tz);
326 fjx0 = _mm_add_pd(fjx0,tx);
327 fjy0 = _mm_add_pd(fjy0,ty);
328 fjz0 = _mm_add_pd(fjz0,tz);
330 /**************************
331 * CALCULATE INTERACTIONS *
332 **************************/
334 /* Compute parameters for interactions between i and j atoms */
335 qq20 = _mm_mul_pd(iq2,jq0);
337 /* COULOMB ELECTROSTATICS */
338 velec = _mm_mul_pd(qq20,rinv20);
339 felec = _mm_mul_pd(velec,rinvsq20);
341 /* Update potential sum for this i atom from the interaction with this j atom. */
342 velecsum = _mm_add_pd(velecsum,velec);
346 /* Calculate temporary vectorial force */
347 tx = _mm_mul_pd(fscal,dx20);
348 ty = _mm_mul_pd(fscal,dy20);
349 tz = _mm_mul_pd(fscal,dz20);
351 /* Update vectorial force */
352 fix2 = _mm_add_pd(fix2,tx);
353 fiy2 = _mm_add_pd(fiy2,ty);
354 fiz2 = _mm_add_pd(fiz2,tz);
356 fjx0 = _mm_add_pd(fjx0,tx);
357 fjy0 = _mm_add_pd(fjy0,ty);
358 fjz0 = _mm_add_pd(fjz0,tz);
360 /**************************
361 * CALCULATE INTERACTIONS *
362 **************************/
364 /* Compute parameters for interactions between i and j atoms */
365 qq30 = _mm_mul_pd(iq3,jq0);
367 /* COULOMB ELECTROSTATICS */
368 velec = _mm_mul_pd(qq30,rinv30);
369 felec = _mm_mul_pd(velec,rinvsq30);
371 /* Update potential sum for this i atom from the interaction with this j atom. */
372 velecsum = _mm_add_pd(velecsum,velec);
376 /* Calculate temporary vectorial force */
377 tx = _mm_mul_pd(fscal,dx30);
378 ty = _mm_mul_pd(fscal,dy30);
379 tz = _mm_mul_pd(fscal,dz30);
381 /* Update vectorial force */
382 fix3 = _mm_add_pd(fix3,tx);
383 fiy3 = _mm_add_pd(fiy3,ty);
384 fiz3 = _mm_add_pd(fiz3,tz);
386 fjx0 = _mm_add_pd(fjx0,tx);
387 fjy0 = _mm_add_pd(fjy0,ty);
388 fjz0 = _mm_add_pd(fjz0,tz);
390 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
392 /* Inner loop uses 143 flops */
399 j_coord_offsetA = DIM*jnrA;
401 /* load j atom coordinates */
402 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
405 /* Calculate displacement vector */
406 dx00 = _mm_sub_pd(ix0,jx0);
407 dy00 = _mm_sub_pd(iy0,jy0);
408 dz00 = _mm_sub_pd(iz0,jz0);
409 dx10 = _mm_sub_pd(ix1,jx0);
410 dy10 = _mm_sub_pd(iy1,jy0);
411 dz10 = _mm_sub_pd(iz1,jz0);
412 dx20 = _mm_sub_pd(ix2,jx0);
413 dy20 = _mm_sub_pd(iy2,jy0);
414 dz20 = _mm_sub_pd(iz2,jz0);
415 dx30 = _mm_sub_pd(ix3,jx0);
416 dy30 = _mm_sub_pd(iy3,jy0);
417 dz30 = _mm_sub_pd(iz3,jz0);
419 /* Calculate squared distance and things based on it */
420 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
421 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
422 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
423 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
425 rinv00 = gmx_mm_invsqrt_pd(rsq00);
426 rinv10 = gmx_mm_invsqrt_pd(rsq10);
427 rinv20 = gmx_mm_invsqrt_pd(rsq20);
428 rinv30 = gmx_mm_invsqrt_pd(rsq30);
430 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
431 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
432 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
434 /* Load parameters for j particles */
435 jq0 = _mm_load_sd(charge+jnrA+0);
436 vdwjidx0A = 2*vdwtype[jnrA+0];
438 fjx0 = _mm_setzero_pd();
439 fjy0 = _mm_setzero_pd();
440 fjz0 = _mm_setzero_pd();
442 /**************************
443 * CALCULATE INTERACTIONS *
444 **************************/
446 r00 = _mm_mul_pd(rsq00,rinv00);
448 /* Compute parameters for interactions between i and j atoms */
449 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
451 /* Calculate table index by multiplying r with table scale and truncate to integer */
452 rt = _mm_mul_pd(r00,vftabscale);
453 vfitab = _mm_cvttpd_epi32(rt);
454 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
455 vfitab = _mm_slli_epi32(vfitab,3);
457 /* CUBIC SPLINE TABLE DISPERSION */
458 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
459 F = _mm_setzero_pd();
460 GMX_MM_TRANSPOSE2_PD(Y,F);
461 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
462 H = _mm_setzero_pd();
463 GMX_MM_TRANSPOSE2_PD(G,H);
464 Heps = _mm_mul_pd(vfeps,H);
465 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
466 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
467 vvdw6 = _mm_mul_pd(c6_00,VV);
468 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
469 fvdw6 = _mm_mul_pd(c6_00,FF);
471 /* CUBIC SPLINE TABLE REPULSION */
472 vfitab = _mm_add_epi32(vfitab,ifour);
473 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
474 F = _mm_setzero_pd();
475 GMX_MM_TRANSPOSE2_PD(Y,F);
476 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
477 H = _mm_setzero_pd();
478 GMX_MM_TRANSPOSE2_PD(G,H);
479 Heps = _mm_mul_pd(vfeps,H);
480 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
481 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
482 vvdw12 = _mm_mul_pd(c12_00,VV);
483 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
484 fvdw12 = _mm_mul_pd(c12_00,FF);
485 vvdw = _mm_add_pd(vvdw12,vvdw6);
486 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
488 /* Update potential sum for this i atom from the interaction with this j atom. */
489 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
490 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
494 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
496 /* Calculate temporary vectorial force */
497 tx = _mm_mul_pd(fscal,dx00);
498 ty = _mm_mul_pd(fscal,dy00);
499 tz = _mm_mul_pd(fscal,dz00);
501 /* Update vectorial force */
502 fix0 = _mm_add_pd(fix0,tx);
503 fiy0 = _mm_add_pd(fiy0,ty);
504 fiz0 = _mm_add_pd(fiz0,tz);
506 fjx0 = _mm_add_pd(fjx0,tx);
507 fjy0 = _mm_add_pd(fjy0,ty);
508 fjz0 = _mm_add_pd(fjz0,tz);
510 /**************************
511 * CALCULATE INTERACTIONS *
512 **************************/
514 /* Compute parameters for interactions between i and j atoms */
515 qq10 = _mm_mul_pd(iq1,jq0);
517 /* COULOMB ELECTROSTATICS */
518 velec = _mm_mul_pd(qq10,rinv10);
519 felec = _mm_mul_pd(velec,rinvsq10);
521 /* Update potential sum for this i atom from the interaction with this j atom. */
522 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
523 velecsum = _mm_add_pd(velecsum,velec);
527 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
529 /* Calculate temporary vectorial force */
530 tx = _mm_mul_pd(fscal,dx10);
531 ty = _mm_mul_pd(fscal,dy10);
532 tz = _mm_mul_pd(fscal,dz10);
534 /* Update vectorial force */
535 fix1 = _mm_add_pd(fix1,tx);
536 fiy1 = _mm_add_pd(fiy1,ty);
537 fiz1 = _mm_add_pd(fiz1,tz);
539 fjx0 = _mm_add_pd(fjx0,tx);
540 fjy0 = _mm_add_pd(fjy0,ty);
541 fjz0 = _mm_add_pd(fjz0,tz);
543 /**************************
544 * CALCULATE INTERACTIONS *
545 **************************/
547 /* Compute parameters for interactions between i and j atoms */
548 qq20 = _mm_mul_pd(iq2,jq0);
550 /* COULOMB ELECTROSTATICS */
551 velec = _mm_mul_pd(qq20,rinv20);
552 felec = _mm_mul_pd(velec,rinvsq20);
554 /* Update potential sum for this i atom from the interaction with this j atom. */
555 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
556 velecsum = _mm_add_pd(velecsum,velec);
560 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
562 /* Calculate temporary vectorial force */
563 tx = _mm_mul_pd(fscal,dx20);
564 ty = _mm_mul_pd(fscal,dy20);
565 tz = _mm_mul_pd(fscal,dz20);
567 /* Update vectorial force */
568 fix2 = _mm_add_pd(fix2,tx);
569 fiy2 = _mm_add_pd(fiy2,ty);
570 fiz2 = _mm_add_pd(fiz2,tz);
572 fjx0 = _mm_add_pd(fjx0,tx);
573 fjy0 = _mm_add_pd(fjy0,ty);
574 fjz0 = _mm_add_pd(fjz0,tz);
576 /**************************
577 * CALCULATE INTERACTIONS *
578 **************************/
580 /* Compute parameters for interactions between i and j atoms */
581 qq30 = _mm_mul_pd(iq3,jq0);
583 /* COULOMB ELECTROSTATICS */
584 velec = _mm_mul_pd(qq30,rinv30);
585 felec = _mm_mul_pd(velec,rinvsq30);
587 /* Update potential sum for this i atom from the interaction with this j atom. */
588 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
589 velecsum = _mm_add_pd(velecsum,velec);
593 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
595 /* Calculate temporary vectorial force */
596 tx = _mm_mul_pd(fscal,dx30);
597 ty = _mm_mul_pd(fscal,dy30);
598 tz = _mm_mul_pd(fscal,dz30);
600 /* Update vectorial force */
601 fix3 = _mm_add_pd(fix3,tx);
602 fiy3 = _mm_add_pd(fiy3,ty);
603 fiz3 = _mm_add_pd(fiz3,tz);
605 fjx0 = _mm_add_pd(fjx0,tx);
606 fjy0 = _mm_add_pd(fjy0,ty);
607 fjz0 = _mm_add_pd(fjz0,tz);
609 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
611 /* Inner loop uses 143 flops */
614 /* End of innermost loop */
616 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
617 f+i_coord_offset,fshift+i_shift_offset);
620 /* Update potential energies */
621 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
622 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
624 /* Increment number of inner iterations */
625 inneriter += j_index_end - j_index_start;
627 /* Outer loop uses 26 flops */
630 /* Increment number of outer iterations */
633 /* Update outer/inner flops */
635 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*143);
638 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_sse2_double
639 * Electrostatics interaction: Coulomb
640 * VdW interaction: CubicSplineTable
641 * Geometry: Water4-Particle
642 * Calculate force/pot: Force
645 nb_kernel_ElecCoul_VdwCSTab_GeomW4P1_F_sse2_double
646 (t_nblist * gmx_restrict nlist,
647 rvec * gmx_restrict xx,
648 rvec * gmx_restrict ff,
649 t_forcerec * gmx_restrict fr,
650 t_mdatoms * gmx_restrict mdatoms,
651 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
652 t_nrnb * gmx_restrict nrnb)
654 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
655 * just 0 for non-waters.
656 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
657 * jnr indices corresponding to data put in the four positions in the SIMD register.
659 int i_shift_offset,i_coord_offset,outeriter,inneriter;
660 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
662 int j_coord_offsetA,j_coord_offsetB;
663 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
665 real *shiftvec,*fshift,*x,*f;
666 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
668 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
670 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
672 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
674 __m128d ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
675 int vdwjidx0A,vdwjidx0B;
676 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
677 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
678 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
679 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
680 __m128d dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
681 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
684 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
687 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
688 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
690 __m128i ifour = _mm_set1_epi32(4);
691 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
693 __m128d dummy_mask,cutoff_mask;
694 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
695 __m128d one = _mm_set1_pd(1.0);
696 __m128d two = _mm_set1_pd(2.0);
702 jindex = nlist->jindex;
704 shiftidx = nlist->shift;
706 shiftvec = fr->shift_vec[0];
707 fshift = fr->fshift[0];
708 facel = _mm_set1_pd(fr->epsfac);
709 charge = mdatoms->chargeA;
710 nvdwtype = fr->ntype;
712 vdwtype = mdatoms->typeA;
714 vftab = kernel_data->table_vdw->data;
715 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
717 /* Setup water-specific parameters */
718 inr = nlist->iinr[0];
719 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
720 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
721 iq3 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
722 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
724 /* Avoid stupid compiler warnings */
732 /* Start outer loop over neighborlists */
733 for(iidx=0; iidx<nri; iidx++)
735 /* Load shift vector for this list */
736 i_shift_offset = DIM*shiftidx[iidx];
738 /* Load limits for loop over neighbors */
739 j_index_start = jindex[iidx];
740 j_index_end = jindex[iidx+1];
742 /* Get outer coordinate index */
744 i_coord_offset = DIM*inr;
746 /* Load i particle coords and add shift vector */
747 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
748 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
750 fix0 = _mm_setzero_pd();
751 fiy0 = _mm_setzero_pd();
752 fiz0 = _mm_setzero_pd();
753 fix1 = _mm_setzero_pd();
754 fiy1 = _mm_setzero_pd();
755 fiz1 = _mm_setzero_pd();
756 fix2 = _mm_setzero_pd();
757 fiy2 = _mm_setzero_pd();
758 fiz2 = _mm_setzero_pd();
759 fix3 = _mm_setzero_pd();
760 fiy3 = _mm_setzero_pd();
761 fiz3 = _mm_setzero_pd();
763 /* Start inner kernel loop */
764 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
767 /* Get j neighbor index, and coordinate index */
770 j_coord_offsetA = DIM*jnrA;
771 j_coord_offsetB = DIM*jnrB;
773 /* load j atom coordinates */
774 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
777 /* Calculate displacement vector */
778 dx00 = _mm_sub_pd(ix0,jx0);
779 dy00 = _mm_sub_pd(iy0,jy0);
780 dz00 = _mm_sub_pd(iz0,jz0);
781 dx10 = _mm_sub_pd(ix1,jx0);
782 dy10 = _mm_sub_pd(iy1,jy0);
783 dz10 = _mm_sub_pd(iz1,jz0);
784 dx20 = _mm_sub_pd(ix2,jx0);
785 dy20 = _mm_sub_pd(iy2,jy0);
786 dz20 = _mm_sub_pd(iz2,jz0);
787 dx30 = _mm_sub_pd(ix3,jx0);
788 dy30 = _mm_sub_pd(iy3,jy0);
789 dz30 = _mm_sub_pd(iz3,jz0);
791 /* Calculate squared distance and things based on it */
792 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
793 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
794 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
795 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
797 rinv00 = gmx_mm_invsqrt_pd(rsq00);
798 rinv10 = gmx_mm_invsqrt_pd(rsq10);
799 rinv20 = gmx_mm_invsqrt_pd(rsq20);
800 rinv30 = gmx_mm_invsqrt_pd(rsq30);
802 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
803 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
804 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
806 /* Load parameters for j particles */
807 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
808 vdwjidx0A = 2*vdwtype[jnrA+0];
809 vdwjidx0B = 2*vdwtype[jnrB+0];
811 fjx0 = _mm_setzero_pd();
812 fjy0 = _mm_setzero_pd();
813 fjz0 = _mm_setzero_pd();
815 /**************************
816 * CALCULATE INTERACTIONS *
817 **************************/
819 r00 = _mm_mul_pd(rsq00,rinv00);
821 /* Compute parameters for interactions between i and j atoms */
822 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
823 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
825 /* Calculate table index by multiplying r with table scale and truncate to integer */
826 rt = _mm_mul_pd(r00,vftabscale);
827 vfitab = _mm_cvttpd_epi32(rt);
828 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
829 vfitab = _mm_slli_epi32(vfitab,3);
831 /* CUBIC SPLINE TABLE DISPERSION */
832 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
833 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
834 GMX_MM_TRANSPOSE2_PD(Y,F);
835 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
836 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
837 GMX_MM_TRANSPOSE2_PD(G,H);
838 Heps = _mm_mul_pd(vfeps,H);
839 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
840 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
841 fvdw6 = _mm_mul_pd(c6_00,FF);
843 /* CUBIC SPLINE TABLE REPULSION */
844 vfitab = _mm_add_epi32(vfitab,ifour);
845 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
846 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
847 GMX_MM_TRANSPOSE2_PD(Y,F);
848 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
849 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
850 GMX_MM_TRANSPOSE2_PD(G,H);
851 Heps = _mm_mul_pd(vfeps,H);
852 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
853 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
854 fvdw12 = _mm_mul_pd(c12_00,FF);
855 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
859 /* Calculate temporary vectorial force */
860 tx = _mm_mul_pd(fscal,dx00);
861 ty = _mm_mul_pd(fscal,dy00);
862 tz = _mm_mul_pd(fscal,dz00);
864 /* Update vectorial force */
865 fix0 = _mm_add_pd(fix0,tx);
866 fiy0 = _mm_add_pd(fiy0,ty);
867 fiz0 = _mm_add_pd(fiz0,tz);
869 fjx0 = _mm_add_pd(fjx0,tx);
870 fjy0 = _mm_add_pd(fjy0,ty);
871 fjz0 = _mm_add_pd(fjz0,tz);
873 /**************************
874 * CALCULATE INTERACTIONS *
875 **************************/
877 /* Compute parameters for interactions between i and j atoms */
878 qq10 = _mm_mul_pd(iq1,jq0);
880 /* COULOMB ELECTROSTATICS */
881 velec = _mm_mul_pd(qq10,rinv10);
882 felec = _mm_mul_pd(velec,rinvsq10);
886 /* Calculate temporary vectorial force */
887 tx = _mm_mul_pd(fscal,dx10);
888 ty = _mm_mul_pd(fscal,dy10);
889 tz = _mm_mul_pd(fscal,dz10);
891 /* Update vectorial force */
892 fix1 = _mm_add_pd(fix1,tx);
893 fiy1 = _mm_add_pd(fiy1,ty);
894 fiz1 = _mm_add_pd(fiz1,tz);
896 fjx0 = _mm_add_pd(fjx0,tx);
897 fjy0 = _mm_add_pd(fjy0,ty);
898 fjz0 = _mm_add_pd(fjz0,tz);
900 /**************************
901 * CALCULATE INTERACTIONS *
902 **************************/
904 /* Compute parameters for interactions between i and j atoms */
905 qq20 = _mm_mul_pd(iq2,jq0);
907 /* COULOMB ELECTROSTATICS */
908 velec = _mm_mul_pd(qq20,rinv20);
909 felec = _mm_mul_pd(velec,rinvsq20);
913 /* Calculate temporary vectorial force */
914 tx = _mm_mul_pd(fscal,dx20);
915 ty = _mm_mul_pd(fscal,dy20);
916 tz = _mm_mul_pd(fscal,dz20);
918 /* Update vectorial force */
919 fix2 = _mm_add_pd(fix2,tx);
920 fiy2 = _mm_add_pd(fiy2,ty);
921 fiz2 = _mm_add_pd(fiz2,tz);
923 fjx0 = _mm_add_pd(fjx0,tx);
924 fjy0 = _mm_add_pd(fjy0,ty);
925 fjz0 = _mm_add_pd(fjz0,tz);
927 /**************************
928 * CALCULATE INTERACTIONS *
929 **************************/
931 /* Compute parameters for interactions between i and j atoms */
932 qq30 = _mm_mul_pd(iq3,jq0);
934 /* COULOMB ELECTROSTATICS */
935 velec = _mm_mul_pd(qq30,rinv30);
936 felec = _mm_mul_pd(velec,rinvsq30);
940 /* Calculate temporary vectorial force */
941 tx = _mm_mul_pd(fscal,dx30);
942 ty = _mm_mul_pd(fscal,dy30);
943 tz = _mm_mul_pd(fscal,dz30);
945 /* Update vectorial force */
946 fix3 = _mm_add_pd(fix3,tx);
947 fiy3 = _mm_add_pd(fiy3,ty);
948 fiz3 = _mm_add_pd(fiz3,tz);
950 fjx0 = _mm_add_pd(fjx0,tx);
951 fjy0 = _mm_add_pd(fjy0,ty);
952 fjz0 = _mm_add_pd(fjz0,tz);
954 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
956 /* Inner loop uses 132 flops */
963 j_coord_offsetA = DIM*jnrA;
965 /* load j atom coordinates */
966 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
969 /* Calculate displacement vector */
970 dx00 = _mm_sub_pd(ix0,jx0);
971 dy00 = _mm_sub_pd(iy0,jy0);
972 dz00 = _mm_sub_pd(iz0,jz0);
973 dx10 = _mm_sub_pd(ix1,jx0);
974 dy10 = _mm_sub_pd(iy1,jy0);
975 dz10 = _mm_sub_pd(iz1,jz0);
976 dx20 = _mm_sub_pd(ix2,jx0);
977 dy20 = _mm_sub_pd(iy2,jy0);
978 dz20 = _mm_sub_pd(iz2,jz0);
979 dx30 = _mm_sub_pd(ix3,jx0);
980 dy30 = _mm_sub_pd(iy3,jy0);
981 dz30 = _mm_sub_pd(iz3,jz0);
983 /* Calculate squared distance and things based on it */
984 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
985 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
986 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
987 rsq30 = gmx_mm_calc_rsq_pd(dx30,dy30,dz30);
989 rinv00 = gmx_mm_invsqrt_pd(rsq00);
990 rinv10 = gmx_mm_invsqrt_pd(rsq10);
991 rinv20 = gmx_mm_invsqrt_pd(rsq20);
992 rinv30 = gmx_mm_invsqrt_pd(rsq30);
994 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
995 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
996 rinvsq30 = _mm_mul_pd(rinv30,rinv30);
998 /* Load parameters for j particles */
999 jq0 = _mm_load_sd(charge+jnrA+0);
1000 vdwjidx0A = 2*vdwtype[jnrA+0];
1002 fjx0 = _mm_setzero_pd();
1003 fjy0 = _mm_setzero_pd();
1004 fjz0 = _mm_setzero_pd();
1006 /**************************
1007 * CALCULATE INTERACTIONS *
1008 **************************/
1010 r00 = _mm_mul_pd(rsq00,rinv00);
1012 /* Compute parameters for interactions between i and j atoms */
1013 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
1015 /* Calculate table index by multiplying r with table scale and truncate to integer */
1016 rt = _mm_mul_pd(r00,vftabscale);
1017 vfitab = _mm_cvttpd_epi32(rt);
1018 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
1019 vfitab = _mm_slli_epi32(vfitab,3);
1021 /* CUBIC SPLINE TABLE DISPERSION */
1022 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
1023 F = _mm_setzero_pd();
1024 GMX_MM_TRANSPOSE2_PD(Y,F);
1025 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
1026 H = _mm_setzero_pd();
1027 GMX_MM_TRANSPOSE2_PD(G,H);
1028 Heps = _mm_mul_pd(vfeps,H);
1029 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
1030 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
1031 fvdw6 = _mm_mul_pd(c6_00,FF);
1033 /* CUBIC SPLINE TABLE REPULSION */
1034 vfitab = _mm_add_epi32(vfitab,ifour);
1035 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
1036 F = _mm_setzero_pd();
1037 GMX_MM_TRANSPOSE2_PD(Y,F);
1038 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
1039 H = _mm_setzero_pd();
1040 GMX_MM_TRANSPOSE2_PD(G,H);
1041 Heps = _mm_mul_pd(vfeps,H);
1042 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
1043 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
1044 fvdw12 = _mm_mul_pd(c12_00,FF);
1045 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
1049 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1051 /* Calculate temporary vectorial force */
1052 tx = _mm_mul_pd(fscal,dx00);
1053 ty = _mm_mul_pd(fscal,dy00);
1054 tz = _mm_mul_pd(fscal,dz00);
1056 /* Update vectorial force */
1057 fix0 = _mm_add_pd(fix0,tx);
1058 fiy0 = _mm_add_pd(fiy0,ty);
1059 fiz0 = _mm_add_pd(fiz0,tz);
1061 fjx0 = _mm_add_pd(fjx0,tx);
1062 fjy0 = _mm_add_pd(fjy0,ty);
1063 fjz0 = _mm_add_pd(fjz0,tz);
1065 /**************************
1066 * CALCULATE INTERACTIONS *
1067 **************************/
1069 /* Compute parameters for interactions between i and j atoms */
1070 qq10 = _mm_mul_pd(iq1,jq0);
1072 /* COULOMB ELECTROSTATICS */
1073 velec = _mm_mul_pd(qq10,rinv10);
1074 felec = _mm_mul_pd(velec,rinvsq10);
1078 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1080 /* Calculate temporary vectorial force */
1081 tx = _mm_mul_pd(fscal,dx10);
1082 ty = _mm_mul_pd(fscal,dy10);
1083 tz = _mm_mul_pd(fscal,dz10);
1085 /* Update vectorial force */
1086 fix1 = _mm_add_pd(fix1,tx);
1087 fiy1 = _mm_add_pd(fiy1,ty);
1088 fiz1 = _mm_add_pd(fiz1,tz);
1090 fjx0 = _mm_add_pd(fjx0,tx);
1091 fjy0 = _mm_add_pd(fjy0,ty);
1092 fjz0 = _mm_add_pd(fjz0,tz);
1094 /**************************
1095 * CALCULATE INTERACTIONS *
1096 **************************/
1098 /* Compute parameters for interactions between i and j atoms */
1099 qq20 = _mm_mul_pd(iq2,jq0);
1101 /* COULOMB ELECTROSTATICS */
1102 velec = _mm_mul_pd(qq20,rinv20);
1103 felec = _mm_mul_pd(velec,rinvsq20);
1107 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1109 /* Calculate temporary vectorial force */
1110 tx = _mm_mul_pd(fscal,dx20);
1111 ty = _mm_mul_pd(fscal,dy20);
1112 tz = _mm_mul_pd(fscal,dz20);
1114 /* Update vectorial force */
1115 fix2 = _mm_add_pd(fix2,tx);
1116 fiy2 = _mm_add_pd(fiy2,ty);
1117 fiz2 = _mm_add_pd(fiz2,tz);
1119 fjx0 = _mm_add_pd(fjx0,tx);
1120 fjy0 = _mm_add_pd(fjy0,ty);
1121 fjz0 = _mm_add_pd(fjz0,tz);
1123 /**************************
1124 * CALCULATE INTERACTIONS *
1125 **************************/
1127 /* Compute parameters for interactions between i and j atoms */
1128 qq30 = _mm_mul_pd(iq3,jq0);
1130 /* COULOMB ELECTROSTATICS */
1131 velec = _mm_mul_pd(qq30,rinv30);
1132 felec = _mm_mul_pd(velec,rinvsq30);
1136 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1138 /* Calculate temporary vectorial force */
1139 tx = _mm_mul_pd(fscal,dx30);
1140 ty = _mm_mul_pd(fscal,dy30);
1141 tz = _mm_mul_pd(fscal,dz30);
1143 /* Update vectorial force */
1144 fix3 = _mm_add_pd(fix3,tx);
1145 fiy3 = _mm_add_pd(fiy3,ty);
1146 fiz3 = _mm_add_pd(fiz3,tz);
1148 fjx0 = _mm_add_pd(fjx0,tx);
1149 fjy0 = _mm_add_pd(fjy0,ty);
1150 fjz0 = _mm_add_pd(fjz0,tz);
1152 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1154 /* Inner loop uses 132 flops */
1157 /* End of innermost loop */
1159 gmx_mm_update_iforce_4atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1160 f+i_coord_offset,fshift+i_shift_offset);
1162 /* Increment number of inner iterations */
1163 inneriter += j_index_end - j_index_start;
1165 /* Outer loop uses 24 flops */
1168 /* Increment number of outer iterations */
1171 /* Update outer/inner flops */
1173 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*132);