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_single 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_single.h"
48 #include "kernelutil_x86_avx_128_fma_single.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_VF_avx_128_fma_single
52 * Electrostatics interaction: ReactionField
53 * VdW interaction: LennardJones
54 * Geometry: Water3-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_VF_avx_128_fma_single
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,C,D refer to j loop unrolling done with AVX_128, e.g. for the four 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
;
74 int jnrA
,jnrB
,jnrC
,jnrD
;
75 int jnrlistA
,jnrlistB
,jnrlistC
,jnrlistD
;
76 int j_coord_offsetA
,j_coord_offsetB
,j_coord_offsetC
,j_coord_offsetD
;
77 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
79 real
*shiftvec
,*fshift
,*x
,*f
;
80 real
*fjptrA
,*fjptrB
,*fjptrC
,*fjptrD
;
82 __m128 fscal
,rcutoff
,rcutoff2
,jidxall
;
84 __m128 ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
86 __m128 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
88 __m128 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
89 int vdwjidx0A
,vdwjidx0B
,vdwjidx0C
,vdwjidx0D
;
90 __m128 jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
91 __m128 dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
92 __m128 dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
93 __m128 dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
94 __m128 velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
97 __m128 rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
100 __m128 one_sixth
= _mm_set1_ps(1.0/6.0);
101 __m128 one_twelfth
= _mm_set1_ps(1.0/12.0);
102 __m128 dummy_mask
,cutoff_mask
;
103 __m128 signbit
= _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
104 __m128 one
= _mm_set1_ps(1.0);
105 __m128 two
= _mm_set1_ps(2.0);
111 jindex
= nlist
->jindex
;
113 shiftidx
= nlist
->shift
;
115 shiftvec
= fr
->shift_vec
[0];
116 fshift
= fr
->fshift
[0];
117 facel
= _mm_set1_ps(fr
->epsfac
);
118 charge
= mdatoms
->chargeA
;
119 krf
= _mm_set1_ps(fr
->ic
->k_rf
);
120 krf2
= _mm_set1_ps(fr
->ic
->k_rf
*2.0);
121 crf
= _mm_set1_ps(fr
->ic
->c_rf
);
122 nvdwtype
= fr
->ntype
;
124 vdwtype
= mdatoms
->typeA
;
126 /* Setup water-specific parameters */
127 inr
= nlist
->iinr
[0];
128 iq0
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+0]));
129 iq1
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+1]));
130 iq2
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+2]));
131 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
133 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
134 rcutoff_scalar
= fr
->rcoulomb
;
135 rcutoff
= _mm_set1_ps(rcutoff_scalar
);
136 rcutoff2
= _mm_mul_ps(rcutoff
,rcutoff
);
138 sh_vdw_invrcut6
= _mm_set1_ps(fr
->ic
->sh_invrc6
);
139 rvdw
= _mm_set1_ps(fr
->rvdw
);
141 /* Avoid stupid compiler warnings */
142 jnrA
= jnrB
= jnrC
= jnrD
= 0;
151 for(iidx
=0;iidx
<4*DIM
;iidx
++)
156 /* Start outer loop over neighborlists */
157 for(iidx
=0; iidx
<nri
; iidx
++)
159 /* Load shift vector for this list */
160 i_shift_offset
= DIM
*shiftidx
[iidx
];
162 /* Load limits for loop over neighbors */
163 j_index_start
= jindex
[iidx
];
164 j_index_end
= jindex
[iidx
+1];
166 /* Get outer coordinate index */
168 i_coord_offset
= DIM
*inr
;
170 /* Load i particle coords and add shift vector */
171 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
172 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
);
174 fix0
= _mm_setzero_ps();
175 fiy0
= _mm_setzero_ps();
176 fiz0
= _mm_setzero_ps();
177 fix1
= _mm_setzero_ps();
178 fiy1
= _mm_setzero_ps();
179 fiz1
= _mm_setzero_ps();
180 fix2
= _mm_setzero_ps();
181 fiy2
= _mm_setzero_ps();
182 fiz2
= _mm_setzero_ps();
184 /* Reset potential sums */
185 velecsum
= _mm_setzero_ps();
186 vvdwsum
= _mm_setzero_ps();
188 /* Start inner kernel loop */
189 for(jidx
=j_index_start
; jidx
<j_index_end
&& jjnr
[jidx
+3]>=0; jidx
+=4)
192 /* Get j neighbor index, and coordinate index */
197 j_coord_offsetA
= DIM
*jnrA
;
198 j_coord_offsetB
= DIM
*jnrB
;
199 j_coord_offsetC
= DIM
*jnrC
;
200 j_coord_offsetD
= DIM
*jnrD
;
202 /* load j atom coordinates */
203 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
204 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
207 /* Calculate displacement vector */
208 dx00
= _mm_sub_ps(ix0
,jx0
);
209 dy00
= _mm_sub_ps(iy0
,jy0
);
210 dz00
= _mm_sub_ps(iz0
,jz0
);
211 dx10
= _mm_sub_ps(ix1
,jx0
);
212 dy10
= _mm_sub_ps(iy1
,jy0
);
213 dz10
= _mm_sub_ps(iz1
,jz0
);
214 dx20
= _mm_sub_ps(ix2
,jx0
);
215 dy20
= _mm_sub_ps(iy2
,jy0
);
216 dz20
= _mm_sub_ps(iz2
,jz0
);
218 /* Calculate squared distance and things based on it */
219 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
220 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
221 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
223 rinv00
= gmx_mm_invsqrt_ps(rsq00
);
224 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
225 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
227 rinvsq00
= _mm_mul_ps(rinv00
,rinv00
);
228 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
229 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
231 /* Load parameters for j particles */
232 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
233 charge
+jnrC
+0,charge
+jnrD
+0);
234 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
235 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
236 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
237 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
239 fjx0
= _mm_setzero_ps();
240 fjy0
= _mm_setzero_ps();
241 fjz0
= _mm_setzero_ps();
243 /**************************
244 * CALCULATE INTERACTIONS *
245 **************************/
247 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
250 /* Compute parameters for interactions between i and j atoms */
251 qq00
= _mm_mul_ps(iq0
,jq0
);
252 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
253 vdwparam
+vdwioffset0
+vdwjidx0B
,
254 vdwparam
+vdwioffset0
+vdwjidx0C
,
255 vdwparam
+vdwioffset0
+vdwjidx0D
,
258 /* REACTION-FIELD ELECTROSTATICS */
259 velec
= _mm_mul_ps(qq00
,_mm_sub_ps(_mm_macc_ps(krf
,rsq00
,rinv00
),crf
));
260 felec
= _mm_mul_ps(qq00
,_mm_msub_ps(rinv00
,rinvsq00
,krf2
));
262 /* LENNARD-JONES DISPERSION/REPULSION */
264 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
265 vvdw6
= _mm_mul_ps(c6_00
,rinvsix
);
266 vvdw12
= _mm_mul_ps(c12_00
,_mm_mul_ps(rinvsix
,rinvsix
));
267 vvdw
= _mm_msub_ps(_mm_nmacc_ps(c12_00
,_mm_mul_ps(sh_vdw_invrcut6
,sh_vdw_invrcut6
),vvdw12
),one_twelfth
,
268 _mm_mul_ps( _mm_nmacc_ps(c6_00
,sh_vdw_invrcut6
,vvdw6
),one_sixth
));
269 fvdw
= _mm_mul_ps(_mm_sub_ps(vvdw12
,vvdw6
),rinvsq00
);
271 cutoff_mask
= _mm_cmplt_ps(rsq00
,rcutoff2
);
273 /* Update potential sum for this i atom from the interaction with this j atom. */
274 velec
= _mm_and_ps(velec
,cutoff_mask
);
275 velecsum
= _mm_add_ps(velecsum
,velec
);
276 vvdw
= _mm_and_ps(vvdw
,cutoff_mask
);
277 vvdwsum
= _mm_add_ps(vvdwsum
,vvdw
);
279 fscal
= _mm_add_ps(felec
,fvdw
);
281 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
283 /* Update vectorial force */
284 fix0
= _mm_macc_ps(dx00
,fscal
,fix0
);
285 fiy0
= _mm_macc_ps(dy00
,fscal
,fiy0
);
286 fiz0
= _mm_macc_ps(dz00
,fscal
,fiz0
);
288 fjx0
= _mm_macc_ps(dx00
,fscal
,fjx0
);
289 fjy0
= _mm_macc_ps(dy00
,fscal
,fjy0
);
290 fjz0
= _mm_macc_ps(dz00
,fscal
,fjz0
);
294 /**************************
295 * CALCULATE INTERACTIONS *
296 **************************/
298 if (gmx_mm_any_lt(rsq10
,rcutoff2
))
301 /* Compute parameters for interactions between i and j atoms */
302 qq10
= _mm_mul_ps(iq1
,jq0
);
304 /* REACTION-FIELD ELECTROSTATICS */
305 velec
= _mm_mul_ps(qq10
,_mm_sub_ps(_mm_macc_ps(krf
,rsq10
,rinv10
),crf
));
306 felec
= _mm_mul_ps(qq10
,_mm_msub_ps(rinv10
,rinvsq10
,krf2
));
308 cutoff_mask
= _mm_cmplt_ps(rsq10
,rcutoff2
);
310 /* Update potential sum for this i atom from the interaction with this j atom. */
311 velec
= _mm_and_ps(velec
,cutoff_mask
);
312 velecsum
= _mm_add_ps(velecsum
,velec
);
316 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
318 /* Update vectorial force */
319 fix1
= _mm_macc_ps(dx10
,fscal
,fix1
);
320 fiy1
= _mm_macc_ps(dy10
,fscal
,fiy1
);
321 fiz1
= _mm_macc_ps(dz10
,fscal
,fiz1
);
323 fjx0
= _mm_macc_ps(dx10
,fscal
,fjx0
);
324 fjy0
= _mm_macc_ps(dy10
,fscal
,fjy0
);
325 fjz0
= _mm_macc_ps(dz10
,fscal
,fjz0
);
329 /**************************
330 * CALCULATE INTERACTIONS *
331 **************************/
333 if (gmx_mm_any_lt(rsq20
,rcutoff2
))
336 /* Compute parameters for interactions between i and j atoms */
337 qq20
= _mm_mul_ps(iq2
,jq0
);
339 /* REACTION-FIELD ELECTROSTATICS */
340 velec
= _mm_mul_ps(qq20
,_mm_sub_ps(_mm_macc_ps(krf
,rsq20
,rinv20
),crf
));
341 felec
= _mm_mul_ps(qq20
,_mm_msub_ps(rinv20
,rinvsq20
,krf2
));
343 cutoff_mask
= _mm_cmplt_ps(rsq20
,rcutoff2
);
345 /* Update potential sum for this i atom from the interaction with this j atom. */
346 velec
= _mm_and_ps(velec
,cutoff_mask
);
347 velecsum
= _mm_add_ps(velecsum
,velec
);
351 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
353 /* Update vectorial force */
354 fix2
= _mm_macc_ps(dx20
,fscal
,fix2
);
355 fiy2
= _mm_macc_ps(dy20
,fscal
,fiy2
);
356 fiz2
= _mm_macc_ps(dz20
,fscal
,fiz2
);
358 fjx0
= _mm_macc_ps(dx20
,fscal
,fjx0
);
359 fjy0
= _mm_macc_ps(dy20
,fscal
,fjy0
);
360 fjz0
= _mm_macc_ps(dz20
,fscal
,fjz0
);
364 fjptrA
= f
+j_coord_offsetA
;
365 fjptrB
= f
+j_coord_offsetB
;
366 fjptrC
= f
+j_coord_offsetC
;
367 fjptrD
= f
+j_coord_offsetD
;
369 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
371 /* Inner loop uses 135 flops */
377 /* Get j neighbor index, and coordinate index */
378 jnrlistA
= jjnr
[jidx
];
379 jnrlistB
= jjnr
[jidx
+1];
380 jnrlistC
= jjnr
[jidx
+2];
381 jnrlistD
= jjnr
[jidx
+3];
382 /* Sign of each element will be negative for non-real atoms.
383 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
384 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
386 dummy_mask
= gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i
*)(jjnr
+jidx
)),_mm_setzero_si128()));
387 jnrA
= (jnrlistA
>=0) ? jnrlistA
: 0;
388 jnrB
= (jnrlistB
>=0) ? jnrlistB
: 0;
389 jnrC
= (jnrlistC
>=0) ? jnrlistC
: 0;
390 jnrD
= (jnrlistD
>=0) ? jnrlistD
: 0;
391 j_coord_offsetA
= DIM
*jnrA
;
392 j_coord_offsetB
= DIM
*jnrB
;
393 j_coord_offsetC
= DIM
*jnrC
;
394 j_coord_offsetD
= DIM
*jnrD
;
396 /* load j atom coordinates */
397 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
398 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
401 /* Calculate displacement vector */
402 dx00
= _mm_sub_ps(ix0
,jx0
);
403 dy00
= _mm_sub_ps(iy0
,jy0
);
404 dz00
= _mm_sub_ps(iz0
,jz0
);
405 dx10
= _mm_sub_ps(ix1
,jx0
);
406 dy10
= _mm_sub_ps(iy1
,jy0
);
407 dz10
= _mm_sub_ps(iz1
,jz0
);
408 dx20
= _mm_sub_ps(ix2
,jx0
);
409 dy20
= _mm_sub_ps(iy2
,jy0
);
410 dz20
= _mm_sub_ps(iz2
,jz0
);
412 /* Calculate squared distance and things based on it */
413 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
414 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
415 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
417 rinv00
= gmx_mm_invsqrt_ps(rsq00
);
418 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
419 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
421 rinvsq00
= _mm_mul_ps(rinv00
,rinv00
);
422 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
423 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
425 /* Load parameters for j particles */
426 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
427 charge
+jnrC
+0,charge
+jnrD
+0);
428 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
429 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
430 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
431 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
433 fjx0
= _mm_setzero_ps();
434 fjy0
= _mm_setzero_ps();
435 fjz0
= _mm_setzero_ps();
437 /**************************
438 * CALCULATE INTERACTIONS *
439 **************************/
441 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
444 /* Compute parameters for interactions between i and j atoms */
445 qq00
= _mm_mul_ps(iq0
,jq0
);
446 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
447 vdwparam
+vdwioffset0
+vdwjidx0B
,
448 vdwparam
+vdwioffset0
+vdwjidx0C
,
449 vdwparam
+vdwioffset0
+vdwjidx0D
,
452 /* REACTION-FIELD ELECTROSTATICS */
453 velec
= _mm_mul_ps(qq00
,_mm_sub_ps(_mm_macc_ps(krf
,rsq00
,rinv00
),crf
));
454 felec
= _mm_mul_ps(qq00
,_mm_msub_ps(rinv00
,rinvsq00
,krf2
));
456 /* LENNARD-JONES DISPERSION/REPULSION */
458 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
459 vvdw6
= _mm_mul_ps(c6_00
,rinvsix
);
460 vvdw12
= _mm_mul_ps(c12_00
,_mm_mul_ps(rinvsix
,rinvsix
));
461 vvdw
= _mm_msub_ps(_mm_nmacc_ps(c12_00
,_mm_mul_ps(sh_vdw_invrcut6
,sh_vdw_invrcut6
),vvdw12
),one_twelfth
,
462 _mm_mul_ps( _mm_nmacc_ps(c6_00
,sh_vdw_invrcut6
,vvdw6
),one_sixth
));
463 fvdw
= _mm_mul_ps(_mm_sub_ps(vvdw12
,vvdw6
),rinvsq00
);
465 cutoff_mask
= _mm_cmplt_ps(rsq00
,rcutoff2
);
467 /* Update potential sum for this i atom from the interaction with this j atom. */
468 velec
= _mm_and_ps(velec
,cutoff_mask
);
469 velec
= _mm_andnot_ps(dummy_mask
,velec
);
470 velecsum
= _mm_add_ps(velecsum
,velec
);
471 vvdw
= _mm_and_ps(vvdw
,cutoff_mask
);
472 vvdw
= _mm_andnot_ps(dummy_mask
,vvdw
);
473 vvdwsum
= _mm_add_ps(vvdwsum
,vvdw
);
475 fscal
= _mm_add_ps(felec
,fvdw
);
477 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
479 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
481 /* Update vectorial force */
482 fix0
= _mm_macc_ps(dx00
,fscal
,fix0
);
483 fiy0
= _mm_macc_ps(dy00
,fscal
,fiy0
);
484 fiz0
= _mm_macc_ps(dz00
,fscal
,fiz0
);
486 fjx0
= _mm_macc_ps(dx00
,fscal
,fjx0
);
487 fjy0
= _mm_macc_ps(dy00
,fscal
,fjy0
);
488 fjz0
= _mm_macc_ps(dz00
,fscal
,fjz0
);
492 /**************************
493 * CALCULATE INTERACTIONS *
494 **************************/
496 if (gmx_mm_any_lt(rsq10
,rcutoff2
))
499 /* Compute parameters for interactions between i and j atoms */
500 qq10
= _mm_mul_ps(iq1
,jq0
);
502 /* REACTION-FIELD ELECTROSTATICS */
503 velec
= _mm_mul_ps(qq10
,_mm_sub_ps(_mm_macc_ps(krf
,rsq10
,rinv10
),crf
));
504 felec
= _mm_mul_ps(qq10
,_mm_msub_ps(rinv10
,rinvsq10
,krf2
));
506 cutoff_mask
= _mm_cmplt_ps(rsq10
,rcutoff2
);
508 /* Update potential sum for this i atom from the interaction with this j atom. */
509 velec
= _mm_and_ps(velec
,cutoff_mask
);
510 velec
= _mm_andnot_ps(dummy_mask
,velec
);
511 velecsum
= _mm_add_ps(velecsum
,velec
);
515 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
517 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
519 /* Update vectorial force */
520 fix1
= _mm_macc_ps(dx10
,fscal
,fix1
);
521 fiy1
= _mm_macc_ps(dy10
,fscal
,fiy1
);
522 fiz1
= _mm_macc_ps(dz10
,fscal
,fiz1
);
524 fjx0
= _mm_macc_ps(dx10
,fscal
,fjx0
);
525 fjy0
= _mm_macc_ps(dy10
,fscal
,fjy0
);
526 fjz0
= _mm_macc_ps(dz10
,fscal
,fjz0
);
530 /**************************
531 * CALCULATE INTERACTIONS *
532 **************************/
534 if (gmx_mm_any_lt(rsq20
,rcutoff2
))
537 /* Compute parameters for interactions between i and j atoms */
538 qq20
= _mm_mul_ps(iq2
,jq0
);
540 /* REACTION-FIELD ELECTROSTATICS */
541 velec
= _mm_mul_ps(qq20
,_mm_sub_ps(_mm_macc_ps(krf
,rsq20
,rinv20
),crf
));
542 felec
= _mm_mul_ps(qq20
,_mm_msub_ps(rinv20
,rinvsq20
,krf2
));
544 cutoff_mask
= _mm_cmplt_ps(rsq20
,rcutoff2
);
546 /* Update potential sum for this i atom from the interaction with this j atom. */
547 velec
= _mm_and_ps(velec
,cutoff_mask
);
548 velec
= _mm_andnot_ps(dummy_mask
,velec
);
549 velecsum
= _mm_add_ps(velecsum
,velec
);
553 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
555 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
557 /* Update vectorial force */
558 fix2
= _mm_macc_ps(dx20
,fscal
,fix2
);
559 fiy2
= _mm_macc_ps(dy20
,fscal
,fiy2
);
560 fiz2
= _mm_macc_ps(dz20
,fscal
,fiz2
);
562 fjx0
= _mm_macc_ps(dx20
,fscal
,fjx0
);
563 fjy0
= _mm_macc_ps(dy20
,fscal
,fjy0
);
564 fjz0
= _mm_macc_ps(dz20
,fscal
,fjz0
);
568 fjptrA
= (jnrlistA
>=0) ? f
+j_coord_offsetA
: scratch
;
569 fjptrB
= (jnrlistB
>=0) ? f
+j_coord_offsetB
: scratch
;
570 fjptrC
= (jnrlistC
>=0) ? f
+j_coord_offsetC
: scratch
;
571 fjptrD
= (jnrlistD
>=0) ? f
+j_coord_offsetD
: scratch
;
573 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
575 /* Inner loop uses 135 flops */
578 /* End of innermost loop */
580 gmx_mm_update_iforce_3atom_swizzle_ps(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,
581 f
+i_coord_offset
,fshift
+i_shift_offset
);
584 /* Update potential energies */
585 gmx_mm_update_1pot_ps(velecsum
,kernel_data
->energygrp_elec
+ggid
);
586 gmx_mm_update_1pot_ps(vvdwsum
,kernel_data
->energygrp_vdw
+ggid
);
588 /* Increment number of inner iterations */
589 inneriter
+= j_index_end
- j_index_start
;
591 /* Outer loop uses 20 flops */
594 /* Increment number of outer iterations */
597 /* Update outer/inner flops */
599 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W3_VF
,outeriter
*20 + inneriter
*135);
602 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_F_avx_128_fma_single
603 * Electrostatics interaction: ReactionField
604 * VdW interaction: LennardJones
605 * Geometry: Water3-Particle
606 * Calculate force/pot: Force
609 nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_F_avx_128_fma_single
610 (t_nblist
* gmx_restrict nlist
,
611 rvec
* gmx_restrict xx
,
612 rvec
* gmx_restrict ff
,
613 t_forcerec
* gmx_restrict fr
,
614 t_mdatoms
* gmx_restrict mdatoms
,
615 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
616 t_nrnb
* gmx_restrict nrnb
)
618 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
619 * just 0 for non-waters.
620 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
621 * jnr indices corresponding to data put in the four positions in the SIMD register.
623 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
624 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
625 int jnrA
,jnrB
,jnrC
,jnrD
;
626 int jnrlistA
,jnrlistB
,jnrlistC
,jnrlistD
;
627 int j_coord_offsetA
,j_coord_offsetB
,j_coord_offsetC
,j_coord_offsetD
;
628 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
630 real
*shiftvec
,*fshift
,*x
,*f
;
631 real
*fjptrA
,*fjptrB
,*fjptrC
,*fjptrD
;
633 __m128 fscal
,rcutoff
,rcutoff2
,jidxall
;
635 __m128 ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
637 __m128 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
639 __m128 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
640 int vdwjidx0A
,vdwjidx0B
,vdwjidx0C
,vdwjidx0D
;
641 __m128 jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
642 __m128 dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
643 __m128 dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
644 __m128 dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
645 __m128 velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
648 __m128 rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
651 __m128 one_sixth
= _mm_set1_ps(1.0/6.0);
652 __m128 one_twelfth
= _mm_set1_ps(1.0/12.0);
653 __m128 dummy_mask
,cutoff_mask
;
654 __m128 signbit
= _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
655 __m128 one
= _mm_set1_ps(1.0);
656 __m128 two
= _mm_set1_ps(2.0);
662 jindex
= nlist
->jindex
;
664 shiftidx
= nlist
->shift
;
666 shiftvec
= fr
->shift_vec
[0];
667 fshift
= fr
->fshift
[0];
668 facel
= _mm_set1_ps(fr
->epsfac
);
669 charge
= mdatoms
->chargeA
;
670 krf
= _mm_set1_ps(fr
->ic
->k_rf
);
671 krf2
= _mm_set1_ps(fr
->ic
->k_rf
*2.0);
672 crf
= _mm_set1_ps(fr
->ic
->c_rf
);
673 nvdwtype
= fr
->ntype
;
675 vdwtype
= mdatoms
->typeA
;
677 /* Setup water-specific parameters */
678 inr
= nlist
->iinr
[0];
679 iq0
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+0]));
680 iq1
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+1]));
681 iq2
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+2]));
682 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
684 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
685 rcutoff_scalar
= fr
->rcoulomb
;
686 rcutoff
= _mm_set1_ps(rcutoff_scalar
);
687 rcutoff2
= _mm_mul_ps(rcutoff
,rcutoff
);
689 sh_vdw_invrcut6
= _mm_set1_ps(fr
->ic
->sh_invrc6
);
690 rvdw
= _mm_set1_ps(fr
->rvdw
);
692 /* Avoid stupid compiler warnings */
693 jnrA
= jnrB
= jnrC
= jnrD
= 0;
702 for(iidx
=0;iidx
<4*DIM
;iidx
++)
707 /* Start outer loop over neighborlists */
708 for(iidx
=0; iidx
<nri
; iidx
++)
710 /* Load shift vector for this list */
711 i_shift_offset
= DIM
*shiftidx
[iidx
];
713 /* Load limits for loop over neighbors */
714 j_index_start
= jindex
[iidx
];
715 j_index_end
= jindex
[iidx
+1];
717 /* Get outer coordinate index */
719 i_coord_offset
= DIM
*inr
;
721 /* Load i particle coords and add shift vector */
722 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
723 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
);
725 fix0
= _mm_setzero_ps();
726 fiy0
= _mm_setzero_ps();
727 fiz0
= _mm_setzero_ps();
728 fix1
= _mm_setzero_ps();
729 fiy1
= _mm_setzero_ps();
730 fiz1
= _mm_setzero_ps();
731 fix2
= _mm_setzero_ps();
732 fiy2
= _mm_setzero_ps();
733 fiz2
= _mm_setzero_ps();
735 /* Start inner kernel loop */
736 for(jidx
=j_index_start
; jidx
<j_index_end
&& jjnr
[jidx
+3]>=0; jidx
+=4)
739 /* Get j neighbor index, and coordinate index */
744 j_coord_offsetA
= DIM
*jnrA
;
745 j_coord_offsetB
= DIM
*jnrB
;
746 j_coord_offsetC
= DIM
*jnrC
;
747 j_coord_offsetD
= DIM
*jnrD
;
749 /* load j atom coordinates */
750 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
751 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
754 /* Calculate displacement vector */
755 dx00
= _mm_sub_ps(ix0
,jx0
);
756 dy00
= _mm_sub_ps(iy0
,jy0
);
757 dz00
= _mm_sub_ps(iz0
,jz0
);
758 dx10
= _mm_sub_ps(ix1
,jx0
);
759 dy10
= _mm_sub_ps(iy1
,jy0
);
760 dz10
= _mm_sub_ps(iz1
,jz0
);
761 dx20
= _mm_sub_ps(ix2
,jx0
);
762 dy20
= _mm_sub_ps(iy2
,jy0
);
763 dz20
= _mm_sub_ps(iz2
,jz0
);
765 /* Calculate squared distance and things based on it */
766 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
767 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
768 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
770 rinv00
= gmx_mm_invsqrt_ps(rsq00
);
771 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
772 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
774 rinvsq00
= _mm_mul_ps(rinv00
,rinv00
);
775 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
776 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
778 /* Load parameters for j particles */
779 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
780 charge
+jnrC
+0,charge
+jnrD
+0);
781 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
782 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
783 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
784 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
786 fjx0
= _mm_setzero_ps();
787 fjy0
= _mm_setzero_ps();
788 fjz0
= _mm_setzero_ps();
790 /**************************
791 * CALCULATE INTERACTIONS *
792 **************************/
794 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
797 /* Compute parameters for interactions between i and j atoms */
798 qq00
= _mm_mul_ps(iq0
,jq0
);
799 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
800 vdwparam
+vdwioffset0
+vdwjidx0B
,
801 vdwparam
+vdwioffset0
+vdwjidx0C
,
802 vdwparam
+vdwioffset0
+vdwjidx0D
,
805 /* REACTION-FIELD ELECTROSTATICS */
806 felec
= _mm_mul_ps(qq00
,_mm_msub_ps(rinv00
,rinvsq00
,krf2
));
808 /* LENNARD-JONES DISPERSION/REPULSION */
810 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
811 fvdw
= _mm_mul_ps(_mm_msub_ps(c12_00
,rinvsix
,c6_00
),_mm_mul_ps(rinvsix
,rinvsq00
));
813 cutoff_mask
= _mm_cmplt_ps(rsq00
,rcutoff2
);
815 fscal
= _mm_add_ps(felec
,fvdw
);
817 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
819 /* Update vectorial force */
820 fix0
= _mm_macc_ps(dx00
,fscal
,fix0
);
821 fiy0
= _mm_macc_ps(dy00
,fscal
,fiy0
);
822 fiz0
= _mm_macc_ps(dz00
,fscal
,fiz0
);
824 fjx0
= _mm_macc_ps(dx00
,fscal
,fjx0
);
825 fjy0
= _mm_macc_ps(dy00
,fscal
,fjy0
);
826 fjz0
= _mm_macc_ps(dz00
,fscal
,fjz0
);
830 /**************************
831 * CALCULATE INTERACTIONS *
832 **************************/
834 if (gmx_mm_any_lt(rsq10
,rcutoff2
))
837 /* Compute parameters for interactions between i and j atoms */
838 qq10
= _mm_mul_ps(iq1
,jq0
);
840 /* REACTION-FIELD ELECTROSTATICS */
841 felec
= _mm_mul_ps(qq10
,_mm_msub_ps(rinv10
,rinvsq10
,krf2
));
843 cutoff_mask
= _mm_cmplt_ps(rsq10
,rcutoff2
);
847 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
849 /* Update vectorial force */
850 fix1
= _mm_macc_ps(dx10
,fscal
,fix1
);
851 fiy1
= _mm_macc_ps(dy10
,fscal
,fiy1
);
852 fiz1
= _mm_macc_ps(dz10
,fscal
,fiz1
);
854 fjx0
= _mm_macc_ps(dx10
,fscal
,fjx0
);
855 fjy0
= _mm_macc_ps(dy10
,fscal
,fjy0
);
856 fjz0
= _mm_macc_ps(dz10
,fscal
,fjz0
);
860 /**************************
861 * CALCULATE INTERACTIONS *
862 **************************/
864 if (gmx_mm_any_lt(rsq20
,rcutoff2
))
867 /* Compute parameters for interactions between i and j atoms */
868 qq20
= _mm_mul_ps(iq2
,jq0
);
870 /* REACTION-FIELD ELECTROSTATICS */
871 felec
= _mm_mul_ps(qq20
,_mm_msub_ps(rinv20
,rinvsq20
,krf2
));
873 cutoff_mask
= _mm_cmplt_ps(rsq20
,rcutoff2
);
877 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
879 /* Update vectorial force */
880 fix2
= _mm_macc_ps(dx20
,fscal
,fix2
);
881 fiy2
= _mm_macc_ps(dy20
,fscal
,fiy2
);
882 fiz2
= _mm_macc_ps(dz20
,fscal
,fiz2
);
884 fjx0
= _mm_macc_ps(dx20
,fscal
,fjx0
);
885 fjy0
= _mm_macc_ps(dy20
,fscal
,fjy0
);
886 fjz0
= _mm_macc_ps(dz20
,fscal
,fjz0
);
890 fjptrA
= f
+j_coord_offsetA
;
891 fjptrB
= f
+j_coord_offsetB
;
892 fjptrC
= f
+j_coord_offsetC
;
893 fjptrD
= f
+j_coord_offsetD
;
895 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
897 /* Inner loop uses 106 flops */
903 /* Get j neighbor index, and coordinate index */
904 jnrlistA
= jjnr
[jidx
];
905 jnrlistB
= jjnr
[jidx
+1];
906 jnrlistC
= jjnr
[jidx
+2];
907 jnrlistD
= jjnr
[jidx
+3];
908 /* Sign of each element will be negative for non-real atoms.
909 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
910 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
912 dummy_mask
= gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i
*)(jjnr
+jidx
)),_mm_setzero_si128()));
913 jnrA
= (jnrlistA
>=0) ? jnrlistA
: 0;
914 jnrB
= (jnrlistB
>=0) ? jnrlistB
: 0;
915 jnrC
= (jnrlistC
>=0) ? jnrlistC
: 0;
916 jnrD
= (jnrlistD
>=0) ? jnrlistD
: 0;
917 j_coord_offsetA
= DIM
*jnrA
;
918 j_coord_offsetB
= DIM
*jnrB
;
919 j_coord_offsetC
= DIM
*jnrC
;
920 j_coord_offsetD
= DIM
*jnrD
;
922 /* load j atom coordinates */
923 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
924 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
927 /* Calculate displacement vector */
928 dx00
= _mm_sub_ps(ix0
,jx0
);
929 dy00
= _mm_sub_ps(iy0
,jy0
);
930 dz00
= _mm_sub_ps(iz0
,jz0
);
931 dx10
= _mm_sub_ps(ix1
,jx0
);
932 dy10
= _mm_sub_ps(iy1
,jy0
);
933 dz10
= _mm_sub_ps(iz1
,jz0
);
934 dx20
= _mm_sub_ps(ix2
,jx0
);
935 dy20
= _mm_sub_ps(iy2
,jy0
);
936 dz20
= _mm_sub_ps(iz2
,jz0
);
938 /* Calculate squared distance and things based on it */
939 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
940 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
941 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
943 rinv00
= gmx_mm_invsqrt_ps(rsq00
);
944 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
945 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
947 rinvsq00
= _mm_mul_ps(rinv00
,rinv00
);
948 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
949 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
951 /* Load parameters for j particles */
952 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
953 charge
+jnrC
+0,charge
+jnrD
+0);
954 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
955 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
956 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
957 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
959 fjx0
= _mm_setzero_ps();
960 fjy0
= _mm_setzero_ps();
961 fjz0
= _mm_setzero_ps();
963 /**************************
964 * CALCULATE INTERACTIONS *
965 **************************/
967 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
970 /* Compute parameters for interactions between i and j atoms */
971 qq00
= _mm_mul_ps(iq0
,jq0
);
972 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
973 vdwparam
+vdwioffset0
+vdwjidx0B
,
974 vdwparam
+vdwioffset0
+vdwjidx0C
,
975 vdwparam
+vdwioffset0
+vdwjidx0D
,
978 /* REACTION-FIELD ELECTROSTATICS */
979 felec
= _mm_mul_ps(qq00
,_mm_msub_ps(rinv00
,rinvsq00
,krf2
));
981 /* LENNARD-JONES DISPERSION/REPULSION */
983 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
984 fvdw
= _mm_mul_ps(_mm_msub_ps(c12_00
,rinvsix
,c6_00
),_mm_mul_ps(rinvsix
,rinvsq00
));
986 cutoff_mask
= _mm_cmplt_ps(rsq00
,rcutoff2
);
988 fscal
= _mm_add_ps(felec
,fvdw
);
990 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
992 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
994 /* Update vectorial force */
995 fix0
= _mm_macc_ps(dx00
,fscal
,fix0
);
996 fiy0
= _mm_macc_ps(dy00
,fscal
,fiy0
);
997 fiz0
= _mm_macc_ps(dz00
,fscal
,fiz0
);
999 fjx0
= _mm_macc_ps(dx00
,fscal
,fjx0
);
1000 fjy0
= _mm_macc_ps(dy00
,fscal
,fjy0
);
1001 fjz0
= _mm_macc_ps(dz00
,fscal
,fjz0
);
1005 /**************************
1006 * CALCULATE INTERACTIONS *
1007 **************************/
1009 if (gmx_mm_any_lt(rsq10
,rcutoff2
))
1012 /* Compute parameters for interactions between i and j atoms */
1013 qq10
= _mm_mul_ps(iq1
,jq0
);
1015 /* REACTION-FIELD ELECTROSTATICS */
1016 felec
= _mm_mul_ps(qq10
,_mm_msub_ps(rinv10
,rinvsq10
,krf2
));
1018 cutoff_mask
= _mm_cmplt_ps(rsq10
,rcutoff2
);
1022 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
1024 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1026 /* Update vectorial force */
1027 fix1
= _mm_macc_ps(dx10
,fscal
,fix1
);
1028 fiy1
= _mm_macc_ps(dy10
,fscal
,fiy1
);
1029 fiz1
= _mm_macc_ps(dz10
,fscal
,fiz1
);
1031 fjx0
= _mm_macc_ps(dx10
,fscal
,fjx0
);
1032 fjy0
= _mm_macc_ps(dy10
,fscal
,fjy0
);
1033 fjz0
= _mm_macc_ps(dz10
,fscal
,fjz0
);
1037 /**************************
1038 * CALCULATE INTERACTIONS *
1039 **************************/
1041 if (gmx_mm_any_lt(rsq20
,rcutoff2
))
1044 /* Compute parameters for interactions between i and j atoms */
1045 qq20
= _mm_mul_ps(iq2
,jq0
);
1047 /* REACTION-FIELD ELECTROSTATICS */
1048 felec
= _mm_mul_ps(qq20
,_mm_msub_ps(rinv20
,rinvsq20
,krf2
));
1050 cutoff_mask
= _mm_cmplt_ps(rsq20
,rcutoff2
);
1054 fscal
= _mm_and_ps(fscal
,cutoff_mask
);
1056 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1058 /* Update vectorial force */
1059 fix2
= _mm_macc_ps(dx20
,fscal
,fix2
);
1060 fiy2
= _mm_macc_ps(dy20
,fscal
,fiy2
);
1061 fiz2
= _mm_macc_ps(dz20
,fscal
,fiz2
);
1063 fjx0
= _mm_macc_ps(dx20
,fscal
,fjx0
);
1064 fjy0
= _mm_macc_ps(dy20
,fscal
,fjy0
);
1065 fjz0
= _mm_macc_ps(dz20
,fscal
,fjz0
);
1069 fjptrA
= (jnrlistA
>=0) ? f
+j_coord_offsetA
: scratch
;
1070 fjptrB
= (jnrlistB
>=0) ? f
+j_coord_offsetB
: scratch
;
1071 fjptrC
= (jnrlistC
>=0) ? f
+j_coord_offsetC
: scratch
;
1072 fjptrD
= (jnrlistD
>=0) ? f
+j_coord_offsetD
: scratch
;
1074 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
1076 /* Inner loop uses 106 flops */
1079 /* End of innermost loop */
1081 gmx_mm_update_iforce_3atom_swizzle_ps(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,
1082 f
+i_coord_offset
,fshift
+i_shift_offset
);
1084 /* Increment number of inner iterations */
1085 inneriter
+= j_index_end
- j_index_start
;
1087 /* Outer loop uses 18 flops */
1090 /* Increment number of outer iterations */
1093 /* Update outer/inner flops */
1095 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W3_F
,outeriter
*18 + inneriter
*106);