2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017, 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.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_sse4_1_double.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_VF_sse4_1_double
51 * Electrostatics interaction: Coulomb
52 * VdW interaction: LennardJones
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_VF_sse4_1_double
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 struct t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67 * just 0 for non-waters.
68 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
69 * jnr indices corresponding to data put in the four positions in the SIMD register.
71 int i_shift_offset,i_coord_offset,outeriter,inneriter;
72 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74 int j_coord_offsetA,j_coord_offsetB;
75 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
77 real *shiftvec,*fshift,*x,*f;
78 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
80 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
82 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
84 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
85 int vdwjidx0A,vdwjidx0B;
86 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
87 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
88 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
89 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
90 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
93 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
96 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
97 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
98 __m128d dummy_mask,cutoff_mask;
99 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
100 __m128d one = _mm_set1_pd(1.0);
101 __m128d two = _mm_set1_pd(2.0);
107 jindex = nlist->jindex;
109 shiftidx = nlist->shift;
111 shiftvec = fr->shift_vec[0];
112 fshift = fr->fshift[0];
113 facel = _mm_set1_pd(fr->ic->epsfac);
114 charge = mdatoms->chargeA;
115 nvdwtype = fr->ntype;
117 vdwtype = mdatoms->typeA;
119 /* Setup water-specific parameters */
120 inr = nlist->iinr[0];
121 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
122 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
123 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
124 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
126 /* Avoid stupid compiler warnings */
134 /* Start outer loop over neighborlists */
135 for(iidx=0; iidx<nri; iidx++)
137 /* Load shift vector for this list */
138 i_shift_offset = DIM*shiftidx[iidx];
140 /* Load limits for loop over neighbors */
141 j_index_start = jindex[iidx];
142 j_index_end = jindex[iidx+1];
144 /* Get outer coordinate index */
146 i_coord_offset = DIM*inr;
148 /* Load i particle coords and add shift vector */
149 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
150 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
152 fix0 = _mm_setzero_pd();
153 fiy0 = _mm_setzero_pd();
154 fiz0 = _mm_setzero_pd();
155 fix1 = _mm_setzero_pd();
156 fiy1 = _mm_setzero_pd();
157 fiz1 = _mm_setzero_pd();
158 fix2 = _mm_setzero_pd();
159 fiy2 = _mm_setzero_pd();
160 fiz2 = _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);
191 /* Calculate squared distance and things based on it */
192 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
193 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
194 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
196 rinv00 = sse41_invsqrt_d(rsq00);
197 rinv10 = sse41_invsqrt_d(rsq10);
198 rinv20 = sse41_invsqrt_d(rsq20);
200 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
201 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
202 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
204 /* Load parameters for j particles */
205 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
206 vdwjidx0A = 2*vdwtype[jnrA+0];
207 vdwjidx0B = 2*vdwtype[jnrB+0];
209 fjx0 = _mm_setzero_pd();
210 fjy0 = _mm_setzero_pd();
211 fjz0 = _mm_setzero_pd();
213 /**************************
214 * CALCULATE INTERACTIONS *
215 **************************/
217 /* Compute parameters for interactions between i and j atoms */
218 qq00 = _mm_mul_pd(iq0,jq0);
219 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
220 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
222 /* COULOMB ELECTROSTATICS */
223 velec = _mm_mul_pd(qq00,rinv00);
224 felec = _mm_mul_pd(velec,rinvsq00);
226 /* LENNARD-JONES DISPERSION/REPULSION */
228 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
229 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
230 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
231 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
232 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
234 /* Update potential sum for this i atom from the interaction with this j atom. */
235 velecsum = _mm_add_pd(velecsum,velec);
236 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
238 fscal = _mm_add_pd(felec,fvdw);
240 /* Calculate temporary vectorial force */
241 tx = _mm_mul_pd(fscal,dx00);
242 ty = _mm_mul_pd(fscal,dy00);
243 tz = _mm_mul_pd(fscal,dz00);
245 /* Update vectorial force */
246 fix0 = _mm_add_pd(fix0,tx);
247 fiy0 = _mm_add_pd(fiy0,ty);
248 fiz0 = _mm_add_pd(fiz0,tz);
250 fjx0 = _mm_add_pd(fjx0,tx);
251 fjy0 = _mm_add_pd(fjy0,ty);
252 fjz0 = _mm_add_pd(fjz0,tz);
254 /**************************
255 * CALCULATE INTERACTIONS *
256 **************************/
258 /* Compute parameters for interactions between i and j atoms */
259 qq10 = _mm_mul_pd(iq1,jq0);
261 /* COULOMB ELECTROSTATICS */
262 velec = _mm_mul_pd(qq10,rinv10);
263 felec = _mm_mul_pd(velec,rinvsq10);
265 /* Update potential sum for this i atom from the interaction with this j atom. */
266 velecsum = _mm_add_pd(velecsum,velec);
270 /* Calculate temporary vectorial force */
271 tx = _mm_mul_pd(fscal,dx10);
272 ty = _mm_mul_pd(fscal,dy10);
273 tz = _mm_mul_pd(fscal,dz10);
275 /* Update vectorial force */
276 fix1 = _mm_add_pd(fix1,tx);
277 fiy1 = _mm_add_pd(fiy1,ty);
278 fiz1 = _mm_add_pd(fiz1,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 qq20 = _mm_mul_pd(iq2,jq0);
291 /* COULOMB ELECTROSTATICS */
292 velec = _mm_mul_pd(qq20,rinv20);
293 felec = _mm_mul_pd(velec,rinvsq20);
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,dx20);
302 ty = _mm_mul_pd(fscal,dy20);
303 tz = _mm_mul_pd(fscal,dz20);
305 /* Update vectorial force */
306 fix2 = _mm_add_pd(fix2,tx);
307 fiy2 = _mm_add_pd(fiy2,ty);
308 fiz2 = _mm_add_pd(fiz2,tz);
310 fjx0 = _mm_add_pd(fjx0,tx);
311 fjy0 = _mm_add_pd(fjy0,ty);
312 fjz0 = _mm_add_pd(fjz0,tz);
314 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
316 /* Inner loop uses 99 flops */
323 j_coord_offsetA = DIM*jnrA;
325 /* load j atom coordinates */
326 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
329 /* Calculate displacement vector */
330 dx00 = _mm_sub_pd(ix0,jx0);
331 dy00 = _mm_sub_pd(iy0,jy0);
332 dz00 = _mm_sub_pd(iz0,jz0);
333 dx10 = _mm_sub_pd(ix1,jx0);
334 dy10 = _mm_sub_pd(iy1,jy0);
335 dz10 = _mm_sub_pd(iz1,jz0);
336 dx20 = _mm_sub_pd(ix2,jx0);
337 dy20 = _mm_sub_pd(iy2,jy0);
338 dz20 = _mm_sub_pd(iz2,jz0);
340 /* Calculate squared distance and things based on it */
341 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
342 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
343 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
345 rinv00 = sse41_invsqrt_d(rsq00);
346 rinv10 = sse41_invsqrt_d(rsq10);
347 rinv20 = sse41_invsqrt_d(rsq20);
349 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
350 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
351 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
353 /* Load parameters for j particles */
354 jq0 = _mm_load_sd(charge+jnrA+0);
355 vdwjidx0A = 2*vdwtype[jnrA+0];
357 fjx0 = _mm_setzero_pd();
358 fjy0 = _mm_setzero_pd();
359 fjz0 = _mm_setzero_pd();
361 /**************************
362 * CALCULATE INTERACTIONS *
363 **************************/
365 /* Compute parameters for interactions between i and j atoms */
366 qq00 = _mm_mul_pd(iq0,jq0);
367 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
369 /* COULOMB ELECTROSTATICS */
370 velec = _mm_mul_pd(qq00,rinv00);
371 felec = _mm_mul_pd(velec,rinvsq00);
373 /* LENNARD-JONES DISPERSION/REPULSION */
375 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
376 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
377 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
378 vvdw = _mm_sub_pd( _mm_mul_pd(vvdw12,one_twelfth) , _mm_mul_pd(vvdw6,one_sixth) );
379 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
381 /* Update potential sum for this i atom from the interaction with this j atom. */
382 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
383 velecsum = _mm_add_pd(velecsum,velec);
384 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
385 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
387 fscal = _mm_add_pd(felec,fvdw);
389 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
391 /* Calculate temporary vectorial force */
392 tx = _mm_mul_pd(fscal,dx00);
393 ty = _mm_mul_pd(fscal,dy00);
394 tz = _mm_mul_pd(fscal,dz00);
396 /* Update vectorial force */
397 fix0 = _mm_add_pd(fix0,tx);
398 fiy0 = _mm_add_pd(fiy0,ty);
399 fiz0 = _mm_add_pd(fiz0,tz);
401 fjx0 = _mm_add_pd(fjx0,tx);
402 fjy0 = _mm_add_pd(fjy0,ty);
403 fjz0 = _mm_add_pd(fjz0,tz);
405 /**************************
406 * CALCULATE INTERACTIONS *
407 **************************/
409 /* Compute parameters for interactions between i and j atoms */
410 qq10 = _mm_mul_pd(iq1,jq0);
412 /* COULOMB ELECTROSTATICS */
413 velec = _mm_mul_pd(qq10,rinv10);
414 felec = _mm_mul_pd(velec,rinvsq10);
416 /* Update potential sum for this i atom from the interaction with this j atom. */
417 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
418 velecsum = _mm_add_pd(velecsum,velec);
422 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
424 /* Calculate temporary vectorial force */
425 tx = _mm_mul_pd(fscal,dx10);
426 ty = _mm_mul_pd(fscal,dy10);
427 tz = _mm_mul_pd(fscal,dz10);
429 /* Update vectorial force */
430 fix1 = _mm_add_pd(fix1,tx);
431 fiy1 = _mm_add_pd(fiy1,ty);
432 fiz1 = _mm_add_pd(fiz1,tz);
434 fjx0 = _mm_add_pd(fjx0,tx);
435 fjy0 = _mm_add_pd(fjy0,ty);
436 fjz0 = _mm_add_pd(fjz0,tz);
438 /**************************
439 * CALCULATE INTERACTIONS *
440 **************************/
442 /* Compute parameters for interactions between i and j atoms */
443 qq20 = _mm_mul_pd(iq2,jq0);
445 /* COULOMB ELECTROSTATICS */
446 velec = _mm_mul_pd(qq20,rinv20);
447 felec = _mm_mul_pd(velec,rinvsq20);
449 /* Update potential sum for this i atom from the interaction with this j atom. */
450 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
451 velecsum = _mm_add_pd(velecsum,velec);
455 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
457 /* Calculate temporary vectorial force */
458 tx = _mm_mul_pd(fscal,dx20);
459 ty = _mm_mul_pd(fscal,dy20);
460 tz = _mm_mul_pd(fscal,dz20);
462 /* Update vectorial force */
463 fix2 = _mm_add_pd(fix2,tx);
464 fiy2 = _mm_add_pd(fiy2,ty);
465 fiz2 = _mm_add_pd(fiz2,tz);
467 fjx0 = _mm_add_pd(fjx0,tx);
468 fjy0 = _mm_add_pd(fjy0,ty);
469 fjz0 = _mm_add_pd(fjz0,tz);
471 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
473 /* Inner loop uses 99 flops */
476 /* End of innermost loop */
478 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
479 f+i_coord_offset,fshift+i_shift_offset);
482 /* Update potential energies */
483 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
484 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
486 /* Increment number of inner iterations */
487 inneriter += j_index_end - j_index_start;
489 /* Outer loop uses 20 flops */
492 /* Increment number of outer iterations */
495 /* Update outer/inner flops */
497 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*99);
500 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_sse4_1_double
501 * Electrostatics interaction: Coulomb
502 * VdW interaction: LennardJones
503 * Geometry: Water3-Particle
504 * Calculate force/pot: Force
507 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_sse4_1_double
508 (t_nblist * gmx_restrict nlist,
509 rvec * gmx_restrict xx,
510 rvec * gmx_restrict ff,
511 struct t_forcerec * gmx_restrict fr,
512 t_mdatoms * gmx_restrict mdatoms,
513 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
514 t_nrnb * gmx_restrict nrnb)
516 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
517 * just 0 for non-waters.
518 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
519 * jnr indices corresponding to data put in the four positions in the SIMD register.
521 int i_shift_offset,i_coord_offset,outeriter,inneriter;
522 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
524 int j_coord_offsetA,j_coord_offsetB;
525 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
527 real *shiftvec,*fshift,*x,*f;
528 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
530 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
532 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
534 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
535 int vdwjidx0A,vdwjidx0B;
536 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
537 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
538 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
539 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
540 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
543 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
546 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
547 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
548 __m128d dummy_mask,cutoff_mask;
549 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
550 __m128d one = _mm_set1_pd(1.0);
551 __m128d two = _mm_set1_pd(2.0);
557 jindex = nlist->jindex;
559 shiftidx = nlist->shift;
561 shiftvec = fr->shift_vec[0];
562 fshift = fr->fshift[0];
563 facel = _mm_set1_pd(fr->ic->epsfac);
564 charge = mdatoms->chargeA;
565 nvdwtype = fr->ntype;
567 vdwtype = mdatoms->typeA;
569 /* Setup water-specific parameters */
570 inr = nlist->iinr[0];
571 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
572 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
573 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
574 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
576 /* Avoid stupid compiler warnings */
584 /* Start outer loop over neighborlists */
585 for(iidx=0; iidx<nri; iidx++)
587 /* Load shift vector for this list */
588 i_shift_offset = DIM*shiftidx[iidx];
590 /* Load limits for loop over neighbors */
591 j_index_start = jindex[iidx];
592 j_index_end = jindex[iidx+1];
594 /* Get outer coordinate index */
596 i_coord_offset = DIM*inr;
598 /* Load i particle coords and add shift vector */
599 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
600 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
602 fix0 = _mm_setzero_pd();
603 fiy0 = _mm_setzero_pd();
604 fiz0 = _mm_setzero_pd();
605 fix1 = _mm_setzero_pd();
606 fiy1 = _mm_setzero_pd();
607 fiz1 = _mm_setzero_pd();
608 fix2 = _mm_setzero_pd();
609 fiy2 = _mm_setzero_pd();
610 fiz2 = _mm_setzero_pd();
612 /* Start inner kernel loop */
613 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
616 /* Get j neighbor index, and coordinate index */
619 j_coord_offsetA = DIM*jnrA;
620 j_coord_offsetB = DIM*jnrB;
622 /* load j atom coordinates */
623 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
626 /* Calculate displacement vector */
627 dx00 = _mm_sub_pd(ix0,jx0);
628 dy00 = _mm_sub_pd(iy0,jy0);
629 dz00 = _mm_sub_pd(iz0,jz0);
630 dx10 = _mm_sub_pd(ix1,jx0);
631 dy10 = _mm_sub_pd(iy1,jy0);
632 dz10 = _mm_sub_pd(iz1,jz0);
633 dx20 = _mm_sub_pd(ix2,jx0);
634 dy20 = _mm_sub_pd(iy2,jy0);
635 dz20 = _mm_sub_pd(iz2,jz0);
637 /* Calculate squared distance and things based on it */
638 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
639 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
640 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
642 rinv00 = sse41_invsqrt_d(rsq00);
643 rinv10 = sse41_invsqrt_d(rsq10);
644 rinv20 = sse41_invsqrt_d(rsq20);
646 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
647 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
648 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
650 /* Load parameters for j particles */
651 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
652 vdwjidx0A = 2*vdwtype[jnrA+0];
653 vdwjidx0B = 2*vdwtype[jnrB+0];
655 fjx0 = _mm_setzero_pd();
656 fjy0 = _mm_setzero_pd();
657 fjz0 = _mm_setzero_pd();
659 /**************************
660 * CALCULATE INTERACTIONS *
661 **************************/
663 /* Compute parameters for interactions between i and j atoms */
664 qq00 = _mm_mul_pd(iq0,jq0);
665 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
666 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
668 /* COULOMB ELECTROSTATICS */
669 velec = _mm_mul_pd(qq00,rinv00);
670 felec = _mm_mul_pd(velec,rinvsq00);
672 /* LENNARD-JONES DISPERSION/REPULSION */
674 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
675 fvdw = _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00,rinvsix),c6_00),_mm_mul_pd(rinvsix,rinvsq00));
677 fscal = _mm_add_pd(felec,fvdw);
679 /* Calculate temporary vectorial force */
680 tx = _mm_mul_pd(fscal,dx00);
681 ty = _mm_mul_pd(fscal,dy00);
682 tz = _mm_mul_pd(fscal,dz00);
684 /* Update vectorial force */
685 fix0 = _mm_add_pd(fix0,tx);
686 fiy0 = _mm_add_pd(fiy0,ty);
687 fiz0 = _mm_add_pd(fiz0,tz);
689 fjx0 = _mm_add_pd(fjx0,tx);
690 fjy0 = _mm_add_pd(fjy0,ty);
691 fjz0 = _mm_add_pd(fjz0,tz);
693 /**************************
694 * CALCULATE INTERACTIONS *
695 **************************/
697 /* Compute parameters for interactions between i and j atoms */
698 qq10 = _mm_mul_pd(iq1,jq0);
700 /* COULOMB ELECTROSTATICS */
701 velec = _mm_mul_pd(qq10,rinv10);
702 felec = _mm_mul_pd(velec,rinvsq10);
706 /* Calculate temporary vectorial force */
707 tx = _mm_mul_pd(fscal,dx10);
708 ty = _mm_mul_pd(fscal,dy10);
709 tz = _mm_mul_pd(fscal,dz10);
711 /* Update vectorial force */
712 fix1 = _mm_add_pd(fix1,tx);
713 fiy1 = _mm_add_pd(fiy1,ty);
714 fiz1 = _mm_add_pd(fiz1,tz);
716 fjx0 = _mm_add_pd(fjx0,tx);
717 fjy0 = _mm_add_pd(fjy0,ty);
718 fjz0 = _mm_add_pd(fjz0,tz);
720 /**************************
721 * CALCULATE INTERACTIONS *
722 **************************/
724 /* Compute parameters for interactions between i and j atoms */
725 qq20 = _mm_mul_pd(iq2,jq0);
727 /* COULOMB ELECTROSTATICS */
728 velec = _mm_mul_pd(qq20,rinv20);
729 felec = _mm_mul_pd(velec,rinvsq20);
733 /* Calculate temporary vectorial force */
734 tx = _mm_mul_pd(fscal,dx20);
735 ty = _mm_mul_pd(fscal,dy20);
736 tz = _mm_mul_pd(fscal,dz20);
738 /* Update vectorial force */
739 fix2 = _mm_add_pd(fix2,tx);
740 fiy2 = _mm_add_pd(fiy2,ty);
741 fiz2 = _mm_add_pd(fiz2,tz);
743 fjx0 = _mm_add_pd(fjx0,tx);
744 fjy0 = _mm_add_pd(fjy0,ty);
745 fjz0 = _mm_add_pd(fjz0,tz);
747 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
749 /* Inner loop uses 91 flops */
756 j_coord_offsetA = DIM*jnrA;
758 /* load j atom coordinates */
759 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
762 /* Calculate displacement vector */
763 dx00 = _mm_sub_pd(ix0,jx0);
764 dy00 = _mm_sub_pd(iy0,jy0);
765 dz00 = _mm_sub_pd(iz0,jz0);
766 dx10 = _mm_sub_pd(ix1,jx0);
767 dy10 = _mm_sub_pd(iy1,jy0);
768 dz10 = _mm_sub_pd(iz1,jz0);
769 dx20 = _mm_sub_pd(ix2,jx0);
770 dy20 = _mm_sub_pd(iy2,jy0);
771 dz20 = _mm_sub_pd(iz2,jz0);
773 /* Calculate squared distance and things based on it */
774 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
775 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
776 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
778 rinv00 = sse41_invsqrt_d(rsq00);
779 rinv10 = sse41_invsqrt_d(rsq10);
780 rinv20 = sse41_invsqrt_d(rsq20);
782 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
783 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
784 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
786 /* Load parameters for j particles */
787 jq0 = _mm_load_sd(charge+jnrA+0);
788 vdwjidx0A = 2*vdwtype[jnrA+0];
790 fjx0 = _mm_setzero_pd();
791 fjy0 = _mm_setzero_pd();
792 fjz0 = _mm_setzero_pd();
794 /**************************
795 * CALCULATE INTERACTIONS *
796 **************************/
798 /* Compute parameters for interactions between i and j atoms */
799 qq00 = _mm_mul_pd(iq0,jq0);
800 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
802 /* COULOMB ELECTROSTATICS */
803 velec = _mm_mul_pd(qq00,rinv00);
804 felec = _mm_mul_pd(velec,rinvsq00);
806 /* LENNARD-JONES DISPERSION/REPULSION */
808 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
809 fvdw = _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00,rinvsix),c6_00),_mm_mul_pd(rinvsix,rinvsq00));
811 fscal = _mm_add_pd(felec,fvdw);
813 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
815 /* Calculate temporary vectorial force */
816 tx = _mm_mul_pd(fscal,dx00);
817 ty = _mm_mul_pd(fscal,dy00);
818 tz = _mm_mul_pd(fscal,dz00);
820 /* Update vectorial force */
821 fix0 = _mm_add_pd(fix0,tx);
822 fiy0 = _mm_add_pd(fiy0,ty);
823 fiz0 = _mm_add_pd(fiz0,tz);
825 fjx0 = _mm_add_pd(fjx0,tx);
826 fjy0 = _mm_add_pd(fjy0,ty);
827 fjz0 = _mm_add_pd(fjz0,tz);
829 /**************************
830 * CALCULATE INTERACTIONS *
831 **************************/
833 /* Compute parameters for interactions between i and j atoms */
834 qq10 = _mm_mul_pd(iq1,jq0);
836 /* COULOMB ELECTROSTATICS */
837 velec = _mm_mul_pd(qq10,rinv10);
838 felec = _mm_mul_pd(velec,rinvsq10);
842 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
844 /* Calculate temporary vectorial force */
845 tx = _mm_mul_pd(fscal,dx10);
846 ty = _mm_mul_pd(fscal,dy10);
847 tz = _mm_mul_pd(fscal,dz10);
849 /* Update vectorial force */
850 fix1 = _mm_add_pd(fix1,tx);
851 fiy1 = _mm_add_pd(fiy1,ty);
852 fiz1 = _mm_add_pd(fiz1,tz);
854 fjx0 = _mm_add_pd(fjx0,tx);
855 fjy0 = _mm_add_pd(fjy0,ty);
856 fjz0 = _mm_add_pd(fjz0,tz);
858 /**************************
859 * CALCULATE INTERACTIONS *
860 **************************/
862 /* Compute parameters for interactions between i and j atoms */
863 qq20 = _mm_mul_pd(iq2,jq0);
865 /* COULOMB ELECTROSTATICS */
866 velec = _mm_mul_pd(qq20,rinv20);
867 felec = _mm_mul_pd(velec,rinvsq20);
871 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
873 /* Calculate temporary vectorial force */
874 tx = _mm_mul_pd(fscal,dx20);
875 ty = _mm_mul_pd(fscal,dy20);
876 tz = _mm_mul_pd(fscal,dz20);
878 /* Update vectorial force */
879 fix2 = _mm_add_pd(fix2,tx);
880 fiy2 = _mm_add_pd(fiy2,ty);
881 fiz2 = _mm_add_pd(fiz2,tz);
883 fjx0 = _mm_add_pd(fjx0,tx);
884 fjy0 = _mm_add_pd(fjy0,ty);
885 fjz0 = _mm_add_pd(fjz0,tz);
887 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
889 /* Inner loop uses 91 flops */
892 /* End of innermost loop */
894 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
895 f+i_coord_offset,fshift+i_shift_offset);
897 /* Increment number of inner iterations */
898 inneriter += j_index_end - j_index_start;
900 /* Outer loop uses 18 flops */
903 /* Increment number of outer iterations */
906 /* Update outer/inner flops */
908 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*91);