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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_sse2_double.h"
48 #include "kernelutil_x86_sse2_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomP1P1_VF_sse2_double
52 * Electrostatics interaction: Ewald
53 * VdW interaction: LennardJones
54 * Geometry: Particle-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecEwSh_VdwLJSh_GeomP1P1_VF_sse2_double
59 (t_nblist * gmx_restrict nlist,
60 rvec * gmx_restrict xx,
61 rvec * gmx_restrict ff,
62 t_forcerec * gmx_restrict fr,
63 t_mdatoms * gmx_restrict mdatoms,
64 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65 t_nrnb * gmx_restrict nrnb)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
70 * jnr indices corresponding to data put in the four positions in the SIMD register.
72 int i_shift_offset,i_coord_offset,outeriter,inneriter;
73 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
75 int j_coord_offsetA,j_coord_offsetB;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
81 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
82 int vdwjidx0A,vdwjidx0B;
83 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
84 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
85 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
88 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
91 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
92 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
94 __m128d ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
96 __m128d dummy_mask,cutoff_mask;
97 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
98 __m128d one = _mm_set1_pd(1.0);
99 __m128d two = _mm_set1_pd(2.0);
105 jindex = nlist->jindex;
107 shiftidx = nlist->shift;
109 shiftvec = fr->shift_vec[0];
110 fshift = fr->fshift[0];
111 facel = _mm_set1_pd(fr->epsfac);
112 charge = mdatoms->chargeA;
113 nvdwtype = fr->ntype;
115 vdwtype = mdatoms->typeA;
117 sh_ewald = _mm_set1_pd(fr->ic->sh_ewald);
118 ewtab = fr->ic->tabq_coul_FDV0;
119 ewtabscale = _mm_set1_pd(fr->ic->tabq_scale);
120 ewtabhalfspace = _mm_set1_pd(0.5/fr->ic->tabq_scale);
122 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
123 rcutoff_scalar = fr->rcoulomb;
124 rcutoff = _mm_set1_pd(rcutoff_scalar);
125 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
127 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
128 rvdw = _mm_set1_pd(fr->rvdw);
130 /* Avoid stupid compiler warnings */
138 /* Start outer loop over neighborlists */
139 for(iidx=0; iidx<nri; iidx++)
141 /* Load shift vector for this list */
142 i_shift_offset = DIM*shiftidx[iidx];
144 /* Load limits for loop over neighbors */
145 j_index_start = jindex[iidx];
146 j_index_end = jindex[iidx+1];
148 /* Get outer coordinate index */
150 i_coord_offset = DIM*inr;
152 /* Load i particle coords and add shift vector */
153 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
155 fix0 = _mm_setzero_pd();
156 fiy0 = _mm_setzero_pd();
157 fiz0 = _mm_setzero_pd();
159 /* Load parameters for i particles */
160 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
161 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
163 /* Reset potential sums */
164 velecsum = _mm_setzero_pd();
165 vvdwsum = _mm_setzero_pd();
167 /* Start inner kernel loop */
168 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
171 /* Get j neighbor index, and coordinate index */
174 j_coord_offsetA = DIM*jnrA;
175 j_coord_offsetB = DIM*jnrB;
177 /* load j atom coordinates */
178 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
181 /* Calculate displacement vector */
182 dx00 = _mm_sub_pd(ix0,jx0);
183 dy00 = _mm_sub_pd(iy0,jy0);
184 dz00 = _mm_sub_pd(iz0,jz0);
186 /* Calculate squared distance and things based on it */
187 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
189 rinv00 = gmx_mm_invsqrt_pd(rsq00);
191 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
193 /* Load parameters for j particles */
194 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
195 vdwjidx0A = 2*vdwtype[jnrA+0];
196 vdwjidx0B = 2*vdwtype[jnrB+0];
198 /**************************
199 * CALCULATE INTERACTIONS *
200 **************************/
202 if (gmx_mm_any_lt(rsq00,rcutoff2))
205 r00 = _mm_mul_pd(rsq00,rinv00);
207 /* Compute parameters for interactions between i and j atoms */
208 qq00 = _mm_mul_pd(iq0,jq0);
209 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
210 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
212 /* EWALD ELECTROSTATICS */
214 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
215 ewrt = _mm_mul_pd(r00,ewtabscale);
216 ewitab = _mm_cvttpd_epi32(ewrt);
217 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
218 ewitab = _mm_slli_epi32(ewitab,2);
219 ewtabF = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
220 ewtabD = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,1) );
221 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
222 ewtabV = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
223 ewtabFn = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,1) +2);
224 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
225 felec = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
226 velec = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
227 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_sub_pd(rinv00,sh_ewald),velec));
228 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
230 /* LENNARD-JONES DISPERSION/REPULSION */
232 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
233 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
234 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
235 vvdw = _mm_sub_pd(_mm_mul_pd( _mm_sub_pd(vvdw12 , _mm_mul_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6))), one_twelfth) ,
236 _mm_mul_pd( _mm_sub_pd(vvdw6,_mm_mul_pd(c6_00,sh_vdw_invrcut6)),one_sixth));
237 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
239 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
241 /* Update potential sum for this i atom from the interaction with this j atom. */
242 velec = _mm_and_pd(velec,cutoff_mask);
243 velecsum = _mm_add_pd(velecsum,velec);
244 vvdw = _mm_and_pd(vvdw,cutoff_mask);
245 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
247 fscal = _mm_add_pd(felec,fvdw);
249 fscal = _mm_and_pd(fscal,cutoff_mask);
251 /* Calculate temporary vectorial force */
252 tx = _mm_mul_pd(fscal,dx00);
253 ty = _mm_mul_pd(fscal,dy00);
254 tz = _mm_mul_pd(fscal,dz00);
256 /* Update vectorial force */
257 fix0 = _mm_add_pd(fix0,tx);
258 fiy0 = _mm_add_pd(fiy0,ty);
259 fiz0 = _mm_add_pd(fiz0,tz);
261 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
265 /* Inner loop uses 64 flops */
272 j_coord_offsetA = DIM*jnrA;
274 /* load j atom coordinates */
275 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
278 /* Calculate displacement vector */
279 dx00 = _mm_sub_pd(ix0,jx0);
280 dy00 = _mm_sub_pd(iy0,jy0);
281 dz00 = _mm_sub_pd(iz0,jz0);
283 /* Calculate squared distance and things based on it */
284 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
286 rinv00 = gmx_mm_invsqrt_pd(rsq00);
288 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
290 /* Load parameters for j particles */
291 jq0 = _mm_load_sd(charge+jnrA+0);
292 vdwjidx0A = 2*vdwtype[jnrA+0];
294 /**************************
295 * CALCULATE INTERACTIONS *
296 **************************/
298 if (gmx_mm_any_lt(rsq00,rcutoff2))
301 r00 = _mm_mul_pd(rsq00,rinv00);
303 /* Compute parameters for interactions between i and j atoms */
304 qq00 = _mm_mul_pd(iq0,jq0);
305 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
307 /* EWALD ELECTROSTATICS */
309 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
310 ewrt = _mm_mul_pd(r00,ewtabscale);
311 ewitab = _mm_cvttpd_epi32(ewrt);
312 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
313 ewitab = _mm_slli_epi32(ewitab,2);
314 ewtabF = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
315 ewtabD = _mm_setzero_pd();
316 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
317 ewtabV = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
318 ewtabFn = _mm_setzero_pd();
319 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
320 felec = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
321 velec = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
322 velec = _mm_mul_pd(qq00,_mm_sub_pd(_mm_sub_pd(rinv00,sh_ewald),velec));
323 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
325 /* LENNARD-JONES DISPERSION/REPULSION */
327 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
328 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
329 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
330 vvdw = _mm_sub_pd(_mm_mul_pd( _mm_sub_pd(vvdw12 , _mm_mul_pd(c12_00,_mm_mul_pd(sh_vdw_invrcut6,sh_vdw_invrcut6))), one_twelfth) ,
331 _mm_mul_pd( _mm_sub_pd(vvdw6,_mm_mul_pd(c6_00,sh_vdw_invrcut6)),one_sixth));
332 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
334 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
336 /* Update potential sum for this i atom from the interaction with this j atom. */
337 velec = _mm_and_pd(velec,cutoff_mask);
338 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
339 velecsum = _mm_add_pd(velecsum,velec);
340 vvdw = _mm_and_pd(vvdw,cutoff_mask);
341 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
342 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
344 fscal = _mm_add_pd(felec,fvdw);
346 fscal = _mm_and_pd(fscal,cutoff_mask);
348 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
350 /* Calculate temporary vectorial force */
351 tx = _mm_mul_pd(fscal,dx00);
352 ty = _mm_mul_pd(fscal,dy00);
353 tz = _mm_mul_pd(fscal,dz00);
355 /* Update vectorial force */
356 fix0 = _mm_add_pd(fix0,tx);
357 fiy0 = _mm_add_pd(fiy0,ty);
358 fiz0 = _mm_add_pd(fiz0,tz);
360 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
364 /* Inner loop uses 64 flops */
367 /* End of innermost loop */
369 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
370 f+i_coord_offset,fshift+i_shift_offset);
373 /* Update potential energies */
374 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
375 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
377 /* Increment number of inner iterations */
378 inneriter += j_index_end - j_index_start;
380 /* Outer loop uses 9 flops */
383 /* Increment number of outer iterations */
386 /* Update outer/inner flops */
388 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*64);
391 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomP1P1_F_sse2_double
392 * Electrostatics interaction: Ewald
393 * VdW interaction: LennardJones
394 * Geometry: Particle-Particle
395 * Calculate force/pot: Force
398 nb_kernel_ElecEwSh_VdwLJSh_GeomP1P1_F_sse2_double
399 (t_nblist * gmx_restrict nlist,
400 rvec * gmx_restrict xx,
401 rvec * gmx_restrict ff,
402 t_forcerec * gmx_restrict fr,
403 t_mdatoms * gmx_restrict mdatoms,
404 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
405 t_nrnb * gmx_restrict nrnb)
407 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
408 * just 0 for non-waters.
409 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
410 * jnr indices corresponding to data put in the four positions in the SIMD register.
412 int i_shift_offset,i_coord_offset,outeriter,inneriter;
413 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
415 int j_coord_offsetA,j_coord_offsetB;
416 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
418 real *shiftvec,*fshift,*x,*f;
419 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
421 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
422 int vdwjidx0A,vdwjidx0B;
423 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
424 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
425 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
428 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
431 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
432 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
434 __m128d ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
436 __m128d dummy_mask,cutoff_mask;
437 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
438 __m128d one = _mm_set1_pd(1.0);
439 __m128d two = _mm_set1_pd(2.0);
445 jindex = nlist->jindex;
447 shiftidx = nlist->shift;
449 shiftvec = fr->shift_vec[0];
450 fshift = fr->fshift[0];
451 facel = _mm_set1_pd(fr->epsfac);
452 charge = mdatoms->chargeA;
453 nvdwtype = fr->ntype;
455 vdwtype = mdatoms->typeA;
457 sh_ewald = _mm_set1_pd(fr->ic->sh_ewald);
458 ewtab = fr->ic->tabq_coul_F;
459 ewtabscale = _mm_set1_pd(fr->ic->tabq_scale);
460 ewtabhalfspace = _mm_set1_pd(0.5/fr->ic->tabq_scale);
462 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
463 rcutoff_scalar = fr->rcoulomb;
464 rcutoff = _mm_set1_pd(rcutoff_scalar);
465 rcutoff2 = _mm_mul_pd(rcutoff,rcutoff);
467 sh_vdw_invrcut6 = _mm_set1_pd(fr->ic->sh_invrc6);
468 rvdw = _mm_set1_pd(fr->rvdw);
470 /* Avoid stupid compiler warnings */
478 /* Start outer loop over neighborlists */
479 for(iidx=0; iidx<nri; iidx++)
481 /* Load shift vector for this list */
482 i_shift_offset = DIM*shiftidx[iidx];
484 /* Load limits for loop over neighbors */
485 j_index_start = jindex[iidx];
486 j_index_end = jindex[iidx+1];
488 /* Get outer coordinate index */
490 i_coord_offset = DIM*inr;
492 /* Load i particle coords and add shift vector */
493 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
495 fix0 = _mm_setzero_pd();
496 fiy0 = _mm_setzero_pd();
497 fiz0 = _mm_setzero_pd();
499 /* Load parameters for i particles */
500 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
501 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
503 /* Start inner kernel loop */
504 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
507 /* Get j neighbor index, and coordinate index */
510 j_coord_offsetA = DIM*jnrA;
511 j_coord_offsetB = DIM*jnrB;
513 /* load j atom coordinates */
514 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
517 /* Calculate displacement vector */
518 dx00 = _mm_sub_pd(ix0,jx0);
519 dy00 = _mm_sub_pd(iy0,jy0);
520 dz00 = _mm_sub_pd(iz0,jz0);
522 /* Calculate squared distance and things based on it */
523 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
525 rinv00 = gmx_mm_invsqrt_pd(rsq00);
527 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
529 /* Load parameters for j particles */
530 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
531 vdwjidx0A = 2*vdwtype[jnrA+0];
532 vdwjidx0B = 2*vdwtype[jnrB+0];
534 /**************************
535 * CALCULATE INTERACTIONS *
536 **************************/
538 if (gmx_mm_any_lt(rsq00,rcutoff2))
541 r00 = _mm_mul_pd(rsq00,rinv00);
543 /* Compute parameters for interactions between i and j atoms */
544 qq00 = _mm_mul_pd(iq0,jq0);
545 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
546 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
548 /* EWALD ELECTROSTATICS */
550 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
551 ewrt = _mm_mul_pd(r00,ewtabscale);
552 ewitab = _mm_cvttpd_epi32(ewrt);
553 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
554 gmx_mm_load_2pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),ewtab+gmx_mm_extract_epi32(ewitab,1),
556 felec = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
557 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
559 /* LENNARD-JONES DISPERSION/REPULSION */
561 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
562 fvdw = _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00,rinvsix),c6_00),_mm_mul_pd(rinvsix,rinvsq00));
564 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
566 fscal = _mm_add_pd(felec,fvdw);
568 fscal = _mm_and_pd(fscal,cutoff_mask);
570 /* Calculate temporary vectorial force */
571 tx = _mm_mul_pd(fscal,dx00);
572 ty = _mm_mul_pd(fscal,dy00);
573 tz = _mm_mul_pd(fscal,dz00);
575 /* Update vectorial force */
576 fix0 = _mm_add_pd(fix0,tx);
577 fiy0 = _mm_add_pd(fiy0,ty);
578 fiz0 = _mm_add_pd(fiz0,tz);
580 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
584 /* Inner loop uses 46 flops */
591 j_coord_offsetA = DIM*jnrA;
593 /* load j atom coordinates */
594 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
597 /* Calculate displacement vector */
598 dx00 = _mm_sub_pd(ix0,jx0);
599 dy00 = _mm_sub_pd(iy0,jy0);
600 dz00 = _mm_sub_pd(iz0,jz0);
602 /* Calculate squared distance and things based on it */
603 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
605 rinv00 = gmx_mm_invsqrt_pd(rsq00);
607 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
609 /* Load parameters for j particles */
610 jq0 = _mm_load_sd(charge+jnrA+0);
611 vdwjidx0A = 2*vdwtype[jnrA+0];
613 /**************************
614 * CALCULATE INTERACTIONS *
615 **************************/
617 if (gmx_mm_any_lt(rsq00,rcutoff2))
620 r00 = _mm_mul_pd(rsq00,rinv00);
622 /* Compute parameters for interactions between i and j atoms */
623 qq00 = _mm_mul_pd(iq0,jq0);
624 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
626 /* EWALD ELECTROSTATICS */
628 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
629 ewrt = _mm_mul_pd(r00,ewtabscale);
630 ewitab = _mm_cvttpd_epi32(ewrt);
631 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
632 gmx_mm_load_1pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),&ewtabF,&ewtabFn);
633 felec = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
634 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
636 /* LENNARD-JONES DISPERSION/REPULSION */
638 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
639 fvdw = _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00,rinvsix),c6_00),_mm_mul_pd(rinvsix,rinvsq00));
641 cutoff_mask = _mm_cmplt_pd(rsq00,rcutoff2);
643 fscal = _mm_add_pd(felec,fvdw);
645 fscal = _mm_and_pd(fscal,cutoff_mask);
647 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
649 /* Calculate temporary vectorial force */
650 tx = _mm_mul_pd(fscal,dx00);
651 ty = _mm_mul_pd(fscal,dy00);
652 tz = _mm_mul_pd(fscal,dz00);
654 /* Update vectorial force */
655 fix0 = _mm_add_pd(fix0,tx);
656 fiy0 = _mm_add_pd(fiy0,ty);
657 fiz0 = _mm_add_pd(fiz0,tz);
659 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
663 /* Inner loop uses 46 flops */
666 /* End of innermost loop */
668 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
669 f+i_coord_offset,fshift+i_shift_offset);
671 /* Increment number of inner iterations */
672 inneriter += j_index_end - j_index_start;
674 /* Outer loop uses 7 flops */
677 /* Increment number of outer iterations */
680 /* Update outer/inner flops */
682 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*46);