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 avx_128_fma_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_avx_128_fma_double.h"
50 #include "kernelutil_x86_avx_128_fma_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_VF_avx_128_fma_double
54 * Electrostatics interaction: Coulomb
55 * VdW interaction: LennardJones
56 * Geometry: Water3-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_VF_avx_128_fma_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;
88 int vdwjidx0A,vdwjidx0B;
89 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
90 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
91 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
92 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
93 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
96 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
99 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
100 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
101 __m128d dummy_mask,cutoff_mask;
102 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
103 __m128d one = _mm_set1_pd(1.0);
104 __m128d two = _mm_set1_pd(2.0);
110 jindex = nlist->jindex;
112 shiftidx = nlist->shift;
114 shiftvec = fr->shift_vec[0];
115 fshift = fr->fshift[0];
116 facel = _mm_set1_pd(fr->epsfac);
117 charge = mdatoms->chargeA;
118 nvdwtype = fr->ntype;
120 vdwtype = mdatoms->typeA;
122 /* Setup water-specific parameters */
123 inr = nlist->iinr[0];
124 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
125 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
126 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
127 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
129 /* Avoid stupid compiler warnings */
137 /* Start outer loop over neighborlists */
138 for(iidx=0; iidx<nri; iidx++)
140 /* Load shift vector for this list */
141 i_shift_offset = DIM*shiftidx[iidx];
143 /* Load limits for loop over neighbors */
144 j_index_start = jindex[iidx];
145 j_index_end = jindex[iidx+1];
147 /* Get outer coordinate index */
149 i_coord_offset = DIM*inr;
151 /* Load i particle coords and add shift vector */
152 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
153 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
155 fix0 = _mm_setzero_pd();
156 fiy0 = _mm_setzero_pd();
157 fiz0 = _mm_setzero_pd();
158 fix1 = _mm_setzero_pd();
159 fiy1 = _mm_setzero_pd();
160 fiz1 = _mm_setzero_pd();
161 fix2 = _mm_setzero_pd();
162 fiy2 = _mm_setzero_pd();
163 fiz2 = _mm_setzero_pd();
165 /* Reset potential sums */
166 velecsum = _mm_setzero_pd();
167 vvdwsum = _mm_setzero_pd();
169 /* Start inner kernel loop */
170 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
173 /* Get j neighbor index, and coordinate index */
176 j_coord_offsetA = DIM*jnrA;
177 j_coord_offsetB = DIM*jnrB;
179 /* load j atom coordinates */
180 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
183 /* Calculate displacement vector */
184 dx00 = _mm_sub_pd(ix0,jx0);
185 dy00 = _mm_sub_pd(iy0,jy0);
186 dz00 = _mm_sub_pd(iz0,jz0);
187 dx10 = _mm_sub_pd(ix1,jx0);
188 dy10 = _mm_sub_pd(iy1,jy0);
189 dz10 = _mm_sub_pd(iz1,jz0);
190 dx20 = _mm_sub_pd(ix2,jx0);
191 dy20 = _mm_sub_pd(iy2,jy0);
192 dz20 = _mm_sub_pd(iz2,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);
199 rinv00 = gmx_mm_invsqrt_pd(rsq00);
200 rinv10 = gmx_mm_invsqrt_pd(rsq10);
201 rinv20 = gmx_mm_invsqrt_pd(rsq20);
203 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
204 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
205 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
207 /* Load parameters for j particles */
208 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
209 vdwjidx0A = 2*vdwtype[jnrA+0];
210 vdwjidx0B = 2*vdwtype[jnrB+0];
212 fjx0 = _mm_setzero_pd();
213 fjy0 = _mm_setzero_pd();
214 fjz0 = _mm_setzero_pd();
216 /**************************
217 * CALCULATE INTERACTIONS *
218 **************************/
220 /* Compute parameters for interactions between i and j atoms */
221 qq00 = _mm_mul_pd(iq0,jq0);
222 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
223 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
225 /* COULOMB ELECTROSTATICS */
226 velec = _mm_mul_pd(qq00,rinv00);
227 felec = _mm_mul_pd(velec,rinvsq00);
229 /* LENNARD-JONES DISPERSION/REPULSION */
231 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
232 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
233 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
234 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
235 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
237 /* Update potential sum for this i atom from the interaction with this j atom. */
238 velecsum = _mm_add_pd(velecsum,velec);
239 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
241 fscal = _mm_add_pd(felec,fvdw);
243 /* Update vectorial force */
244 fix0 = _mm_macc_pd(dx00,fscal,fix0);
245 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
246 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
248 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
249 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
250 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
252 /**************************
253 * CALCULATE INTERACTIONS *
254 **************************/
256 /* Compute parameters for interactions between i and j atoms */
257 qq10 = _mm_mul_pd(iq1,jq0);
259 /* COULOMB ELECTROSTATICS */
260 velec = _mm_mul_pd(qq10,rinv10);
261 felec = _mm_mul_pd(velec,rinvsq10);
263 /* Update potential sum for this i atom from the interaction with this j atom. */
264 velecsum = _mm_add_pd(velecsum,velec);
268 /* Update vectorial force */
269 fix1 = _mm_macc_pd(dx10,fscal,fix1);
270 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
271 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
273 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
274 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
275 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
277 /**************************
278 * CALCULATE INTERACTIONS *
279 **************************/
281 /* Compute parameters for interactions between i and j atoms */
282 qq20 = _mm_mul_pd(iq2,jq0);
284 /* COULOMB ELECTROSTATICS */
285 velec = _mm_mul_pd(qq20,rinv20);
286 felec = _mm_mul_pd(velec,rinvsq20);
288 /* Update potential sum for this i atom from the interaction with this j atom. */
289 velecsum = _mm_add_pd(velecsum,velec);
293 /* Update vectorial force */
294 fix2 = _mm_macc_pd(dx20,fscal,fix2);
295 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
296 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
298 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
299 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
300 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
302 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
304 /* Inner loop uses 108 flops */
311 j_coord_offsetA = DIM*jnrA;
313 /* load j atom coordinates */
314 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
317 /* Calculate displacement vector */
318 dx00 = _mm_sub_pd(ix0,jx0);
319 dy00 = _mm_sub_pd(iy0,jy0);
320 dz00 = _mm_sub_pd(iz0,jz0);
321 dx10 = _mm_sub_pd(ix1,jx0);
322 dy10 = _mm_sub_pd(iy1,jy0);
323 dz10 = _mm_sub_pd(iz1,jz0);
324 dx20 = _mm_sub_pd(ix2,jx0);
325 dy20 = _mm_sub_pd(iy2,jy0);
326 dz20 = _mm_sub_pd(iz2,jz0);
328 /* Calculate squared distance and things based on it */
329 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
330 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
331 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
333 rinv00 = gmx_mm_invsqrt_pd(rsq00);
334 rinv10 = gmx_mm_invsqrt_pd(rsq10);
335 rinv20 = gmx_mm_invsqrt_pd(rsq20);
337 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
338 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
339 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
341 /* Load parameters for j particles */
342 jq0 = _mm_load_sd(charge+jnrA+0);
343 vdwjidx0A = 2*vdwtype[jnrA+0];
345 fjx0 = _mm_setzero_pd();
346 fjy0 = _mm_setzero_pd();
347 fjz0 = _mm_setzero_pd();
349 /**************************
350 * CALCULATE INTERACTIONS *
351 **************************/
353 /* Compute parameters for interactions between i and j atoms */
354 qq00 = _mm_mul_pd(iq0,jq0);
355 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
357 /* COULOMB ELECTROSTATICS */
358 velec = _mm_mul_pd(qq00,rinv00);
359 felec = _mm_mul_pd(velec,rinvsq00);
361 /* LENNARD-JONES DISPERSION/REPULSION */
363 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
364 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
365 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
366 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
367 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
369 /* Update potential sum for this i atom from the interaction with this j atom. */
370 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
371 velecsum = _mm_add_pd(velecsum,velec);
372 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
373 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
375 fscal = _mm_add_pd(felec,fvdw);
377 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
379 /* Update vectorial force */
380 fix0 = _mm_macc_pd(dx00,fscal,fix0);
381 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
382 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
384 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
385 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
386 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
388 /**************************
389 * CALCULATE INTERACTIONS *
390 **************************/
392 /* Compute parameters for interactions between i and j atoms */
393 qq10 = _mm_mul_pd(iq1,jq0);
395 /* COULOMB ELECTROSTATICS */
396 velec = _mm_mul_pd(qq10,rinv10);
397 felec = _mm_mul_pd(velec,rinvsq10);
399 /* Update potential sum for this i atom from the interaction with this j atom. */
400 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
401 velecsum = _mm_add_pd(velecsum,velec);
405 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
407 /* Update vectorial force */
408 fix1 = _mm_macc_pd(dx10,fscal,fix1);
409 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
410 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
412 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
413 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
414 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
416 /**************************
417 * CALCULATE INTERACTIONS *
418 **************************/
420 /* Compute parameters for interactions between i and j atoms */
421 qq20 = _mm_mul_pd(iq2,jq0);
423 /* COULOMB ELECTROSTATICS */
424 velec = _mm_mul_pd(qq20,rinv20);
425 felec = _mm_mul_pd(velec,rinvsq20);
427 /* Update potential sum for this i atom from the interaction with this j atom. */
428 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
429 velecsum = _mm_add_pd(velecsum,velec);
433 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
435 /* Update vectorial force */
436 fix2 = _mm_macc_pd(dx20,fscal,fix2);
437 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
438 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
440 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
441 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
442 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
444 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
446 /* Inner loop uses 108 flops */
449 /* End of innermost loop */
451 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
452 f+i_coord_offset,fshift+i_shift_offset);
455 /* Update potential energies */
456 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
457 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
459 /* Increment number of inner iterations */
460 inneriter += j_index_end - j_index_start;
462 /* Outer loop uses 20 flops */
465 /* Increment number of outer iterations */
468 /* Update outer/inner flops */
470 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*108);
473 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_avx_128_fma_double
474 * Electrostatics interaction: Coulomb
475 * VdW interaction: LennardJones
476 * Geometry: Water3-Particle
477 * Calculate force/pot: Force
480 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_avx_128_fma_double
481 (t_nblist * gmx_restrict nlist,
482 rvec * gmx_restrict xx,
483 rvec * gmx_restrict ff,
484 t_forcerec * gmx_restrict fr,
485 t_mdatoms * gmx_restrict mdatoms,
486 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
487 t_nrnb * gmx_restrict nrnb)
489 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
490 * just 0 for non-waters.
491 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
492 * jnr indices corresponding to data put in the four positions in the SIMD register.
494 int i_shift_offset,i_coord_offset,outeriter,inneriter;
495 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
497 int j_coord_offsetA,j_coord_offsetB;
498 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
500 real *shiftvec,*fshift,*x,*f;
501 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
503 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
505 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
507 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
508 int vdwjidx0A,vdwjidx0B;
509 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
510 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
511 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
512 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
513 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
516 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
519 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
520 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
521 __m128d dummy_mask,cutoff_mask;
522 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
523 __m128d one = _mm_set1_pd(1.0);
524 __m128d two = _mm_set1_pd(2.0);
530 jindex = nlist->jindex;
532 shiftidx = nlist->shift;
534 shiftvec = fr->shift_vec[0];
535 fshift = fr->fshift[0];
536 facel = _mm_set1_pd(fr->epsfac);
537 charge = mdatoms->chargeA;
538 nvdwtype = fr->ntype;
540 vdwtype = mdatoms->typeA;
542 /* Setup water-specific parameters */
543 inr = nlist->iinr[0];
544 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
545 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
546 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
547 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
549 /* Avoid stupid compiler warnings */
557 /* Start outer loop over neighborlists */
558 for(iidx=0; iidx<nri; iidx++)
560 /* Load shift vector for this list */
561 i_shift_offset = DIM*shiftidx[iidx];
563 /* Load limits for loop over neighbors */
564 j_index_start = jindex[iidx];
565 j_index_end = jindex[iidx+1];
567 /* Get outer coordinate index */
569 i_coord_offset = DIM*inr;
571 /* Load i particle coords and add shift vector */
572 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
573 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
575 fix0 = _mm_setzero_pd();
576 fiy0 = _mm_setzero_pd();
577 fiz0 = _mm_setzero_pd();
578 fix1 = _mm_setzero_pd();
579 fiy1 = _mm_setzero_pd();
580 fiz1 = _mm_setzero_pd();
581 fix2 = _mm_setzero_pd();
582 fiy2 = _mm_setzero_pd();
583 fiz2 = _mm_setzero_pd();
585 /* Start inner kernel loop */
586 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
589 /* Get j neighbor index, and coordinate index */
592 j_coord_offsetA = DIM*jnrA;
593 j_coord_offsetB = DIM*jnrB;
595 /* load j atom coordinates */
596 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
599 /* Calculate displacement vector */
600 dx00 = _mm_sub_pd(ix0,jx0);
601 dy00 = _mm_sub_pd(iy0,jy0);
602 dz00 = _mm_sub_pd(iz0,jz0);
603 dx10 = _mm_sub_pd(ix1,jx0);
604 dy10 = _mm_sub_pd(iy1,jy0);
605 dz10 = _mm_sub_pd(iz1,jz0);
606 dx20 = _mm_sub_pd(ix2,jx0);
607 dy20 = _mm_sub_pd(iy2,jy0);
608 dz20 = _mm_sub_pd(iz2,jz0);
610 /* Calculate squared distance and things based on it */
611 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
612 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
613 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
615 rinv00 = gmx_mm_invsqrt_pd(rsq00);
616 rinv10 = gmx_mm_invsqrt_pd(rsq10);
617 rinv20 = gmx_mm_invsqrt_pd(rsq20);
619 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
620 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
621 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
623 /* Load parameters for j particles */
624 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
625 vdwjidx0A = 2*vdwtype[jnrA+0];
626 vdwjidx0B = 2*vdwtype[jnrB+0];
628 fjx0 = _mm_setzero_pd();
629 fjy0 = _mm_setzero_pd();
630 fjz0 = _mm_setzero_pd();
632 /**************************
633 * CALCULATE INTERACTIONS *
634 **************************/
636 /* Compute parameters for interactions between i and j atoms */
637 qq00 = _mm_mul_pd(iq0,jq0);
638 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
639 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
641 /* COULOMB ELECTROSTATICS */
642 velec = _mm_mul_pd(qq00,rinv00);
643 felec = _mm_mul_pd(velec,rinvsq00);
645 /* LENNARD-JONES DISPERSION/REPULSION */
647 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
648 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
650 fscal = _mm_add_pd(felec,fvdw);
652 /* Update vectorial force */
653 fix0 = _mm_macc_pd(dx00,fscal,fix0);
654 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
655 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
657 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
658 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
659 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
661 /**************************
662 * CALCULATE INTERACTIONS *
663 **************************/
665 /* Compute parameters for interactions between i and j atoms */
666 qq10 = _mm_mul_pd(iq1,jq0);
668 /* COULOMB ELECTROSTATICS */
669 velec = _mm_mul_pd(qq10,rinv10);
670 felec = _mm_mul_pd(velec,rinvsq10);
674 /* Update vectorial force */
675 fix1 = _mm_macc_pd(dx10,fscal,fix1);
676 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
677 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
679 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
680 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
681 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
683 /**************************
684 * CALCULATE INTERACTIONS *
685 **************************/
687 /* Compute parameters for interactions between i and j atoms */
688 qq20 = _mm_mul_pd(iq2,jq0);
690 /* COULOMB ELECTROSTATICS */
691 velec = _mm_mul_pd(qq20,rinv20);
692 felec = _mm_mul_pd(velec,rinvsq20);
696 /* Update vectorial force */
697 fix2 = _mm_macc_pd(dx20,fscal,fix2);
698 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
699 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
701 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
702 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
703 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
705 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
707 /* Inner loop uses 100 flops */
714 j_coord_offsetA = DIM*jnrA;
716 /* load j atom coordinates */
717 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
720 /* Calculate displacement vector */
721 dx00 = _mm_sub_pd(ix0,jx0);
722 dy00 = _mm_sub_pd(iy0,jy0);
723 dz00 = _mm_sub_pd(iz0,jz0);
724 dx10 = _mm_sub_pd(ix1,jx0);
725 dy10 = _mm_sub_pd(iy1,jy0);
726 dz10 = _mm_sub_pd(iz1,jz0);
727 dx20 = _mm_sub_pd(ix2,jx0);
728 dy20 = _mm_sub_pd(iy2,jy0);
729 dz20 = _mm_sub_pd(iz2,jz0);
731 /* Calculate squared distance and things based on it */
732 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
733 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
734 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
736 rinv00 = gmx_mm_invsqrt_pd(rsq00);
737 rinv10 = gmx_mm_invsqrt_pd(rsq10);
738 rinv20 = gmx_mm_invsqrt_pd(rsq20);
740 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
741 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
742 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
744 /* Load parameters for j particles */
745 jq0 = _mm_load_sd(charge+jnrA+0);
746 vdwjidx0A = 2*vdwtype[jnrA+0];
748 fjx0 = _mm_setzero_pd();
749 fjy0 = _mm_setzero_pd();
750 fjz0 = _mm_setzero_pd();
752 /**************************
753 * CALCULATE INTERACTIONS *
754 **************************/
756 /* Compute parameters for interactions between i and j atoms */
757 qq00 = _mm_mul_pd(iq0,jq0);
758 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
760 /* COULOMB ELECTROSTATICS */
761 velec = _mm_mul_pd(qq00,rinv00);
762 felec = _mm_mul_pd(velec,rinvsq00);
764 /* LENNARD-JONES DISPERSION/REPULSION */
766 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
767 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
769 fscal = _mm_add_pd(felec,fvdw);
771 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
773 /* Update vectorial force */
774 fix0 = _mm_macc_pd(dx00,fscal,fix0);
775 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
776 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
778 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
779 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
780 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
782 /**************************
783 * CALCULATE INTERACTIONS *
784 **************************/
786 /* Compute parameters for interactions between i and j atoms */
787 qq10 = _mm_mul_pd(iq1,jq0);
789 /* COULOMB ELECTROSTATICS */
790 velec = _mm_mul_pd(qq10,rinv10);
791 felec = _mm_mul_pd(velec,rinvsq10);
795 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
797 /* Update vectorial force */
798 fix1 = _mm_macc_pd(dx10,fscal,fix1);
799 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
800 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
802 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
803 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
804 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
806 /**************************
807 * CALCULATE INTERACTIONS *
808 **************************/
810 /* Compute parameters for interactions between i and j atoms */
811 qq20 = _mm_mul_pd(iq2,jq0);
813 /* COULOMB ELECTROSTATICS */
814 velec = _mm_mul_pd(qq20,rinv20);
815 felec = _mm_mul_pd(velec,rinvsq20);
819 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
821 /* Update vectorial force */
822 fix2 = _mm_macc_pd(dx20,fscal,fix2);
823 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
824 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
826 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
827 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
828 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
830 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
832 /* Inner loop uses 100 flops */
835 /* End of innermost loop */
837 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
838 f+i_coord_offset,fshift+i_shift_offset);
840 /* Increment number of inner iterations */
841 inneriter += j_index_end - j_index_start;
843 /* Outer loop uses 18 flops */
846 /* Increment number of outer iterations */
849 /* Update outer/inner flops */
851 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*100);