2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015, 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_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/math/vec.h"
46 #include "gromacs/legacyheaders/nrnb.h"
48 #include "gromacs/simd/math_x86_sse2_single.h"
49 #include "kernelutil_x86_sse2_single.h"
52 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW4P1_VF_sse2_single
53 * Electrostatics interaction: ReactionField
54 * VdW interaction: LennardJones
55 * Geometry: Water4-Particle
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecRF_VdwLJ_GeomW4P1_VF_sse2_single
60 (t_nblist
* gmx_restrict nlist
,
61 rvec
* gmx_restrict xx
,
62 rvec
* gmx_restrict ff
,
63 t_forcerec
* gmx_restrict fr
,
64 t_mdatoms
* gmx_restrict mdatoms
,
65 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
66 t_nrnb
* gmx_restrict nrnb
)
68 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
69 * just 0 for non-waters.
70 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
71 * jnr indices corresponding to data put in the four positions in the SIMD register.
73 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
74 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
75 int jnrA
,jnrB
,jnrC
,jnrD
;
76 int jnrlistA
,jnrlistB
,jnrlistC
,jnrlistD
;
77 int j_coord_offsetA
,j_coord_offsetB
,j_coord_offsetC
,j_coord_offsetD
;
78 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
80 real
*shiftvec
,*fshift
,*x
,*f
;
81 real
*fjptrA
,*fjptrB
,*fjptrC
,*fjptrD
;
83 __m128 tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
85 __m128 ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
87 __m128 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
89 __m128 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
91 __m128 ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
92 int vdwjidx0A
,vdwjidx0B
,vdwjidx0C
,vdwjidx0D
;
93 __m128 jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
94 __m128 dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
95 __m128 dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
96 __m128 dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
97 __m128 dx30
,dy30
,dz30
,rsq30
,rinv30
,rinvsq30
,r30
,qq30
,c6_30
,c12_30
;
98 __m128 velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
101 __m128 rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
104 __m128 one_sixth
= _mm_set1_ps(1.0/6.0);
105 __m128 one_twelfth
= _mm_set1_ps(1.0/12.0);
106 __m128 dummy_mask
,cutoff_mask
;
107 __m128 signbit
= _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
108 __m128 one
= _mm_set1_ps(1.0);
109 __m128 two
= _mm_set1_ps(2.0);
115 jindex
= nlist
->jindex
;
117 shiftidx
= nlist
->shift
;
119 shiftvec
= fr
->shift_vec
[0];
120 fshift
= fr
->fshift
[0];
121 facel
= _mm_set1_ps(fr
->epsfac
);
122 charge
= mdatoms
->chargeA
;
123 krf
= _mm_set1_ps(fr
->ic
->k_rf
);
124 krf2
= _mm_set1_ps(fr
->ic
->k_rf
*2.0);
125 crf
= _mm_set1_ps(fr
->ic
->c_rf
);
126 nvdwtype
= fr
->ntype
;
128 vdwtype
= mdatoms
->typeA
;
130 /* Setup water-specific parameters */
131 inr
= nlist
->iinr
[0];
132 iq1
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+1]));
133 iq2
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+2]));
134 iq3
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+3]));
135 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
137 /* Avoid stupid compiler warnings */
138 jnrA
= jnrB
= jnrC
= jnrD
= 0;
147 for(iidx
=0;iidx
<4*DIM
;iidx
++)
152 /* Start outer loop over neighborlists */
153 for(iidx
=0; iidx
<nri
; iidx
++)
155 /* Load shift vector for this list */
156 i_shift_offset
= DIM
*shiftidx
[iidx
];
158 /* Load limits for loop over neighbors */
159 j_index_start
= jindex
[iidx
];
160 j_index_end
= jindex
[iidx
+1];
162 /* Get outer coordinate index */
164 i_coord_offset
= DIM
*inr
;
166 /* Load i particle coords and add shift vector */
167 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
168 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
,&ix3
,&iy3
,&iz3
);
170 fix0
= _mm_setzero_ps();
171 fiy0
= _mm_setzero_ps();
172 fiz0
= _mm_setzero_ps();
173 fix1
= _mm_setzero_ps();
174 fiy1
= _mm_setzero_ps();
175 fiz1
= _mm_setzero_ps();
176 fix2
= _mm_setzero_ps();
177 fiy2
= _mm_setzero_ps();
178 fiz2
= _mm_setzero_ps();
179 fix3
= _mm_setzero_ps();
180 fiy3
= _mm_setzero_ps();
181 fiz3
= _mm_setzero_ps();
183 /* Reset potential sums */
184 velecsum
= _mm_setzero_ps();
185 vvdwsum
= _mm_setzero_ps();
187 /* Start inner kernel loop */
188 for(jidx
=j_index_start
; jidx
<j_index_end
&& jjnr
[jidx
+3]>=0; jidx
+=4)
191 /* Get j neighbor index, and coordinate index */
196 j_coord_offsetA
= DIM
*jnrA
;
197 j_coord_offsetB
= DIM
*jnrB
;
198 j_coord_offsetC
= DIM
*jnrC
;
199 j_coord_offsetD
= DIM
*jnrD
;
201 /* load j atom coordinates */
202 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
203 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
206 /* Calculate displacement vector */
207 dx00
= _mm_sub_ps(ix0
,jx0
);
208 dy00
= _mm_sub_ps(iy0
,jy0
);
209 dz00
= _mm_sub_ps(iz0
,jz0
);
210 dx10
= _mm_sub_ps(ix1
,jx0
);
211 dy10
= _mm_sub_ps(iy1
,jy0
);
212 dz10
= _mm_sub_ps(iz1
,jz0
);
213 dx20
= _mm_sub_ps(ix2
,jx0
);
214 dy20
= _mm_sub_ps(iy2
,jy0
);
215 dz20
= _mm_sub_ps(iz2
,jz0
);
216 dx30
= _mm_sub_ps(ix3
,jx0
);
217 dy30
= _mm_sub_ps(iy3
,jy0
);
218 dz30
= _mm_sub_ps(iz3
,jz0
);
220 /* Calculate squared distance and things based on it */
221 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
222 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
223 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
224 rsq30
= gmx_mm_calc_rsq_ps(dx30
,dy30
,dz30
);
226 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
227 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
228 rinv30
= gmx_mm_invsqrt_ps(rsq30
);
230 rinvsq00
= gmx_mm_inv_ps(rsq00
);
231 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
232 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
233 rinvsq30
= _mm_mul_ps(rinv30
,rinv30
);
235 /* Load parameters for j particles */
236 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
237 charge
+jnrC
+0,charge
+jnrD
+0);
238 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
239 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
240 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
241 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
243 fjx0
= _mm_setzero_ps();
244 fjy0
= _mm_setzero_ps();
245 fjz0
= _mm_setzero_ps();
247 /**************************
248 * CALCULATE INTERACTIONS *
249 **************************/
251 /* Compute parameters for interactions between i and j atoms */
252 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
253 vdwparam
+vdwioffset0
+vdwjidx0B
,
254 vdwparam
+vdwioffset0
+vdwjidx0C
,
255 vdwparam
+vdwioffset0
+vdwjidx0D
,
258 /* LENNARD-JONES DISPERSION/REPULSION */
260 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
261 vvdw6
= _mm_mul_ps(c6_00
,rinvsix
);
262 vvdw12
= _mm_mul_ps(c12_00
,_mm_mul_ps(rinvsix
,rinvsix
));
263 vvdw
= _mm_sub_ps( _mm_mul_ps(vvdw12
,one_twelfth
) , _mm_mul_ps(vvdw6
,one_sixth
) );
264 fvdw
= _mm_mul_ps(_mm_sub_ps(vvdw12
,vvdw6
),rinvsq00
);
266 /* Update potential sum for this i atom from the interaction with this j atom. */
267 vvdwsum
= _mm_add_ps(vvdwsum
,vvdw
);
271 /* Calculate temporary vectorial force */
272 tx
= _mm_mul_ps(fscal
,dx00
);
273 ty
= _mm_mul_ps(fscal
,dy00
);
274 tz
= _mm_mul_ps(fscal
,dz00
);
276 /* Update vectorial force */
277 fix0
= _mm_add_ps(fix0
,tx
);
278 fiy0
= _mm_add_ps(fiy0
,ty
);
279 fiz0
= _mm_add_ps(fiz0
,tz
);
281 fjx0
= _mm_add_ps(fjx0
,tx
);
282 fjy0
= _mm_add_ps(fjy0
,ty
);
283 fjz0
= _mm_add_ps(fjz0
,tz
);
285 /**************************
286 * CALCULATE INTERACTIONS *
287 **************************/
289 /* Compute parameters for interactions between i and j atoms */
290 qq10
= _mm_mul_ps(iq1
,jq0
);
292 /* REACTION-FIELD ELECTROSTATICS */
293 velec
= _mm_mul_ps(qq10
,_mm_sub_ps(_mm_add_ps(rinv10
,_mm_mul_ps(krf
,rsq10
)),crf
));
294 felec
= _mm_mul_ps(qq10
,_mm_sub_ps(_mm_mul_ps(rinv10
,rinvsq10
),krf2
));
296 /* Update potential sum for this i atom from the interaction with this j atom. */
297 velecsum
= _mm_add_ps(velecsum
,velec
);
301 /* Calculate temporary vectorial force */
302 tx
= _mm_mul_ps(fscal
,dx10
);
303 ty
= _mm_mul_ps(fscal
,dy10
);
304 tz
= _mm_mul_ps(fscal
,dz10
);
306 /* Update vectorial force */
307 fix1
= _mm_add_ps(fix1
,tx
);
308 fiy1
= _mm_add_ps(fiy1
,ty
);
309 fiz1
= _mm_add_ps(fiz1
,tz
);
311 fjx0
= _mm_add_ps(fjx0
,tx
);
312 fjy0
= _mm_add_ps(fjy0
,ty
);
313 fjz0
= _mm_add_ps(fjz0
,tz
);
315 /**************************
316 * CALCULATE INTERACTIONS *
317 **************************/
319 /* Compute parameters for interactions between i and j atoms */
320 qq20
= _mm_mul_ps(iq2
,jq0
);
322 /* REACTION-FIELD ELECTROSTATICS */
323 velec
= _mm_mul_ps(qq20
,_mm_sub_ps(_mm_add_ps(rinv20
,_mm_mul_ps(krf
,rsq20
)),crf
));
324 felec
= _mm_mul_ps(qq20
,_mm_sub_ps(_mm_mul_ps(rinv20
,rinvsq20
),krf2
));
326 /* Update potential sum for this i atom from the interaction with this j atom. */
327 velecsum
= _mm_add_ps(velecsum
,velec
);
331 /* Calculate temporary vectorial force */
332 tx
= _mm_mul_ps(fscal
,dx20
);
333 ty
= _mm_mul_ps(fscal
,dy20
);
334 tz
= _mm_mul_ps(fscal
,dz20
);
336 /* Update vectorial force */
337 fix2
= _mm_add_ps(fix2
,tx
);
338 fiy2
= _mm_add_ps(fiy2
,ty
);
339 fiz2
= _mm_add_ps(fiz2
,tz
);
341 fjx0
= _mm_add_ps(fjx0
,tx
);
342 fjy0
= _mm_add_ps(fjy0
,ty
);
343 fjz0
= _mm_add_ps(fjz0
,tz
);
345 /**************************
346 * CALCULATE INTERACTIONS *
347 **************************/
349 /* Compute parameters for interactions between i and j atoms */
350 qq30
= _mm_mul_ps(iq3
,jq0
);
352 /* REACTION-FIELD ELECTROSTATICS */
353 velec
= _mm_mul_ps(qq30
,_mm_sub_ps(_mm_add_ps(rinv30
,_mm_mul_ps(krf
,rsq30
)),crf
));
354 felec
= _mm_mul_ps(qq30
,_mm_sub_ps(_mm_mul_ps(rinv30
,rinvsq30
),krf2
));
356 /* Update potential sum for this i atom from the interaction with this j atom. */
357 velecsum
= _mm_add_ps(velecsum
,velec
);
361 /* Calculate temporary vectorial force */
362 tx
= _mm_mul_ps(fscal
,dx30
);
363 ty
= _mm_mul_ps(fscal
,dy30
);
364 tz
= _mm_mul_ps(fscal
,dz30
);
366 /* Update vectorial force */
367 fix3
= _mm_add_ps(fix3
,tx
);
368 fiy3
= _mm_add_ps(fiy3
,ty
);
369 fiz3
= _mm_add_ps(fiz3
,tz
);
371 fjx0
= _mm_add_ps(fjx0
,tx
);
372 fjy0
= _mm_add_ps(fjy0
,ty
);
373 fjz0
= _mm_add_ps(fjz0
,tz
);
375 fjptrA
= f
+j_coord_offsetA
;
376 fjptrB
= f
+j_coord_offsetB
;
377 fjptrC
= f
+j_coord_offsetC
;
378 fjptrD
= f
+j_coord_offsetD
;
380 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
382 /* Inner loop uses 128 flops */
388 /* Get j neighbor index, and coordinate index */
389 jnrlistA
= jjnr
[jidx
];
390 jnrlistB
= jjnr
[jidx
+1];
391 jnrlistC
= jjnr
[jidx
+2];
392 jnrlistD
= jjnr
[jidx
+3];
393 /* Sign of each element will be negative for non-real atoms.
394 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
395 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
397 dummy_mask
= gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i
*)(jjnr
+jidx
)),_mm_setzero_si128()));
398 jnrA
= (jnrlistA
>=0) ? jnrlistA
: 0;
399 jnrB
= (jnrlistB
>=0) ? jnrlistB
: 0;
400 jnrC
= (jnrlistC
>=0) ? jnrlistC
: 0;
401 jnrD
= (jnrlistD
>=0) ? jnrlistD
: 0;
402 j_coord_offsetA
= DIM
*jnrA
;
403 j_coord_offsetB
= DIM
*jnrB
;
404 j_coord_offsetC
= DIM
*jnrC
;
405 j_coord_offsetD
= DIM
*jnrD
;
407 /* load j atom coordinates */
408 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
409 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
412 /* Calculate displacement vector */
413 dx00
= _mm_sub_ps(ix0
,jx0
);
414 dy00
= _mm_sub_ps(iy0
,jy0
);
415 dz00
= _mm_sub_ps(iz0
,jz0
);
416 dx10
= _mm_sub_ps(ix1
,jx0
);
417 dy10
= _mm_sub_ps(iy1
,jy0
);
418 dz10
= _mm_sub_ps(iz1
,jz0
);
419 dx20
= _mm_sub_ps(ix2
,jx0
);
420 dy20
= _mm_sub_ps(iy2
,jy0
);
421 dz20
= _mm_sub_ps(iz2
,jz0
);
422 dx30
= _mm_sub_ps(ix3
,jx0
);
423 dy30
= _mm_sub_ps(iy3
,jy0
);
424 dz30
= _mm_sub_ps(iz3
,jz0
);
426 /* Calculate squared distance and things based on it */
427 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
428 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
429 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
430 rsq30
= gmx_mm_calc_rsq_ps(dx30
,dy30
,dz30
);
432 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
433 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
434 rinv30
= gmx_mm_invsqrt_ps(rsq30
);
436 rinvsq00
= gmx_mm_inv_ps(rsq00
);
437 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
438 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
439 rinvsq30
= _mm_mul_ps(rinv30
,rinv30
);
441 /* Load parameters for j particles */
442 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
443 charge
+jnrC
+0,charge
+jnrD
+0);
444 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
445 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
446 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
447 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
449 fjx0
= _mm_setzero_ps();
450 fjy0
= _mm_setzero_ps();
451 fjz0
= _mm_setzero_ps();
453 /**************************
454 * CALCULATE INTERACTIONS *
455 **************************/
457 /* Compute parameters for interactions between i and j atoms */
458 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
459 vdwparam
+vdwioffset0
+vdwjidx0B
,
460 vdwparam
+vdwioffset0
+vdwjidx0C
,
461 vdwparam
+vdwioffset0
+vdwjidx0D
,
464 /* LENNARD-JONES DISPERSION/REPULSION */
466 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
467 vvdw6
= _mm_mul_ps(c6_00
,rinvsix
);
468 vvdw12
= _mm_mul_ps(c12_00
,_mm_mul_ps(rinvsix
,rinvsix
));
469 vvdw
= _mm_sub_ps( _mm_mul_ps(vvdw12
,one_twelfth
) , _mm_mul_ps(vvdw6
,one_sixth
) );
470 fvdw
= _mm_mul_ps(_mm_sub_ps(vvdw12
,vvdw6
),rinvsq00
);
472 /* Update potential sum for this i atom from the interaction with this j atom. */
473 vvdw
= _mm_andnot_ps(dummy_mask
,vvdw
);
474 vvdwsum
= _mm_add_ps(vvdwsum
,vvdw
);
478 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
480 /* Calculate temporary vectorial force */
481 tx
= _mm_mul_ps(fscal
,dx00
);
482 ty
= _mm_mul_ps(fscal
,dy00
);
483 tz
= _mm_mul_ps(fscal
,dz00
);
485 /* Update vectorial force */
486 fix0
= _mm_add_ps(fix0
,tx
);
487 fiy0
= _mm_add_ps(fiy0
,ty
);
488 fiz0
= _mm_add_ps(fiz0
,tz
);
490 fjx0
= _mm_add_ps(fjx0
,tx
);
491 fjy0
= _mm_add_ps(fjy0
,ty
);
492 fjz0
= _mm_add_ps(fjz0
,tz
);
494 /**************************
495 * CALCULATE INTERACTIONS *
496 **************************/
498 /* Compute parameters for interactions between i and j atoms */
499 qq10
= _mm_mul_ps(iq1
,jq0
);
501 /* REACTION-FIELD ELECTROSTATICS */
502 velec
= _mm_mul_ps(qq10
,_mm_sub_ps(_mm_add_ps(rinv10
,_mm_mul_ps(krf
,rsq10
)),crf
));
503 felec
= _mm_mul_ps(qq10
,_mm_sub_ps(_mm_mul_ps(rinv10
,rinvsq10
),krf2
));
505 /* Update potential sum for this i atom from the interaction with this j atom. */
506 velec
= _mm_andnot_ps(dummy_mask
,velec
);
507 velecsum
= _mm_add_ps(velecsum
,velec
);
511 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
513 /* Calculate temporary vectorial force */
514 tx
= _mm_mul_ps(fscal
,dx10
);
515 ty
= _mm_mul_ps(fscal
,dy10
);
516 tz
= _mm_mul_ps(fscal
,dz10
);
518 /* Update vectorial force */
519 fix1
= _mm_add_ps(fix1
,tx
);
520 fiy1
= _mm_add_ps(fiy1
,ty
);
521 fiz1
= _mm_add_ps(fiz1
,tz
);
523 fjx0
= _mm_add_ps(fjx0
,tx
);
524 fjy0
= _mm_add_ps(fjy0
,ty
);
525 fjz0
= _mm_add_ps(fjz0
,tz
);
527 /**************************
528 * CALCULATE INTERACTIONS *
529 **************************/
531 /* Compute parameters for interactions between i and j atoms */
532 qq20
= _mm_mul_ps(iq2
,jq0
);
534 /* REACTION-FIELD ELECTROSTATICS */
535 velec
= _mm_mul_ps(qq20
,_mm_sub_ps(_mm_add_ps(rinv20
,_mm_mul_ps(krf
,rsq20
)),crf
));
536 felec
= _mm_mul_ps(qq20
,_mm_sub_ps(_mm_mul_ps(rinv20
,rinvsq20
),krf2
));
538 /* Update potential sum for this i atom from the interaction with this j atom. */
539 velec
= _mm_andnot_ps(dummy_mask
,velec
);
540 velecsum
= _mm_add_ps(velecsum
,velec
);
544 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
546 /* Calculate temporary vectorial force */
547 tx
= _mm_mul_ps(fscal
,dx20
);
548 ty
= _mm_mul_ps(fscal
,dy20
);
549 tz
= _mm_mul_ps(fscal
,dz20
);
551 /* Update vectorial force */
552 fix2
= _mm_add_ps(fix2
,tx
);
553 fiy2
= _mm_add_ps(fiy2
,ty
);
554 fiz2
= _mm_add_ps(fiz2
,tz
);
556 fjx0
= _mm_add_ps(fjx0
,tx
);
557 fjy0
= _mm_add_ps(fjy0
,ty
);
558 fjz0
= _mm_add_ps(fjz0
,tz
);
560 /**************************
561 * CALCULATE INTERACTIONS *
562 **************************/
564 /* Compute parameters for interactions between i and j atoms */
565 qq30
= _mm_mul_ps(iq3
,jq0
);
567 /* REACTION-FIELD ELECTROSTATICS */
568 velec
= _mm_mul_ps(qq30
,_mm_sub_ps(_mm_add_ps(rinv30
,_mm_mul_ps(krf
,rsq30
)),crf
));
569 felec
= _mm_mul_ps(qq30
,_mm_sub_ps(_mm_mul_ps(rinv30
,rinvsq30
),krf2
));
571 /* Update potential sum for this i atom from the interaction with this j atom. */
572 velec
= _mm_andnot_ps(dummy_mask
,velec
);
573 velecsum
= _mm_add_ps(velecsum
,velec
);
577 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
579 /* Calculate temporary vectorial force */
580 tx
= _mm_mul_ps(fscal
,dx30
);
581 ty
= _mm_mul_ps(fscal
,dy30
);
582 tz
= _mm_mul_ps(fscal
,dz30
);
584 /* Update vectorial force */
585 fix3
= _mm_add_ps(fix3
,tx
);
586 fiy3
= _mm_add_ps(fiy3
,ty
);
587 fiz3
= _mm_add_ps(fiz3
,tz
);
589 fjx0
= _mm_add_ps(fjx0
,tx
);
590 fjy0
= _mm_add_ps(fjy0
,ty
);
591 fjz0
= _mm_add_ps(fjz0
,tz
);
593 fjptrA
= (jnrlistA
>=0) ? f
+j_coord_offsetA
: scratch
;
594 fjptrB
= (jnrlistB
>=0) ? f
+j_coord_offsetB
: scratch
;
595 fjptrC
= (jnrlistC
>=0) ? f
+j_coord_offsetC
: scratch
;
596 fjptrD
= (jnrlistD
>=0) ? f
+j_coord_offsetD
: scratch
;
598 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
600 /* Inner loop uses 128 flops */
603 /* End of innermost loop */
605 gmx_mm_update_iforce_4atom_swizzle_ps(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,fix3
,fiy3
,fiz3
,
606 f
+i_coord_offset
,fshift
+i_shift_offset
);
609 /* Update potential energies */
610 gmx_mm_update_1pot_ps(velecsum
,kernel_data
->energygrp_elec
+ggid
);
611 gmx_mm_update_1pot_ps(vvdwsum
,kernel_data
->energygrp_vdw
+ggid
);
613 /* Increment number of inner iterations */
614 inneriter
+= j_index_end
- j_index_start
;
616 /* Outer loop uses 26 flops */
619 /* Increment number of outer iterations */
622 /* Update outer/inner flops */
624 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4_VF
,outeriter
*26 + inneriter
*128);
627 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_sse2_single
628 * Electrostatics interaction: ReactionField
629 * VdW interaction: LennardJones
630 * Geometry: Water4-Particle
631 * Calculate force/pot: Force
634 nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_sse2_single
635 (t_nblist
* gmx_restrict nlist
,
636 rvec
* gmx_restrict xx
,
637 rvec
* gmx_restrict ff
,
638 t_forcerec
* gmx_restrict fr
,
639 t_mdatoms
* gmx_restrict mdatoms
,
640 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
641 t_nrnb
* gmx_restrict nrnb
)
643 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
644 * just 0 for non-waters.
645 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
646 * jnr indices corresponding to data put in the four positions in the SIMD register.
648 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
649 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
650 int jnrA
,jnrB
,jnrC
,jnrD
;
651 int jnrlistA
,jnrlistB
,jnrlistC
,jnrlistD
;
652 int j_coord_offsetA
,j_coord_offsetB
,j_coord_offsetC
,j_coord_offsetD
;
653 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
655 real
*shiftvec
,*fshift
,*x
,*f
;
656 real
*fjptrA
,*fjptrB
,*fjptrC
,*fjptrD
;
658 __m128 tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
660 __m128 ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
662 __m128 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
664 __m128 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
666 __m128 ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
667 int vdwjidx0A
,vdwjidx0B
,vdwjidx0C
,vdwjidx0D
;
668 __m128 jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
669 __m128 dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
670 __m128 dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
671 __m128 dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
672 __m128 dx30
,dy30
,dz30
,rsq30
,rinv30
,rinvsq30
,r30
,qq30
,c6_30
,c12_30
;
673 __m128 velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
676 __m128 rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
679 __m128 one_sixth
= _mm_set1_ps(1.0/6.0);
680 __m128 one_twelfth
= _mm_set1_ps(1.0/12.0);
681 __m128 dummy_mask
,cutoff_mask
;
682 __m128 signbit
= _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
683 __m128 one
= _mm_set1_ps(1.0);
684 __m128 two
= _mm_set1_ps(2.0);
690 jindex
= nlist
->jindex
;
692 shiftidx
= nlist
->shift
;
694 shiftvec
= fr
->shift_vec
[0];
695 fshift
= fr
->fshift
[0];
696 facel
= _mm_set1_ps(fr
->epsfac
);
697 charge
= mdatoms
->chargeA
;
698 krf
= _mm_set1_ps(fr
->ic
->k_rf
);
699 krf2
= _mm_set1_ps(fr
->ic
->k_rf
*2.0);
700 crf
= _mm_set1_ps(fr
->ic
->c_rf
);
701 nvdwtype
= fr
->ntype
;
703 vdwtype
= mdatoms
->typeA
;
705 /* Setup water-specific parameters */
706 inr
= nlist
->iinr
[0];
707 iq1
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+1]));
708 iq2
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+2]));
709 iq3
= _mm_mul_ps(facel
,_mm_set1_ps(charge
[inr
+3]));
710 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
712 /* Avoid stupid compiler warnings */
713 jnrA
= jnrB
= jnrC
= jnrD
= 0;
722 for(iidx
=0;iidx
<4*DIM
;iidx
++)
727 /* Start outer loop over neighborlists */
728 for(iidx
=0; iidx
<nri
; iidx
++)
730 /* Load shift vector for this list */
731 i_shift_offset
= DIM
*shiftidx
[iidx
];
733 /* Load limits for loop over neighbors */
734 j_index_start
= jindex
[iidx
];
735 j_index_end
= jindex
[iidx
+1];
737 /* Get outer coordinate index */
739 i_coord_offset
= DIM
*inr
;
741 /* Load i particle coords and add shift vector */
742 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
743 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
,&ix3
,&iy3
,&iz3
);
745 fix0
= _mm_setzero_ps();
746 fiy0
= _mm_setzero_ps();
747 fiz0
= _mm_setzero_ps();
748 fix1
= _mm_setzero_ps();
749 fiy1
= _mm_setzero_ps();
750 fiz1
= _mm_setzero_ps();
751 fix2
= _mm_setzero_ps();
752 fiy2
= _mm_setzero_ps();
753 fiz2
= _mm_setzero_ps();
754 fix3
= _mm_setzero_ps();
755 fiy3
= _mm_setzero_ps();
756 fiz3
= _mm_setzero_ps();
758 /* Start inner kernel loop */
759 for(jidx
=j_index_start
; jidx
<j_index_end
&& jjnr
[jidx
+3]>=0; jidx
+=4)
762 /* Get j neighbor index, and coordinate index */
767 j_coord_offsetA
= DIM
*jnrA
;
768 j_coord_offsetB
= DIM
*jnrB
;
769 j_coord_offsetC
= DIM
*jnrC
;
770 j_coord_offsetD
= DIM
*jnrD
;
772 /* load j atom coordinates */
773 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
774 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
777 /* Calculate displacement vector */
778 dx00
= _mm_sub_ps(ix0
,jx0
);
779 dy00
= _mm_sub_ps(iy0
,jy0
);
780 dz00
= _mm_sub_ps(iz0
,jz0
);
781 dx10
= _mm_sub_ps(ix1
,jx0
);
782 dy10
= _mm_sub_ps(iy1
,jy0
);
783 dz10
= _mm_sub_ps(iz1
,jz0
);
784 dx20
= _mm_sub_ps(ix2
,jx0
);
785 dy20
= _mm_sub_ps(iy2
,jy0
);
786 dz20
= _mm_sub_ps(iz2
,jz0
);
787 dx30
= _mm_sub_ps(ix3
,jx0
);
788 dy30
= _mm_sub_ps(iy3
,jy0
);
789 dz30
= _mm_sub_ps(iz3
,jz0
);
791 /* Calculate squared distance and things based on it */
792 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
793 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
794 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
795 rsq30
= gmx_mm_calc_rsq_ps(dx30
,dy30
,dz30
);
797 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
798 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
799 rinv30
= gmx_mm_invsqrt_ps(rsq30
);
801 rinvsq00
= gmx_mm_inv_ps(rsq00
);
802 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
803 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
804 rinvsq30
= _mm_mul_ps(rinv30
,rinv30
);
806 /* Load parameters for j particles */
807 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
808 charge
+jnrC
+0,charge
+jnrD
+0);
809 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
810 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
811 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
812 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
814 fjx0
= _mm_setzero_ps();
815 fjy0
= _mm_setzero_ps();
816 fjz0
= _mm_setzero_ps();
818 /**************************
819 * CALCULATE INTERACTIONS *
820 **************************/
822 /* Compute parameters for interactions between i and j atoms */
823 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
824 vdwparam
+vdwioffset0
+vdwjidx0B
,
825 vdwparam
+vdwioffset0
+vdwjidx0C
,
826 vdwparam
+vdwioffset0
+vdwjidx0D
,
829 /* LENNARD-JONES DISPERSION/REPULSION */
831 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
832 fvdw
= _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00
,rinvsix
),c6_00
),_mm_mul_ps(rinvsix
,rinvsq00
));
836 /* Calculate temporary vectorial force */
837 tx
= _mm_mul_ps(fscal
,dx00
);
838 ty
= _mm_mul_ps(fscal
,dy00
);
839 tz
= _mm_mul_ps(fscal
,dz00
);
841 /* Update vectorial force */
842 fix0
= _mm_add_ps(fix0
,tx
);
843 fiy0
= _mm_add_ps(fiy0
,ty
);
844 fiz0
= _mm_add_ps(fiz0
,tz
);
846 fjx0
= _mm_add_ps(fjx0
,tx
);
847 fjy0
= _mm_add_ps(fjy0
,ty
);
848 fjz0
= _mm_add_ps(fjz0
,tz
);
850 /**************************
851 * CALCULATE INTERACTIONS *
852 **************************/
854 /* Compute parameters for interactions between i and j atoms */
855 qq10
= _mm_mul_ps(iq1
,jq0
);
857 /* REACTION-FIELD ELECTROSTATICS */
858 felec
= _mm_mul_ps(qq10
,_mm_sub_ps(_mm_mul_ps(rinv10
,rinvsq10
),krf2
));
862 /* Calculate temporary vectorial force */
863 tx
= _mm_mul_ps(fscal
,dx10
);
864 ty
= _mm_mul_ps(fscal
,dy10
);
865 tz
= _mm_mul_ps(fscal
,dz10
);
867 /* Update vectorial force */
868 fix1
= _mm_add_ps(fix1
,tx
);
869 fiy1
= _mm_add_ps(fiy1
,ty
);
870 fiz1
= _mm_add_ps(fiz1
,tz
);
872 fjx0
= _mm_add_ps(fjx0
,tx
);
873 fjy0
= _mm_add_ps(fjy0
,ty
);
874 fjz0
= _mm_add_ps(fjz0
,tz
);
876 /**************************
877 * CALCULATE INTERACTIONS *
878 **************************/
880 /* Compute parameters for interactions between i and j atoms */
881 qq20
= _mm_mul_ps(iq2
,jq0
);
883 /* REACTION-FIELD ELECTROSTATICS */
884 felec
= _mm_mul_ps(qq20
,_mm_sub_ps(_mm_mul_ps(rinv20
,rinvsq20
),krf2
));
888 /* Calculate temporary vectorial force */
889 tx
= _mm_mul_ps(fscal
,dx20
);
890 ty
= _mm_mul_ps(fscal
,dy20
);
891 tz
= _mm_mul_ps(fscal
,dz20
);
893 /* Update vectorial force */
894 fix2
= _mm_add_ps(fix2
,tx
);
895 fiy2
= _mm_add_ps(fiy2
,ty
);
896 fiz2
= _mm_add_ps(fiz2
,tz
);
898 fjx0
= _mm_add_ps(fjx0
,tx
);
899 fjy0
= _mm_add_ps(fjy0
,ty
);
900 fjz0
= _mm_add_ps(fjz0
,tz
);
902 /**************************
903 * CALCULATE INTERACTIONS *
904 **************************/
906 /* Compute parameters for interactions between i and j atoms */
907 qq30
= _mm_mul_ps(iq3
,jq0
);
909 /* REACTION-FIELD ELECTROSTATICS */
910 felec
= _mm_mul_ps(qq30
,_mm_sub_ps(_mm_mul_ps(rinv30
,rinvsq30
),krf2
));
914 /* Calculate temporary vectorial force */
915 tx
= _mm_mul_ps(fscal
,dx30
);
916 ty
= _mm_mul_ps(fscal
,dy30
);
917 tz
= _mm_mul_ps(fscal
,dz30
);
919 /* Update vectorial force */
920 fix3
= _mm_add_ps(fix3
,tx
);
921 fiy3
= _mm_add_ps(fiy3
,ty
);
922 fiz3
= _mm_add_ps(fiz3
,tz
);
924 fjx0
= _mm_add_ps(fjx0
,tx
);
925 fjy0
= _mm_add_ps(fjy0
,ty
);
926 fjz0
= _mm_add_ps(fjz0
,tz
);
928 fjptrA
= f
+j_coord_offsetA
;
929 fjptrB
= f
+j_coord_offsetB
;
930 fjptrC
= f
+j_coord_offsetC
;
931 fjptrD
= f
+j_coord_offsetD
;
933 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
935 /* Inner loop uses 108 flops */
941 /* Get j neighbor index, and coordinate index */
942 jnrlistA
= jjnr
[jidx
];
943 jnrlistB
= jjnr
[jidx
+1];
944 jnrlistC
= jjnr
[jidx
+2];
945 jnrlistD
= jjnr
[jidx
+3];
946 /* Sign of each element will be negative for non-real atoms.
947 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
948 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
950 dummy_mask
= gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i
*)(jjnr
+jidx
)),_mm_setzero_si128()));
951 jnrA
= (jnrlistA
>=0) ? jnrlistA
: 0;
952 jnrB
= (jnrlistB
>=0) ? jnrlistB
: 0;
953 jnrC
= (jnrlistC
>=0) ? jnrlistC
: 0;
954 jnrD
= (jnrlistD
>=0) ? jnrlistD
: 0;
955 j_coord_offsetA
= DIM
*jnrA
;
956 j_coord_offsetB
= DIM
*jnrB
;
957 j_coord_offsetC
= DIM
*jnrC
;
958 j_coord_offsetD
= DIM
*jnrD
;
960 /* load j atom coordinates */
961 gmx_mm_load_1rvec_4ptr_swizzle_ps(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
962 x
+j_coord_offsetC
,x
+j_coord_offsetD
,
965 /* Calculate displacement vector */
966 dx00
= _mm_sub_ps(ix0
,jx0
);
967 dy00
= _mm_sub_ps(iy0
,jy0
);
968 dz00
= _mm_sub_ps(iz0
,jz0
);
969 dx10
= _mm_sub_ps(ix1
,jx0
);
970 dy10
= _mm_sub_ps(iy1
,jy0
);
971 dz10
= _mm_sub_ps(iz1
,jz0
);
972 dx20
= _mm_sub_ps(ix2
,jx0
);
973 dy20
= _mm_sub_ps(iy2
,jy0
);
974 dz20
= _mm_sub_ps(iz2
,jz0
);
975 dx30
= _mm_sub_ps(ix3
,jx0
);
976 dy30
= _mm_sub_ps(iy3
,jy0
);
977 dz30
= _mm_sub_ps(iz3
,jz0
);
979 /* Calculate squared distance and things based on it */
980 rsq00
= gmx_mm_calc_rsq_ps(dx00
,dy00
,dz00
);
981 rsq10
= gmx_mm_calc_rsq_ps(dx10
,dy10
,dz10
);
982 rsq20
= gmx_mm_calc_rsq_ps(dx20
,dy20
,dz20
);
983 rsq30
= gmx_mm_calc_rsq_ps(dx30
,dy30
,dz30
);
985 rinv10
= gmx_mm_invsqrt_ps(rsq10
);
986 rinv20
= gmx_mm_invsqrt_ps(rsq20
);
987 rinv30
= gmx_mm_invsqrt_ps(rsq30
);
989 rinvsq00
= gmx_mm_inv_ps(rsq00
);
990 rinvsq10
= _mm_mul_ps(rinv10
,rinv10
);
991 rinvsq20
= _mm_mul_ps(rinv20
,rinv20
);
992 rinvsq30
= _mm_mul_ps(rinv30
,rinv30
);
994 /* Load parameters for j particles */
995 jq0
= gmx_mm_load_4real_swizzle_ps(charge
+jnrA
+0,charge
+jnrB
+0,
996 charge
+jnrC
+0,charge
+jnrD
+0);
997 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
998 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
999 vdwjidx0C
= 2*vdwtype
[jnrC
+0];
1000 vdwjidx0D
= 2*vdwtype
[jnrD
+0];
1002 fjx0
= _mm_setzero_ps();
1003 fjy0
= _mm_setzero_ps();
1004 fjz0
= _mm_setzero_ps();
1006 /**************************
1007 * CALCULATE INTERACTIONS *
1008 **************************/
1010 /* Compute parameters for interactions between i and j atoms */
1011 gmx_mm_load_4pair_swizzle_ps(vdwparam
+vdwioffset0
+vdwjidx0A
,
1012 vdwparam
+vdwioffset0
+vdwjidx0B
,
1013 vdwparam
+vdwioffset0
+vdwjidx0C
,
1014 vdwparam
+vdwioffset0
+vdwjidx0D
,
1017 /* LENNARD-JONES DISPERSION/REPULSION */
1019 rinvsix
= _mm_mul_ps(_mm_mul_ps(rinvsq00
,rinvsq00
),rinvsq00
);
1020 fvdw
= _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00
,rinvsix
),c6_00
),_mm_mul_ps(rinvsix
,rinvsq00
));
1024 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1026 /* Calculate temporary vectorial force */
1027 tx
= _mm_mul_ps(fscal
,dx00
);
1028 ty
= _mm_mul_ps(fscal
,dy00
);
1029 tz
= _mm_mul_ps(fscal
,dz00
);
1031 /* Update vectorial force */
1032 fix0
= _mm_add_ps(fix0
,tx
);
1033 fiy0
= _mm_add_ps(fiy0
,ty
);
1034 fiz0
= _mm_add_ps(fiz0
,tz
);
1036 fjx0
= _mm_add_ps(fjx0
,tx
);
1037 fjy0
= _mm_add_ps(fjy0
,ty
);
1038 fjz0
= _mm_add_ps(fjz0
,tz
);
1040 /**************************
1041 * CALCULATE INTERACTIONS *
1042 **************************/
1044 /* Compute parameters for interactions between i and j atoms */
1045 qq10
= _mm_mul_ps(iq1
,jq0
);
1047 /* REACTION-FIELD ELECTROSTATICS */
1048 felec
= _mm_mul_ps(qq10
,_mm_sub_ps(_mm_mul_ps(rinv10
,rinvsq10
),krf2
));
1052 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1054 /* Calculate temporary vectorial force */
1055 tx
= _mm_mul_ps(fscal
,dx10
);
1056 ty
= _mm_mul_ps(fscal
,dy10
);
1057 tz
= _mm_mul_ps(fscal
,dz10
);
1059 /* Update vectorial force */
1060 fix1
= _mm_add_ps(fix1
,tx
);
1061 fiy1
= _mm_add_ps(fiy1
,ty
);
1062 fiz1
= _mm_add_ps(fiz1
,tz
);
1064 fjx0
= _mm_add_ps(fjx0
,tx
);
1065 fjy0
= _mm_add_ps(fjy0
,ty
);
1066 fjz0
= _mm_add_ps(fjz0
,tz
);
1068 /**************************
1069 * CALCULATE INTERACTIONS *
1070 **************************/
1072 /* Compute parameters for interactions between i and j atoms */
1073 qq20
= _mm_mul_ps(iq2
,jq0
);
1075 /* REACTION-FIELD ELECTROSTATICS */
1076 felec
= _mm_mul_ps(qq20
,_mm_sub_ps(_mm_mul_ps(rinv20
,rinvsq20
),krf2
));
1080 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1082 /* Calculate temporary vectorial force */
1083 tx
= _mm_mul_ps(fscal
,dx20
);
1084 ty
= _mm_mul_ps(fscal
,dy20
);
1085 tz
= _mm_mul_ps(fscal
,dz20
);
1087 /* Update vectorial force */
1088 fix2
= _mm_add_ps(fix2
,tx
);
1089 fiy2
= _mm_add_ps(fiy2
,ty
);
1090 fiz2
= _mm_add_ps(fiz2
,tz
);
1092 fjx0
= _mm_add_ps(fjx0
,tx
);
1093 fjy0
= _mm_add_ps(fjy0
,ty
);
1094 fjz0
= _mm_add_ps(fjz0
,tz
);
1096 /**************************
1097 * CALCULATE INTERACTIONS *
1098 **************************/
1100 /* Compute parameters for interactions between i and j atoms */
1101 qq30
= _mm_mul_ps(iq3
,jq0
);
1103 /* REACTION-FIELD ELECTROSTATICS */
1104 felec
= _mm_mul_ps(qq30
,_mm_sub_ps(_mm_mul_ps(rinv30
,rinvsq30
),krf2
));
1108 fscal
= _mm_andnot_ps(dummy_mask
,fscal
);
1110 /* Calculate temporary vectorial force */
1111 tx
= _mm_mul_ps(fscal
,dx30
);
1112 ty
= _mm_mul_ps(fscal
,dy30
);
1113 tz
= _mm_mul_ps(fscal
,dz30
);
1115 /* Update vectorial force */
1116 fix3
= _mm_add_ps(fix3
,tx
);
1117 fiy3
= _mm_add_ps(fiy3
,ty
);
1118 fiz3
= _mm_add_ps(fiz3
,tz
);
1120 fjx0
= _mm_add_ps(fjx0
,tx
);
1121 fjy0
= _mm_add_ps(fjy0
,ty
);
1122 fjz0
= _mm_add_ps(fjz0
,tz
);
1124 fjptrA
= (jnrlistA
>=0) ? f
+j_coord_offsetA
: scratch
;
1125 fjptrB
= (jnrlistB
>=0) ? f
+j_coord_offsetB
: scratch
;
1126 fjptrC
= (jnrlistC
>=0) ? f
+j_coord_offsetC
: scratch
;
1127 fjptrD
= (jnrlistD
>=0) ? f
+j_coord_offsetD
: scratch
;
1129 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA
,fjptrB
,fjptrC
,fjptrD
,fjx0
,fjy0
,fjz0
);
1131 /* Inner loop uses 108 flops */
1134 /* End of innermost loop */
1136 gmx_mm_update_iforce_4atom_swizzle_ps(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,fix3
,fiy3
,fiz3
,
1137 f
+i_coord_offset
,fshift
+i_shift_offset
);
1139 /* Increment number of inner iterations */
1140 inneriter
+= j_index_end
- j_index_start
;
1142 /* Outer loop uses 24 flops */
1145 /* Increment number of outer iterations */
1148 /* Update outer/inner flops */
1150 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4_F
,outeriter
*24 + inneriter
*108);