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 sse2_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_sse2_double.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_VF_sse2_double
51 * Electrostatics interaction: Coulomb
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_VF_sse2_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
;
86 __m128d ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
87 int vdwjidx0A
,vdwjidx0B
;
88 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
89 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
90 __m128d dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
91 __m128d dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
92 __m128d dx30
,dy30
,dz30
,rsq30
,rinv30
,rinvsq30
,r30
,qq30
,c6_30
,c12_30
;
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
->ic
->epsfac
);
117 charge
= mdatoms
->chargeA
;
118 nvdwtype
= fr
->ntype
;
120 vdwtype
= mdatoms
->typeA
;
122 /* Setup water-specific parameters */
123 inr
= nlist
->iinr
[0];
124 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
125 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
126 iq3
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+3]));
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_4rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
153 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
,&ix3
,&iy3
,&iz3
);
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();
164 fix3
= _mm_setzero_pd();
165 fiy3
= _mm_setzero_pd();
166 fiz3
= _mm_setzero_pd();
168 /* Reset potential sums */
169 velecsum
= _mm_setzero_pd();
170 vvdwsum
= _mm_setzero_pd();
172 /* Start inner kernel loop */
173 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
176 /* Get j neighbor index, and coordinate index */
179 j_coord_offsetA
= DIM
*jnrA
;
180 j_coord_offsetB
= DIM
*jnrB
;
182 /* load j atom coordinates */
183 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
186 /* Calculate displacement vector */
187 dx00
= _mm_sub_pd(ix0
,jx0
);
188 dy00
= _mm_sub_pd(iy0
,jy0
);
189 dz00
= _mm_sub_pd(iz0
,jz0
);
190 dx10
= _mm_sub_pd(ix1
,jx0
);
191 dy10
= _mm_sub_pd(iy1
,jy0
);
192 dz10
= _mm_sub_pd(iz1
,jz0
);
193 dx20
= _mm_sub_pd(ix2
,jx0
);
194 dy20
= _mm_sub_pd(iy2
,jy0
);
195 dz20
= _mm_sub_pd(iz2
,jz0
);
196 dx30
= _mm_sub_pd(ix3
,jx0
);
197 dy30
= _mm_sub_pd(iy3
,jy0
);
198 dz30
= _mm_sub_pd(iz3
,jz0
);
200 /* Calculate squared distance and things based on it */
201 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
202 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
203 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
204 rsq30
= gmx_mm_calc_rsq_pd(dx30
,dy30
,dz30
);
206 rinv10
= sse2_invsqrt_d(rsq10
);
207 rinv20
= sse2_invsqrt_d(rsq20
);
208 rinv30
= sse2_invsqrt_d(rsq30
);
210 rinvsq00
= sse2_inv_d(rsq00
);
211 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
212 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
213 rinvsq30
= _mm_mul_pd(rinv30
,rinv30
);
215 /* Load parameters for j particles */
216 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
217 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
218 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
220 fjx0
= _mm_setzero_pd();
221 fjy0
= _mm_setzero_pd();
222 fjz0
= _mm_setzero_pd();
224 /**************************
225 * CALCULATE INTERACTIONS *
226 **************************/
228 /* Compute parameters for interactions between i and j atoms */
229 gmx_mm_load_2pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,
230 vdwparam
+vdwioffset0
+vdwjidx0B
,&c6_00
,&c12_00
);
232 /* LENNARD-JONES DISPERSION/REPULSION */
234 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
235 vvdw6
= _mm_mul_pd(c6_00
,rinvsix
);
236 vvdw12
= _mm_mul_pd(c12_00
,_mm_mul_pd(rinvsix
,rinvsix
));
237 vvdw
= _mm_sub_pd( _mm_mul_pd(vvdw12
,one_twelfth
) , _mm_mul_pd(vvdw6
,one_sixth
) );
238 fvdw
= _mm_mul_pd(_mm_sub_pd(vvdw12
,vvdw6
),rinvsq00
);
240 /* Update potential sum for this i atom from the interaction with this j atom. */
241 vvdwsum
= _mm_add_pd(vvdwsum
,vvdw
);
245 /* Calculate temporary vectorial force */
246 tx
= _mm_mul_pd(fscal
,dx00
);
247 ty
= _mm_mul_pd(fscal
,dy00
);
248 tz
= _mm_mul_pd(fscal
,dz00
);
250 /* Update vectorial force */
251 fix0
= _mm_add_pd(fix0
,tx
);
252 fiy0
= _mm_add_pd(fiy0
,ty
);
253 fiz0
= _mm_add_pd(fiz0
,tz
);
255 fjx0
= _mm_add_pd(fjx0
,tx
);
256 fjy0
= _mm_add_pd(fjy0
,ty
);
257 fjz0
= _mm_add_pd(fjz0
,tz
);
259 /**************************
260 * CALCULATE INTERACTIONS *
261 **************************/
263 /* Compute parameters for interactions between i and j atoms */
264 qq10
= _mm_mul_pd(iq1
,jq0
);
266 /* COULOMB ELECTROSTATICS */
267 velec
= _mm_mul_pd(qq10
,rinv10
);
268 felec
= _mm_mul_pd(velec
,rinvsq10
);
270 /* Update potential sum for this i atom from the interaction with this j atom. */
271 velecsum
= _mm_add_pd(velecsum
,velec
);
275 /* Calculate temporary vectorial force */
276 tx
= _mm_mul_pd(fscal
,dx10
);
277 ty
= _mm_mul_pd(fscal
,dy10
);
278 tz
= _mm_mul_pd(fscal
,dz10
);
280 /* Update vectorial force */
281 fix1
= _mm_add_pd(fix1
,tx
);
282 fiy1
= _mm_add_pd(fiy1
,ty
);
283 fiz1
= _mm_add_pd(fiz1
,tz
);
285 fjx0
= _mm_add_pd(fjx0
,tx
);
286 fjy0
= _mm_add_pd(fjy0
,ty
);
287 fjz0
= _mm_add_pd(fjz0
,tz
);
289 /**************************
290 * CALCULATE INTERACTIONS *
291 **************************/
293 /* Compute parameters for interactions between i and j atoms */
294 qq20
= _mm_mul_pd(iq2
,jq0
);
296 /* COULOMB ELECTROSTATICS */
297 velec
= _mm_mul_pd(qq20
,rinv20
);
298 felec
= _mm_mul_pd(velec
,rinvsq20
);
300 /* Update potential sum for this i atom from the interaction with this j atom. */
301 velecsum
= _mm_add_pd(velecsum
,velec
);
305 /* Calculate temporary vectorial force */
306 tx
= _mm_mul_pd(fscal
,dx20
);
307 ty
= _mm_mul_pd(fscal
,dy20
);
308 tz
= _mm_mul_pd(fscal
,dz20
);
310 /* Update vectorial force */
311 fix2
= _mm_add_pd(fix2
,tx
);
312 fiy2
= _mm_add_pd(fiy2
,ty
);
313 fiz2
= _mm_add_pd(fiz2
,tz
);
315 fjx0
= _mm_add_pd(fjx0
,tx
);
316 fjy0
= _mm_add_pd(fjy0
,ty
);
317 fjz0
= _mm_add_pd(fjz0
,tz
);
319 /**************************
320 * CALCULATE INTERACTIONS *
321 **************************/
323 /* Compute parameters for interactions between i and j atoms */
324 qq30
= _mm_mul_pd(iq3
,jq0
);
326 /* COULOMB ELECTROSTATICS */
327 velec
= _mm_mul_pd(qq30
,rinv30
);
328 felec
= _mm_mul_pd(velec
,rinvsq30
);
330 /* Update potential sum for this i atom from the interaction with this j atom. */
331 velecsum
= _mm_add_pd(velecsum
,velec
);
335 /* Calculate temporary vectorial force */
336 tx
= _mm_mul_pd(fscal
,dx30
);
337 ty
= _mm_mul_pd(fscal
,dy30
);
338 tz
= _mm_mul_pd(fscal
,dz30
);
340 /* Update vectorial force */
341 fix3
= _mm_add_pd(fix3
,tx
);
342 fiy3
= _mm_add_pd(fiy3
,ty
);
343 fiz3
= _mm_add_pd(fiz3
,tz
);
345 fjx0
= _mm_add_pd(fjx0
,tx
);
346 fjy0
= _mm_add_pd(fjy0
,ty
);
347 fjz0
= _mm_add_pd(fjz0
,tz
);
349 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
);
351 /* Inner loop uses 119 flops */
358 j_coord_offsetA
= DIM
*jnrA
;
360 /* load j atom coordinates */
361 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
364 /* Calculate displacement vector */
365 dx00
= _mm_sub_pd(ix0
,jx0
);
366 dy00
= _mm_sub_pd(iy0
,jy0
);
367 dz00
= _mm_sub_pd(iz0
,jz0
);
368 dx10
= _mm_sub_pd(ix1
,jx0
);
369 dy10
= _mm_sub_pd(iy1
,jy0
);
370 dz10
= _mm_sub_pd(iz1
,jz0
);
371 dx20
= _mm_sub_pd(ix2
,jx0
);
372 dy20
= _mm_sub_pd(iy2
,jy0
);
373 dz20
= _mm_sub_pd(iz2
,jz0
);
374 dx30
= _mm_sub_pd(ix3
,jx0
);
375 dy30
= _mm_sub_pd(iy3
,jy0
);
376 dz30
= _mm_sub_pd(iz3
,jz0
);
378 /* Calculate squared distance and things based on it */
379 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
380 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
381 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
382 rsq30
= gmx_mm_calc_rsq_pd(dx30
,dy30
,dz30
);
384 rinv10
= sse2_invsqrt_d(rsq10
);
385 rinv20
= sse2_invsqrt_d(rsq20
);
386 rinv30
= sse2_invsqrt_d(rsq30
);
388 rinvsq00
= sse2_inv_d(rsq00
);
389 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
390 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
391 rinvsq30
= _mm_mul_pd(rinv30
,rinv30
);
393 /* Load parameters for j particles */
394 jq0
= _mm_load_sd(charge
+jnrA
+0);
395 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
397 fjx0
= _mm_setzero_pd();
398 fjy0
= _mm_setzero_pd();
399 fjz0
= _mm_setzero_pd();
401 /**************************
402 * CALCULATE INTERACTIONS *
403 **************************/
405 /* Compute parameters for interactions between i and j atoms */
406 gmx_mm_load_1pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,&c6_00
,&c12_00
);
408 /* LENNARD-JONES DISPERSION/REPULSION */
410 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
411 vvdw6
= _mm_mul_pd(c6_00
,rinvsix
);
412 vvdw12
= _mm_mul_pd(c12_00
,_mm_mul_pd(rinvsix
,rinvsix
));
413 vvdw
= _mm_sub_pd( _mm_mul_pd(vvdw12
,one_twelfth
) , _mm_mul_pd(vvdw6
,one_sixth
) );
414 fvdw
= _mm_mul_pd(_mm_sub_pd(vvdw12
,vvdw6
),rinvsq00
);
416 /* Update potential sum for this i atom from the interaction with this j atom. */
417 vvdw
= _mm_unpacklo_pd(vvdw
,_mm_setzero_pd());
418 vvdwsum
= _mm_add_pd(vvdwsum
,vvdw
);
422 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
424 /* Calculate temporary vectorial force */
425 tx
= _mm_mul_pd(fscal
,dx00
);
426 ty
= _mm_mul_pd(fscal
,dy00
);
427 tz
= _mm_mul_pd(fscal
,dz00
);
429 /* Update vectorial force */
430 fix0
= _mm_add_pd(fix0
,tx
);
431 fiy0
= _mm_add_pd(fiy0
,ty
);
432 fiz0
= _mm_add_pd(fiz0
,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 qq10
= _mm_mul_pd(iq1
,jq0
);
445 /* COULOMB ELECTROSTATICS */
446 velec
= _mm_mul_pd(qq10
,rinv10
);
447 felec
= _mm_mul_pd(velec
,rinvsq10
);
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
,dx10
);
459 ty
= _mm_mul_pd(fscal
,dy10
);
460 tz
= _mm_mul_pd(fscal
,dz10
);
462 /* Update vectorial force */
463 fix1
= _mm_add_pd(fix1
,tx
);
464 fiy1
= _mm_add_pd(fiy1
,ty
);
465 fiz1
= _mm_add_pd(fiz1
,tz
);
467 fjx0
= _mm_add_pd(fjx0
,tx
);
468 fjy0
= _mm_add_pd(fjy0
,ty
);
469 fjz0
= _mm_add_pd(fjz0
,tz
);
471 /**************************
472 * CALCULATE INTERACTIONS *
473 **************************/
475 /* Compute parameters for interactions between i and j atoms */
476 qq20
= _mm_mul_pd(iq2
,jq0
);
478 /* COULOMB ELECTROSTATICS */
479 velec
= _mm_mul_pd(qq20
,rinv20
);
480 felec
= _mm_mul_pd(velec
,rinvsq20
);
482 /* Update potential sum for this i atom from the interaction with this j atom. */
483 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
484 velecsum
= _mm_add_pd(velecsum
,velec
);
488 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
490 /* Calculate temporary vectorial force */
491 tx
= _mm_mul_pd(fscal
,dx20
);
492 ty
= _mm_mul_pd(fscal
,dy20
);
493 tz
= _mm_mul_pd(fscal
,dz20
);
495 /* Update vectorial force */
496 fix2
= _mm_add_pd(fix2
,tx
);
497 fiy2
= _mm_add_pd(fiy2
,ty
);
498 fiz2
= _mm_add_pd(fiz2
,tz
);
500 fjx0
= _mm_add_pd(fjx0
,tx
);
501 fjy0
= _mm_add_pd(fjy0
,ty
);
502 fjz0
= _mm_add_pd(fjz0
,tz
);
504 /**************************
505 * CALCULATE INTERACTIONS *
506 **************************/
508 /* Compute parameters for interactions between i and j atoms */
509 qq30
= _mm_mul_pd(iq3
,jq0
);
511 /* COULOMB ELECTROSTATICS */
512 velec
= _mm_mul_pd(qq30
,rinv30
);
513 felec
= _mm_mul_pd(velec
,rinvsq30
);
515 /* Update potential sum for this i atom from the interaction with this j atom. */
516 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
517 velecsum
= _mm_add_pd(velecsum
,velec
);
521 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
523 /* Calculate temporary vectorial force */
524 tx
= _mm_mul_pd(fscal
,dx30
);
525 ty
= _mm_mul_pd(fscal
,dy30
);
526 tz
= _mm_mul_pd(fscal
,dz30
);
528 /* Update vectorial force */
529 fix3
= _mm_add_pd(fix3
,tx
);
530 fiy3
= _mm_add_pd(fiy3
,ty
);
531 fiz3
= _mm_add_pd(fiz3
,tz
);
533 fjx0
= _mm_add_pd(fjx0
,tx
);
534 fjy0
= _mm_add_pd(fjy0
,ty
);
535 fjz0
= _mm_add_pd(fjz0
,tz
);
537 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
);
539 /* Inner loop uses 119 flops */
542 /* End of innermost loop */
544 gmx_mm_update_iforce_4atom_swizzle_pd(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,fix3
,fiy3
,fiz3
,
545 f
+i_coord_offset
,fshift
+i_shift_offset
);
548 /* Update potential energies */
549 gmx_mm_update_1pot_pd(velecsum
,kernel_data
->energygrp_elec
+ggid
);
550 gmx_mm_update_1pot_pd(vvdwsum
,kernel_data
->energygrp_vdw
+ggid
);
552 /* Increment number of inner iterations */
553 inneriter
+= j_index_end
- j_index_start
;
555 /* Outer loop uses 26 flops */
558 /* Increment number of outer iterations */
561 /* Update outer/inner flops */
563 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4_VF
,outeriter
*26 + inneriter
*119);
566 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_sse2_double
567 * Electrostatics interaction: Coulomb
568 * VdW interaction: LennardJones
569 * Geometry: Water4-Particle
570 * Calculate force/pot: Force
573 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_sse2_double
574 (t_nblist
* gmx_restrict nlist
,
575 rvec
* gmx_restrict xx
,
576 rvec
* gmx_restrict ff
,
577 struct t_forcerec
* gmx_restrict fr
,
578 t_mdatoms
* gmx_restrict mdatoms
,
579 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
580 t_nrnb
* gmx_restrict nrnb
)
582 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
583 * just 0 for non-waters.
584 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
585 * jnr indices corresponding to data put in the four positions in the SIMD register.
587 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
588 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
590 int j_coord_offsetA
,j_coord_offsetB
;
591 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
593 real
*shiftvec
,*fshift
,*x
,*f
;
594 __m128d tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
596 __m128d ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
598 __m128d ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
600 __m128d ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
602 __m128d ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
603 int vdwjidx0A
,vdwjidx0B
;
604 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
605 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
606 __m128d dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
607 __m128d dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
608 __m128d dx30
,dy30
,dz30
,rsq30
,rinv30
,rinvsq30
,r30
,qq30
,c6_30
,c12_30
;
609 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
612 __m128d rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
615 __m128d one_sixth
= _mm_set1_pd(1.0/6.0);
616 __m128d one_twelfth
= _mm_set1_pd(1.0/12.0);
617 __m128d dummy_mask
,cutoff_mask
;
618 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
619 __m128d one
= _mm_set1_pd(1.0);
620 __m128d two
= _mm_set1_pd(2.0);
626 jindex
= nlist
->jindex
;
628 shiftidx
= nlist
->shift
;
630 shiftvec
= fr
->shift_vec
[0];
631 fshift
= fr
->fshift
[0];
632 facel
= _mm_set1_pd(fr
->ic
->epsfac
);
633 charge
= mdatoms
->chargeA
;
634 nvdwtype
= fr
->ntype
;
636 vdwtype
= mdatoms
->typeA
;
638 /* Setup water-specific parameters */
639 inr
= nlist
->iinr
[0];
640 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
641 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
642 iq3
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+3]));
643 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
645 /* Avoid stupid compiler warnings */
653 /* Start outer loop over neighborlists */
654 for(iidx
=0; iidx
<nri
; iidx
++)
656 /* Load shift vector for this list */
657 i_shift_offset
= DIM
*shiftidx
[iidx
];
659 /* Load limits for loop over neighbors */
660 j_index_start
= jindex
[iidx
];
661 j_index_end
= jindex
[iidx
+1];
663 /* Get outer coordinate index */
665 i_coord_offset
= DIM
*inr
;
667 /* Load i particle coords and add shift vector */
668 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
669 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
,&ix3
,&iy3
,&iz3
);
671 fix0
= _mm_setzero_pd();
672 fiy0
= _mm_setzero_pd();
673 fiz0
= _mm_setzero_pd();
674 fix1
= _mm_setzero_pd();
675 fiy1
= _mm_setzero_pd();
676 fiz1
= _mm_setzero_pd();
677 fix2
= _mm_setzero_pd();
678 fiy2
= _mm_setzero_pd();
679 fiz2
= _mm_setzero_pd();
680 fix3
= _mm_setzero_pd();
681 fiy3
= _mm_setzero_pd();
682 fiz3
= _mm_setzero_pd();
684 /* Start inner kernel loop */
685 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
688 /* Get j neighbor index, and coordinate index */
691 j_coord_offsetA
= DIM
*jnrA
;
692 j_coord_offsetB
= DIM
*jnrB
;
694 /* load j atom coordinates */
695 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
698 /* Calculate displacement vector */
699 dx00
= _mm_sub_pd(ix0
,jx0
);
700 dy00
= _mm_sub_pd(iy0
,jy0
);
701 dz00
= _mm_sub_pd(iz0
,jz0
);
702 dx10
= _mm_sub_pd(ix1
,jx0
);
703 dy10
= _mm_sub_pd(iy1
,jy0
);
704 dz10
= _mm_sub_pd(iz1
,jz0
);
705 dx20
= _mm_sub_pd(ix2
,jx0
);
706 dy20
= _mm_sub_pd(iy2
,jy0
);
707 dz20
= _mm_sub_pd(iz2
,jz0
);
708 dx30
= _mm_sub_pd(ix3
,jx0
);
709 dy30
= _mm_sub_pd(iy3
,jy0
);
710 dz30
= _mm_sub_pd(iz3
,jz0
);
712 /* Calculate squared distance and things based on it */
713 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
714 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
715 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
716 rsq30
= gmx_mm_calc_rsq_pd(dx30
,dy30
,dz30
);
718 rinv10
= sse2_invsqrt_d(rsq10
);
719 rinv20
= sse2_invsqrt_d(rsq20
);
720 rinv30
= sse2_invsqrt_d(rsq30
);
722 rinvsq00
= sse2_inv_d(rsq00
);
723 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
724 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
725 rinvsq30
= _mm_mul_pd(rinv30
,rinv30
);
727 /* Load parameters for j particles */
728 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
729 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
730 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
732 fjx0
= _mm_setzero_pd();
733 fjy0
= _mm_setzero_pd();
734 fjz0
= _mm_setzero_pd();
736 /**************************
737 * CALCULATE INTERACTIONS *
738 **************************/
740 /* Compute parameters for interactions between i and j atoms */
741 gmx_mm_load_2pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,
742 vdwparam
+vdwioffset0
+vdwjidx0B
,&c6_00
,&c12_00
);
744 /* LENNARD-JONES DISPERSION/REPULSION */
746 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
747 fvdw
= _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00
,rinvsix
),c6_00
),_mm_mul_pd(rinvsix
,rinvsq00
));
751 /* Calculate temporary vectorial force */
752 tx
= _mm_mul_pd(fscal
,dx00
);
753 ty
= _mm_mul_pd(fscal
,dy00
);
754 tz
= _mm_mul_pd(fscal
,dz00
);
756 /* Update vectorial force */
757 fix0
= _mm_add_pd(fix0
,tx
);
758 fiy0
= _mm_add_pd(fiy0
,ty
);
759 fiz0
= _mm_add_pd(fiz0
,tz
);
761 fjx0
= _mm_add_pd(fjx0
,tx
);
762 fjy0
= _mm_add_pd(fjy0
,ty
);
763 fjz0
= _mm_add_pd(fjz0
,tz
);
765 /**************************
766 * CALCULATE INTERACTIONS *
767 **************************/
769 /* Compute parameters for interactions between i and j atoms */
770 qq10
= _mm_mul_pd(iq1
,jq0
);
772 /* COULOMB ELECTROSTATICS */
773 velec
= _mm_mul_pd(qq10
,rinv10
);
774 felec
= _mm_mul_pd(velec
,rinvsq10
);
778 /* Calculate temporary vectorial force */
779 tx
= _mm_mul_pd(fscal
,dx10
);
780 ty
= _mm_mul_pd(fscal
,dy10
);
781 tz
= _mm_mul_pd(fscal
,dz10
);
783 /* Update vectorial force */
784 fix1
= _mm_add_pd(fix1
,tx
);
785 fiy1
= _mm_add_pd(fiy1
,ty
);
786 fiz1
= _mm_add_pd(fiz1
,tz
);
788 fjx0
= _mm_add_pd(fjx0
,tx
);
789 fjy0
= _mm_add_pd(fjy0
,ty
);
790 fjz0
= _mm_add_pd(fjz0
,tz
);
792 /**************************
793 * CALCULATE INTERACTIONS *
794 **************************/
796 /* Compute parameters for interactions between i and j atoms */
797 qq20
= _mm_mul_pd(iq2
,jq0
);
799 /* COULOMB ELECTROSTATICS */
800 velec
= _mm_mul_pd(qq20
,rinv20
);
801 felec
= _mm_mul_pd(velec
,rinvsq20
);
805 /* Calculate temporary vectorial force */
806 tx
= _mm_mul_pd(fscal
,dx20
);
807 ty
= _mm_mul_pd(fscal
,dy20
);
808 tz
= _mm_mul_pd(fscal
,dz20
);
810 /* Update vectorial force */
811 fix2
= _mm_add_pd(fix2
,tx
);
812 fiy2
= _mm_add_pd(fiy2
,ty
);
813 fiz2
= _mm_add_pd(fiz2
,tz
);
815 fjx0
= _mm_add_pd(fjx0
,tx
);
816 fjy0
= _mm_add_pd(fjy0
,ty
);
817 fjz0
= _mm_add_pd(fjz0
,tz
);
819 /**************************
820 * CALCULATE INTERACTIONS *
821 **************************/
823 /* Compute parameters for interactions between i and j atoms */
824 qq30
= _mm_mul_pd(iq3
,jq0
);
826 /* COULOMB ELECTROSTATICS */
827 velec
= _mm_mul_pd(qq30
,rinv30
);
828 felec
= _mm_mul_pd(velec
,rinvsq30
);
832 /* Calculate temporary vectorial force */
833 tx
= _mm_mul_pd(fscal
,dx30
);
834 ty
= _mm_mul_pd(fscal
,dy30
);
835 tz
= _mm_mul_pd(fscal
,dz30
);
837 /* Update vectorial force */
838 fix3
= _mm_add_pd(fix3
,tx
);
839 fiy3
= _mm_add_pd(fiy3
,ty
);
840 fiz3
= _mm_add_pd(fiz3
,tz
);
842 fjx0
= _mm_add_pd(fjx0
,tx
);
843 fjy0
= _mm_add_pd(fjy0
,ty
);
844 fjz0
= _mm_add_pd(fjz0
,tz
);
846 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
);
848 /* Inner loop uses 111 flops */
855 j_coord_offsetA
= DIM
*jnrA
;
857 /* load j atom coordinates */
858 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
861 /* Calculate displacement vector */
862 dx00
= _mm_sub_pd(ix0
,jx0
);
863 dy00
= _mm_sub_pd(iy0
,jy0
);
864 dz00
= _mm_sub_pd(iz0
,jz0
);
865 dx10
= _mm_sub_pd(ix1
,jx0
);
866 dy10
= _mm_sub_pd(iy1
,jy0
);
867 dz10
= _mm_sub_pd(iz1
,jz0
);
868 dx20
= _mm_sub_pd(ix2
,jx0
);
869 dy20
= _mm_sub_pd(iy2
,jy0
);
870 dz20
= _mm_sub_pd(iz2
,jz0
);
871 dx30
= _mm_sub_pd(ix3
,jx0
);
872 dy30
= _mm_sub_pd(iy3
,jy0
);
873 dz30
= _mm_sub_pd(iz3
,jz0
);
875 /* Calculate squared distance and things based on it */
876 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
877 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
878 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
879 rsq30
= gmx_mm_calc_rsq_pd(dx30
,dy30
,dz30
);
881 rinv10
= sse2_invsqrt_d(rsq10
);
882 rinv20
= sse2_invsqrt_d(rsq20
);
883 rinv30
= sse2_invsqrt_d(rsq30
);
885 rinvsq00
= sse2_inv_d(rsq00
);
886 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
887 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
888 rinvsq30
= _mm_mul_pd(rinv30
,rinv30
);
890 /* Load parameters for j particles */
891 jq0
= _mm_load_sd(charge
+jnrA
+0);
892 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
894 fjx0
= _mm_setzero_pd();
895 fjy0
= _mm_setzero_pd();
896 fjz0
= _mm_setzero_pd();
898 /**************************
899 * CALCULATE INTERACTIONS *
900 **************************/
902 /* Compute parameters for interactions between i and j atoms */
903 gmx_mm_load_1pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,&c6_00
,&c12_00
);
905 /* LENNARD-JONES DISPERSION/REPULSION */
907 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
908 fvdw
= _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00
,rinvsix
),c6_00
),_mm_mul_pd(rinvsix
,rinvsq00
));
912 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
914 /* Calculate temporary vectorial force */
915 tx
= _mm_mul_pd(fscal
,dx00
);
916 ty
= _mm_mul_pd(fscal
,dy00
);
917 tz
= _mm_mul_pd(fscal
,dz00
);
919 /* Update vectorial force */
920 fix0
= _mm_add_pd(fix0
,tx
);
921 fiy0
= _mm_add_pd(fiy0
,ty
);
922 fiz0
= _mm_add_pd(fiz0
,tz
);
924 fjx0
= _mm_add_pd(fjx0
,tx
);
925 fjy0
= _mm_add_pd(fjy0
,ty
);
926 fjz0
= _mm_add_pd(fjz0
,tz
);
928 /**************************
929 * CALCULATE INTERACTIONS *
930 **************************/
932 /* Compute parameters for interactions between i and j atoms */
933 qq10
= _mm_mul_pd(iq1
,jq0
);
935 /* COULOMB ELECTROSTATICS */
936 velec
= _mm_mul_pd(qq10
,rinv10
);
937 felec
= _mm_mul_pd(velec
,rinvsq10
);
941 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
943 /* Calculate temporary vectorial force */
944 tx
= _mm_mul_pd(fscal
,dx10
);
945 ty
= _mm_mul_pd(fscal
,dy10
);
946 tz
= _mm_mul_pd(fscal
,dz10
);
948 /* Update vectorial force */
949 fix1
= _mm_add_pd(fix1
,tx
);
950 fiy1
= _mm_add_pd(fiy1
,ty
);
951 fiz1
= _mm_add_pd(fiz1
,tz
);
953 fjx0
= _mm_add_pd(fjx0
,tx
);
954 fjy0
= _mm_add_pd(fjy0
,ty
);
955 fjz0
= _mm_add_pd(fjz0
,tz
);
957 /**************************
958 * CALCULATE INTERACTIONS *
959 **************************/
961 /* Compute parameters for interactions between i and j atoms */
962 qq20
= _mm_mul_pd(iq2
,jq0
);
964 /* COULOMB ELECTROSTATICS */
965 velec
= _mm_mul_pd(qq20
,rinv20
);
966 felec
= _mm_mul_pd(velec
,rinvsq20
);
970 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
972 /* Calculate temporary vectorial force */
973 tx
= _mm_mul_pd(fscal
,dx20
);
974 ty
= _mm_mul_pd(fscal
,dy20
);
975 tz
= _mm_mul_pd(fscal
,dz20
);
977 /* Update vectorial force */
978 fix2
= _mm_add_pd(fix2
,tx
);
979 fiy2
= _mm_add_pd(fiy2
,ty
);
980 fiz2
= _mm_add_pd(fiz2
,tz
);
982 fjx0
= _mm_add_pd(fjx0
,tx
);
983 fjy0
= _mm_add_pd(fjy0
,ty
);
984 fjz0
= _mm_add_pd(fjz0
,tz
);
986 /**************************
987 * CALCULATE INTERACTIONS *
988 **************************/
990 /* Compute parameters for interactions between i and j atoms */
991 qq30
= _mm_mul_pd(iq3
,jq0
);
993 /* COULOMB ELECTROSTATICS */
994 velec
= _mm_mul_pd(qq30
,rinv30
);
995 felec
= _mm_mul_pd(velec
,rinvsq30
);
999 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1001 /* Calculate temporary vectorial force */
1002 tx
= _mm_mul_pd(fscal
,dx30
);
1003 ty
= _mm_mul_pd(fscal
,dy30
);
1004 tz
= _mm_mul_pd(fscal
,dz30
);
1006 /* Update vectorial force */
1007 fix3
= _mm_add_pd(fix3
,tx
);
1008 fiy3
= _mm_add_pd(fiy3
,ty
);
1009 fiz3
= _mm_add_pd(fiz3
,tz
);
1011 fjx0
= _mm_add_pd(fjx0
,tx
);
1012 fjy0
= _mm_add_pd(fjy0
,ty
);
1013 fjz0
= _mm_add_pd(fjz0
,tz
);
1015 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
);
1017 /* Inner loop uses 111 flops */
1020 /* End of innermost loop */
1022 gmx_mm_update_iforce_4atom_swizzle_pd(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,fix3
,fiy3
,fiz3
,
1023 f
+i_coord_offset
,fshift
+i_shift_offset
);
1025 /* Increment number of inner iterations */
1026 inneriter
+= j_index_end
- j_index_start
;
1028 /* Outer loop uses 24 flops */
1031 /* Increment number of outer iterations */
1034 /* Update outer/inner flops */
1036 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4_F
,outeriter
*24 + inneriter
*111);