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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_avx_128_fma_double.h"
48 #include "kernelutil_x86_avx_128_fma_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_VF_avx_128_fma_double
52 * Electrostatics interaction: Coulomb
53 * VdW interaction: LennardJones
54 * Geometry: Water3-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_VF_avx_128_fma_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;
83 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
85 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
86 int vdwjidx0A,vdwjidx0B;
87 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
88 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
89 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
90 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
91 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
94 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
97 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
98 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
99 __m128d dummy_mask,cutoff_mask;
100 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
101 __m128d one = _mm_set1_pd(1.0);
102 __m128d two = _mm_set1_pd(2.0);
108 jindex = nlist->jindex;
110 shiftidx = nlist->shift;
112 shiftvec = fr->shift_vec[0];
113 fshift = fr->fshift[0];
114 facel = _mm_set1_pd(fr->epsfac);
115 charge = mdatoms->chargeA;
116 nvdwtype = fr->ntype;
118 vdwtype = mdatoms->typeA;
120 /* Setup water-specific parameters */
121 inr = nlist->iinr[0];
122 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
123 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
124 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
125 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
127 /* Avoid stupid compiler warnings */
135 /* Start outer loop over neighborlists */
136 for(iidx=0; iidx<nri; iidx++)
138 /* Load shift vector for this list */
139 i_shift_offset = DIM*shiftidx[iidx];
141 /* Load limits for loop over neighbors */
142 j_index_start = jindex[iidx];
143 j_index_end = jindex[iidx+1];
145 /* Get outer coordinate index */
147 i_coord_offset = DIM*inr;
149 /* Load i particle coords and add shift vector */
150 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
151 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
153 fix0 = _mm_setzero_pd();
154 fiy0 = _mm_setzero_pd();
155 fiz0 = _mm_setzero_pd();
156 fix1 = _mm_setzero_pd();
157 fiy1 = _mm_setzero_pd();
158 fiz1 = _mm_setzero_pd();
159 fix2 = _mm_setzero_pd();
160 fiy2 = _mm_setzero_pd();
161 fiz2 = _mm_setzero_pd();
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);
185 dx10 = _mm_sub_pd(ix1,jx0);
186 dy10 = _mm_sub_pd(iy1,jy0);
187 dz10 = _mm_sub_pd(iz1,jz0);
188 dx20 = _mm_sub_pd(ix2,jx0);
189 dy20 = _mm_sub_pd(iy2,jy0);
190 dz20 = _mm_sub_pd(iz2,jz0);
192 /* Calculate squared distance and things based on it */
193 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
194 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
195 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
197 rinv00 = gmx_mm_invsqrt_pd(rsq00);
198 rinv10 = gmx_mm_invsqrt_pd(rsq10);
199 rinv20 = gmx_mm_invsqrt_pd(rsq20);
201 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
202 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
203 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
205 /* Load parameters for j particles */
206 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
207 vdwjidx0A = 2*vdwtype[jnrA+0];
208 vdwjidx0B = 2*vdwtype[jnrB+0];
210 fjx0 = _mm_setzero_pd();
211 fjy0 = _mm_setzero_pd();
212 fjz0 = _mm_setzero_pd();
214 /**************************
215 * CALCULATE INTERACTIONS *
216 **************************/
218 /* Compute parameters for interactions between i and j atoms */
219 qq00 = _mm_mul_pd(iq0,jq0);
220 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
221 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
223 /* COULOMB ELECTROSTATICS */
224 velec = _mm_mul_pd(qq00,rinv00);
225 felec = _mm_mul_pd(velec,rinvsq00);
227 /* LENNARD-JONES DISPERSION/REPULSION */
229 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
230 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
231 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
232 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
233 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
235 /* Update potential sum for this i atom from the interaction with this j atom. */
236 velecsum = _mm_add_pd(velecsum,velec);
237 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
239 fscal = _mm_add_pd(felec,fvdw);
241 /* Update vectorial force */
242 fix0 = _mm_macc_pd(dx00,fscal,fix0);
243 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
244 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
246 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
247 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
248 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
250 /**************************
251 * CALCULATE INTERACTIONS *
252 **************************/
254 /* Compute parameters for interactions between i and j atoms */
255 qq10 = _mm_mul_pd(iq1,jq0);
257 /* COULOMB ELECTROSTATICS */
258 velec = _mm_mul_pd(qq10,rinv10);
259 felec = _mm_mul_pd(velec,rinvsq10);
261 /* Update potential sum for this i atom from the interaction with this j atom. */
262 velecsum = _mm_add_pd(velecsum,velec);
266 /* Update vectorial force */
267 fix1 = _mm_macc_pd(dx10,fscal,fix1);
268 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
269 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
271 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
272 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
273 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
275 /**************************
276 * CALCULATE INTERACTIONS *
277 **************************/
279 /* Compute parameters for interactions between i and j atoms */
280 qq20 = _mm_mul_pd(iq2,jq0);
282 /* COULOMB ELECTROSTATICS */
283 velec = _mm_mul_pd(qq20,rinv20);
284 felec = _mm_mul_pd(velec,rinvsq20);
286 /* Update potential sum for this i atom from the interaction with this j atom. */
287 velecsum = _mm_add_pd(velecsum,velec);
291 /* Update vectorial force */
292 fix2 = _mm_macc_pd(dx20,fscal,fix2);
293 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
294 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
296 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
297 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
298 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
300 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
302 /* Inner loop uses 108 flops */
309 j_coord_offsetA = DIM*jnrA;
311 /* load j atom coordinates */
312 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
315 /* Calculate displacement vector */
316 dx00 = _mm_sub_pd(ix0,jx0);
317 dy00 = _mm_sub_pd(iy0,jy0);
318 dz00 = _mm_sub_pd(iz0,jz0);
319 dx10 = _mm_sub_pd(ix1,jx0);
320 dy10 = _mm_sub_pd(iy1,jy0);
321 dz10 = _mm_sub_pd(iz1,jz0);
322 dx20 = _mm_sub_pd(ix2,jx0);
323 dy20 = _mm_sub_pd(iy2,jy0);
324 dz20 = _mm_sub_pd(iz2,jz0);
326 /* Calculate squared distance and things based on it */
327 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
328 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
329 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
331 rinv00 = gmx_mm_invsqrt_pd(rsq00);
332 rinv10 = gmx_mm_invsqrt_pd(rsq10);
333 rinv20 = gmx_mm_invsqrt_pd(rsq20);
335 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
336 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
337 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
339 /* Load parameters for j particles */
340 jq0 = _mm_load_sd(charge+jnrA+0);
341 vdwjidx0A = 2*vdwtype[jnrA+0];
343 fjx0 = _mm_setzero_pd();
344 fjy0 = _mm_setzero_pd();
345 fjz0 = _mm_setzero_pd();
347 /**************************
348 * CALCULATE INTERACTIONS *
349 **************************/
351 /* Compute parameters for interactions between i and j atoms */
352 qq00 = _mm_mul_pd(iq0,jq0);
353 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
355 /* COULOMB ELECTROSTATICS */
356 velec = _mm_mul_pd(qq00,rinv00);
357 felec = _mm_mul_pd(velec,rinvsq00);
359 /* LENNARD-JONES DISPERSION/REPULSION */
361 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
362 vvdw6 = _mm_mul_pd(c6_00,rinvsix);
363 vvdw12 = _mm_mul_pd(c12_00,_mm_mul_pd(rinvsix,rinvsix));
364 vvdw = _mm_msub_pd( vvdw12,one_twelfth, _mm_mul_pd(vvdw6,one_sixth) );
365 fvdw = _mm_mul_pd(_mm_sub_pd(vvdw12,vvdw6),rinvsq00);
367 /* Update potential sum for this i atom from the interaction with this j atom. */
368 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
369 velecsum = _mm_add_pd(velecsum,velec);
370 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
371 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
373 fscal = _mm_add_pd(felec,fvdw);
375 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
377 /* Update vectorial force */
378 fix0 = _mm_macc_pd(dx00,fscal,fix0);
379 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
380 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
382 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
383 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
384 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
386 /**************************
387 * CALCULATE INTERACTIONS *
388 **************************/
390 /* Compute parameters for interactions between i and j atoms */
391 qq10 = _mm_mul_pd(iq1,jq0);
393 /* COULOMB ELECTROSTATICS */
394 velec = _mm_mul_pd(qq10,rinv10);
395 felec = _mm_mul_pd(velec,rinvsq10);
397 /* Update potential sum for this i atom from the interaction with this j atom. */
398 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
399 velecsum = _mm_add_pd(velecsum,velec);
403 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
405 /* Update vectorial force */
406 fix1 = _mm_macc_pd(dx10,fscal,fix1);
407 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
408 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
410 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
411 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
412 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
414 /**************************
415 * CALCULATE INTERACTIONS *
416 **************************/
418 /* Compute parameters for interactions between i and j atoms */
419 qq20 = _mm_mul_pd(iq2,jq0);
421 /* COULOMB ELECTROSTATICS */
422 velec = _mm_mul_pd(qq20,rinv20);
423 felec = _mm_mul_pd(velec,rinvsq20);
425 /* Update potential sum for this i atom from the interaction with this j atom. */
426 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
427 velecsum = _mm_add_pd(velecsum,velec);
431 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
433 /* Update vectorial force */
434 fix2 = _mm_macc_pd(dx20,fscal,fix2);
435 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
436 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
438 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
439 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
440 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
442 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
444 /* Inner loop uses 108 flops */
447 /* End of innermost loop */
449 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
450 f+i_coord_offset,fshift+i_shift_offset);
453 /* Update potential energies */
454 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
455 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
457 /* Increment number of inner iterations */
458 inneriter += j_index_end - j_index_start;
460 /* Outer loop uses 20 flops */
463 /* Increment number of outer iterations */
466 /* Update outer/inner flops */
468 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*108);
471 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_avx_128_fma_double
472 * Electrostatics interaction: Coulomb
473 * VdW interaction: LennardJones
474 * Geometry: Water3-Particle
475 * Calculate force/pot: Force
478 nb_kernel_ElecCoul_VdwLJ_GeomW3P1_F_avx_128_fma_double
479 (t_nblist * gmx_restrict nlist,
480 rvec * gmx_restrict xx,
481 rvec * gmx_restrict ff,
482 t_forcerec * gmx_restrict fr,
483 t_mdatoms * gmx_restrict mdatoms,
484 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
485 t_nrnb * gmx_restrict nrnb)
487 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
488 * just 0 for non-waters.
489 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
490 * jnr indices corresponding to data put in the four positions in the SIMD register.
492 int i_shift_offset,i_coord_offset,outeriter,inneriter;
493 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
495 int j_coord_offsetA,j_coord_offsetB;
496 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
498 real *shiftvec,*fshift,*x,*f;
499 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
501 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
503 __m128d ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
505 __m128d ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
506 int vdwjidx0A,vdwjidx0B;
507 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
508 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
509 __m128d dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
510 __m128d dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
511 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
514 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
517 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
518 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
519 __m128d dummy_mask,cutoff_mask;
520 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
521 __m128d one = _mm_set1_pd(1.0);
522 __m128d two = _mm_set1_pd(2.0);
528 jindex = nlist->jindex;
530 shiftidx = nlist->shift;
532 shiftvec = fr->shift_vec[0];
533 fshift = fr->fshift[0];
534 facel = _mm_set1_pd(fr->epsfac);
535 charge = mdatoms->chargeA;
536 nvdwtype = fr->ntype;
538 vdwtype = mdatoms->typeA;
540 /* Setup water-specific parameters */
541 inr = nlist->iinr[0];
542 iq0 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+0]));
543 iq1 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
544 iq2 = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
545 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
547 /* Avoid stupid compiler warnings */
555 /* Start outer loop over neighborlists */
556 for(iidx=0; iidx<nri; iidx++)
558 /* Load shift vector for this list */
559 i_shift_offset = DIM*shiftidx[iidx];
561 /* Load limits for loop over neighbors */
562 j_index_start = jindex[iidx];
563 j_index_end = jindex[iidx+1];
565 /* Get outer coordinate index */
567 i_coord_offset = DIM*inr;
569 /* Load i particle coords and add shift vector */
570 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,
571 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
573 fix0 = _mm_setzero_pd();
574 fiy0 = _mm_setzero_pd();
575 fiz0 = _mm_setzero_pd();
576 fix1 = _mm_setzero_pd();
577 fiy1 = _mm_setzero_pd();
578 fiz1 = _mm_setzero_pd();
579 fix2 = _mm_setzero_pd();
580 fiy2 = _mm_setzero_pd();
581 fiz2 = _mm_setzero_pd();
583 /* Start inner kernel loop */
584 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
587 /* Get j neighbor index, and coordinate index */
590 j_coord_offsetA = DIM*jnrA;
591 j_coord_offsetB = DIM*jnrB;
593 /* load j atom coordinates */
594 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
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);
601 dx10 = _mm_sub_pd(ix1,jx0);
602 dy10 = _mm_sub_pd(iy1,jy0);
603 dz10 = _mm_sub_pd(iz1,jz0);
604 dx20 = _mm_sub_pd(ix2,jx0);
605 dy20 = _mm_sub_pd(iy2,jy0);
606 dz20 = _mm_sub_pd(iz2,jz0);
608 /* Calculate squared distance and things based on it */
609 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
610 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
611 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
613 rinv00 = gmx_mm_invsqrt_pd(rsq00);
614 rinv10 = gmx_mm_invsqrt_pd(rsq10);
615 rinv20 = gmx_mm_invsqrt_pd(rsq20);
617 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
618 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
619 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
621 /* Load parameters for j particles */
622 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
623 vdwjidx0A = 2*vdwtype[jnrA+0];
624 vdwjidx0B = 2*vdwtype[jnrB+0];
626 fjx0 = _mm_setzero_pd();
627 fjy0 = _mm_setzero_pd();
628 fjz0 = _mm_setzero_pd();
630 /**************************
631 * CALCULATE INTERACTIONS *
632 **************************/
634 /* Compute parameters for interactions between i and j atoms */
635 qq00 = _mm_mul_pd(iq0,jq0);
636 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
637 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
639 /* COULOMB ELECTROSTATICS */
640 velec = _mm_mul_pd(qq00,rinv00);
641 felec = _mm_mul_pd(velec,rinvsq00);
643 /* LENNARD-JONES DISPERSION/REPULSION */
645 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
646 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
648 fscal = _mm_add_pd(felec,fvdw);
650 /* Update vectorial force */
651 fix0 = _mm_macc_pd(dx00,fscal,fix0);
652 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
653 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
655 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
656 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
657 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
659 /**************************
660 * CALCULATE INTERACTIONS *
661 **************************/
663 /* Compute parameters for interactions between i and j atoms */
664 qq10 = _mm_mul_pd(iq1,jq0);
666 /* COULOMB ELECTROSTATICS */
667 velec = _mm_mul_pd(qq10,rinv10);
668 felec = _mm_mul_pd(velec,rinvsq10);
672 /* Update vectorial force */
673 fix1 = _mm_macc_pd(dx10,fscal,fix1);
674 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
675 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
677 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
678 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
679 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
681 /**************************
682 * CALCULATE INTERACTIONS *
683 **************************/
685 /* Compute parameters for interactions between i and j atoms */
686 qq20 = _mm_mul_pd(iq2,jq0);
688 /* COULOMB ELECTROSTATICS */
689 velec = _mm_mul_pd(qq20,rinv20);
690 felec = _mm_mul_pd(velec,rinvsq20);
694 /* Update vectorial force */
695 fix2 = _mm_macc_pd(dx20,fscal,fix2);
696 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
697 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
699 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
700 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
701 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
703 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
705 /* Inner loop uses 100 flops */
712 j_coord_offsetA = DIM*jnrA;
714 /* load j atom coordinates */
715 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
718 /* Calculate displacement vector */
719 dx00 = _mm_sub_pd(ix0,jx0);
720 dy00 = _mm_sub_pd(iy0,jy0);
721 dz00 = _mm_sub_pd(iz0,jz0);
722 dx10 = _mm_sub_pd(ix1,jx0);
723 dy10 = _mm_sub_pd(iy1,jy0);
724 dz10 = _mm_sub_pd(iz1,jz0);
725 dx20 = _mm_sub_pd(ix2,jx0);
726 dy20 = _mm_sub_pd(iy2,jy0);
727 dz20 = _mm_sub_pd(iz2,jz0);
729 /* Calculate squared distance and things based on it */
730 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
731 rsq10 = gmx_mm_calc_rsq_pd(dx10,dy10,dz10);
732 rsq20 = gmx_mm_calc_rsq_pd(dx20,dy20,dz20);
734 rinv00 = gmx_mm_invsqrt_pd(rsq00);
735 rinv10 = gmx_mm_invsqrt_pd(rsq10);
736 rinv20 = gmx_mm_invsqrt_pd(rsq20);
738 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
739 rinvsq10 = _mm_mul_pd(rinv10,rinv10);
740 rinvsq20 = _mm_mul_pd(rinv20,rinv20);
742 /* Load parameters for j particles */
743 jq0 = _mm_load_sd(charge+jnrA+0);
744 vdwjidx0A = 2*vdwtype[jnrA+0];
746 fjx0 = _mm_setzero_pd();
747 fjy0 = _mm_setzero_pd();
748 fjz0 = _mm_setzero_pd();
750 /**************************
751 * CALCULATE INTERACTIONS *
752 **************************/
754 /* Compute parameters for interactions between i and j atoms */
755 qq00 = _mm_mul_pd(iq0,jq0);
756 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
758 /* COULOMB ELECTROSTATICS */
759 velec = _mm_mul_pd(qq00,rinv00);
760 felec = _mm_mul_pd(velec,rinvsq00);
762 /* LENNARD-JONES DISPERSION/REPULSION */
764 rinvsix = _mm_mul_pd(_mm_mul_pd(rinvsq00,rinvsq00),rinvsq00);
765 fvdw = _mm_mul_pd(_mm_msub_pd(c12_00,rinvsix,c6_00),_mm_mul_pd(rinvsix,rinvsq00));
767 fscal = _mm_add_pd(felec,fvdw);
769 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
771 /* Update vectorial force */
772 fix0 = _mm_macc_pd(dx00,fscal,fix0);
773 fiy0 = _mm_macc_pd(dy00,fscal,fiy0);
774 fiz0 = _mm_macc_pd(dz00,fscal,fiz0);
776 fjx0 = _mm_macc_pd(dx00,fscal,fjx0);
777 fjy0 = _mm_macc_pd(dy00,fscal,fjy0);
778 fjz0 = _mm_macc_pd(dz00,fscal,fjz0);
780 /**************************
781 * CALCULATE INTERACTIONS *
782 **************************/
784 /* Compute parameters for interactions between i and j atoms */
785 qq10 = _mm_mul_pd(iq1,jq0);
787 /* COULOMB ELECTROSTATICS */
788 velec = _mm_mul_pd(qq10,rinv10);
789 felec = _mm_mul_pd(velec,rinvsq10);
793 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
795 /* Update vectorial force */
796 fix1 = _mm_macc_pd(dx10,fscal,fix1);
797 fiy1 = _mm_macc_pd(dy10,fscal,fiy1);
798 fiz1 = _mm_macc_pd(dz10,fscal,fiz1);
800 fjx0 = _mm_macc_pd(dx10,fscal,fjx0);
801 fjy0 = _mm_macc_pd(dy10,fscal,fjy0);
802 fjz0 = _mm_macc_pd(dz10,fscal,fjz0);
804 /**************************
805 * CALCULATE INTERACTIONS *
806 **************************/
808 /* Compute parameters for interactions between i and j atoms */
809 qq20 = _mm_mul_pd(iq2,jq0);
811 /* COULOMB ELECTROSTATICS */
812 velec = _mm_mul_pd(qq20,rinv20);
813 felec = _mm_mul_pd(velec,rinvsq20);
817 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
819 /* Update vectorial force */
820 fix2 = _mm_macc_pd(dx20,fscal,fix2);
821 fiy2 = _mm_macc_pd(dy20,fscal,fiy2);
822 fiz2 = _mm_macc_pd(dz20,fscal,fiz2);
824 fjx0 = _mm_macc_pd(dx20,fscal,fjx0);
825 fjy0 = _mm_macc_pd(dy20,fscal,fjy0);
826 fjz0 = _mm_macc_pd(dz20,fscal,fjz0);
828 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,fjx0,fjy0,fjz0);
830 /* Inner loop uses 100 flops */
833 /* End of innermost loop */
835 gmx_mm_update_iforce_3atom_swizzle_pd(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
836 f+i_coord_offset,fshift+i_shift_offset);
838 /* Increment number of inner iterations */
839 inneriter += j_index_end - j_index_start;
841 /* Outer loop uses 18 flops */
844 /* Increment number of outer iterations */
847 /* Update outer/inner flops */
849 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*100);