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_double 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_double.h"
49 #include "kernelutil_x86_sse2_double.h"
52 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW4W4_VF_sse2_double
53 * Electrostatics interaction: ReactionField
54 * VdW interaction: LennardJones
55 * Geometry: Water4-Water4
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecRF_VdwLJ_GeomW4W4_VF_sse2_double
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 refer to j loop unrolling done with SSE double precision, e.g. for the two 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
;
76 int j_coord_offsetA
,j_coord_offsetB
;
77 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
79 real
*shiftvec
,*fshift
,*x
,*f
;
80 __m128d tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
82 __m128d ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
84 __m128d ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
86 __m128d ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
88 __m128d ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
89 int vdwjidx0A
,vdwjidx0B
;
90 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
91 int vdwjidx1A
,vdwjidx1B
;
92 __m128d jx1
,jy1
,jz1
,fjx1
,fjy1
,fjz1
,jq1
,isaj1
;
93 int vdwjidx2A
,vdwjidx2B
;
94 __m128d jx2
,jy2
,jz2
,fjx2
,fjy2
,fjz2
,jq2
,isaj2
;
95 int vdwjidx3A
,vdwjidx3B
;
96 __m128d jx3
,jy3
,jz3
,fjx3
,fjy3
,fjz3
,jq3
,isaj3
;
97 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
98 __m128d dx11
,dy11
,dz11
,rsq11
,rinv11
,rinvsq11
,r11
,qq11
,c6_11
,c12_11
;
99 __m128d dx12
,dy12
,dz12
,rsq12
,rinv12
,rinvsq12
,r12
,qq12
,c6_12
,c12_12
;
100 __m128d dx13
,dy13
,dz13
,rsq13
,rinv13
,rinvsq13
,r13
,qq13
,c6_13
,c12_13
;
101 __m128d dx21
,dy21
,dz21
,rsq21
,rinv21
,rinvsq21
,r21
,qq21
,c6_21
,c12_21
;
102 __m128d dx22
,dy22
,dz22
,rsq22
,rinv22
,rinvsq22
,r22
,qq22
,c6_22
,c12_22
;
103 __m128d dx23
,dy23
,dz23
,rsq23
,rinv23
,rinvsq23
,r23
,qq23
,c6_23
,c12_23
;
104 __m128d dx31
,dy31
,dz31
,rsq31
,rinv31
,rinvsq31
,r31
,qq31
,c6_31
,c12_31
;
105 __m128d dx32
,dy32
,dz32
,rsq32
,rinv32
,rinvsq32
,r32
,qq32
,c6_32
,c12_32
;
106 __m128d dx33
,dy33
,dz33
,rsq33
,rinv33
,rinvsq33
,r33
,qq33
,c6_33
,c12_33
;
107 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
110 __m128d rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
113 __m128d one_sixth
= _mm_set1_pd(1.0/6.0);
114 __m128d one_twelfth
= _mm_set1_pd(1.0/12.0);
115 __m128d dummy_mask
,cutoff_mask
;
116 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
117 __m128d one
= _mm_set1_pd(1.0);
118 __m128d two
= _mm_set1_pd(2.0);
124 jindex
= nlist
->jindex
;
126 shiftidx
= nlist
->shift
;
128 shiftvec
= fr
->shift_vec
[0];
129 fshift
= fr
->fshift
[0];
130 facel
= _mm_set1_pd(fr
->epsfac
);
131 charge
= mdatoms
->chargeA
;
132 krf
= _mm_set1_pd(fr
->ic
->k_rf
);
133 krf2
= _mm_set1_pd(fr
->ic
->k_rf
*2.0);
134 crf
= _mm_set1_pd(fr
->ic
->c_rf
);
135 nvdwtype
= fr
->ntype
;
137 vdwtype
= mdatoms
->typeA
;
139 /* Setup water-specific parameters */
140 inr
= nlist
->iinr
[0];
141 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
142 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
143 iq3
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+3]));
144 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
146 jq1
= _mm_set1_pd(charge
[inr
+1]);
147 jq2
= _mm_set1_pd(charge
[inr
+2]);
148 jq3
= _mm_set1_pd(charge
[inr
+3]);
149 vdwjidx0A
= 2*vdwtype
[inr
+0];
150 c6_00
= _mm_set1_pd(vdwparam
[vdwioffset0
+vdwjidx0A
]);
151 c12_00
= _mm_set1_pd(vdwparam
[vdwioffset0
+vdwjidx0A
+1]);
152 qq11
= _mm_mul_pd(iq1
,jq1
);
153 qq12
= _mm_mul_pd(iq1
,jq2
);
154 qq13
= _mm_mul_pd(iq1
,jq3
);
155 qq21
= _mm_mul_pd(iq2
,jq1
);
156 qq22
= _mm_mul_pd(iq2
,jq2
);
157 qq23
= _mm_mul_pd(iq2
,jq3
);
158 qq31
= _mm_mul_pd(iq3
,jq1
);
159 qq32
= _mm_mul_pd(iq3
,jq2
);
160 qq33
= _mm_mul_pd(iq3
,jq3
);
162 /* Avoid stupid compiler warnings */
170 /* Start outer loop over neighborlists */
171 for(iidx
=0; iidx
<nri
; iidx
++)
173 /* Load shift vector for this list */
174 i_shift_offset
= DIM
*shiftidx
[iidx
];
176 /* Load limits for loop over neighbors */
177 j_index_start
= jindex
[iidx
];
178 j_index_end
= jindex
[iidx
+1];
180 /* Get outer coordinate index */
182 i_coord_offset
= DIM
*inr
;
184 /* Load i particle coords and add shift vector */
185 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
186 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
,&ix3
,&iy3
,&iz3
);
188 fix0
= _mm_setzero_pd();
189 fiy0
= _mm_setzero_pd();
190 fiz0
= _mm_setzero_pd();
191 fix1
= _mm_setzero_pd();
192 fiy1
= _mm_setzero_pd();
193 fiz1
= _mm_setzero_pd();
194 fix2
= _mm_setzero_pd();
195 fiy2
= _mm_setzero_pd();
196 fiz2
= _mm_setzero_pd();
197 fix3
= _mm_setzero_pd();
198 fiy3
= _mm_setzero_pd();
199 fiz3
= _mm_setzero_pd();
201 /* Reset potential sums */
202 velecsum
= _mm_setzero_pd();
203 vvdwsum
= _mm_setzero_pd();
205 /* Start inner kernel loop */
206 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
209 /* Get j neighbor index, and coordinate index */
212 j_coord_offsetA
= DIM
*jnrA
;
213 j_coord_offsetB
= DIM
*jnrB
;
215 /* load j atom coordinates */
216 gmx_mm_load_4rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
217 &jx0
,&jy0
,&jz0
,&jx1
,&jy1
,&jz1
,&jx2
,
218 &jy2
,&jz2
,&jx3
,&jy3
,&jz3
);
220 /* Calculate displacement vector */
221 dx00
= _mm_sub_pd(ix0
,jx0
);
222 dy00
= _mm_sub_pd(iy0
,jy0
);
223 dz00
= _mm_sub_pd(iz0
,jz0
);
224 dx11
= _mm_sub_pd(ix1
,jx1
);
225 dy11
= _mm_sub_pd(iy1
,jy1
);
226 dz11
= _mm_sub_pd(iz1
,jz1
);
227 dx12
= _mm_sub_pd(ix1
,jx2
);
228 dy12
= _mm_sub_pd(iy1
,jy2
);
229 dz12
= _mm_sub_pd(iz1
,jz2
);
230 dx13
= _mm_sub_pd(ix1
,jx3
);
231 dy13
= _mm_sub_pd(iy1
,jy3
);
232 dz13
= _mm_sub_pd(iz1
,jz3
);
233 dx21
= _mm_sub_pd(ix2
,jx1
);
234 dy21
= _mm_sub_pd(iy2
,jy1
);
235 dz21
= _mm_sub_pd(iz2
,jz1
);
236 dx22
= _mm_sub_pd(ix2
,jx2
);
237 dy22
= _mm_sub_pd(iy2
,jy2
);
238 dz22
= _mm_sub_pd(iz2
,jz2
);
239 dx23
= _mm_sub_pd(ix2
,jx3
);
240 dy23
= _mm_sub_pd(iy2
,jy3
);
241 dz23
= _mm_sub_pd(iz2
,jz3
);
242 dx31
= _mm_sub_pd(ix3
,jx1
);
243 dy31
= _mm_sub_pd(iy3
,jy1
);
244 dz31
= _mm_sub_pd(iz3
,jz1
);
245 dx32
= _mm_sub_pd(ix3
,jx2
);
246 dy32
= _mm_sub_pd(iy3
,jy2
);
247 dz32
= _mm_sub_pd(iz3
,jz2
);
248 dx33
= _mm_sub_pd(ix3
,jx3
);
249 dy33
= _mm_sub_pd(iy3
,jy3
);
250 dz33
= _mm_sub_pd(iz3
,jz3
);
252 /* Calculate squared distance and things based on it */
253 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
254 rsq11
= gmx_mm_calc_rsq_pd(dx11
,dy11
,dz11
);
255 rsq12
= gmx_mm_calc_rsq_pd(dx12
,dy12
,dz12
);
256 rsq13
= gmx_mm_calc_rsq_pd(dx13
,dy13
,dz13
);
257 rsq21
= gmx_mm_calc_rsq_pd(dx21
,dy21
,dz21
);
258 rsq22
= gmx_mm_calc_rsq_pd(dx22
,dy22
,dz22
);
259 rsq23
= gmx_mm_calc_rsq_pd(dx23
,dy23
,dz23
);
260 rsq31
= gmx_mm_calc_rsq_pd(dx31
,dy31
,dz31
);
261 rsq32
= gmx_mm_calc_rsq_pd(dx32
,dy32
,dz32
);
262 rsq33
= gmx_mm_calc_rsq_pd(dx33
,dy33
,dz33
);
264 rinv11
= gmx_mm_invsqrt_pd(rsq11
);
265 rinv12
= gmx_mm_invsqrt_pd(rsq12
);
266 rinv13
= gmx_mm_invsqrt_pd(rsq13
);
267 rinv21
= gmx_mm_invsqrt_pd(rsq21
);
268 rinv22
= gmx_mm_invsqrt_pd(rsq22
);
269 rinv23
= gmx_mm_invsqrt_pd(rsq23
);
270 rinv31
= gmx_mm_invsqrt_pd(rsq31
);
271 rinv32
= gmx_mm_invsqrt_pd(rsq32
);
272 rinv33
= gmx_mm_invsqrt_pd(rsq33
);
274 rinvsq00
= gmx_mm_inv_pd(rsq00
);
275 rinvsq11
= _mm_mul_pd(rinv11
,rinv11
);
276 rinvsq12
= _mm_mul_pd(rinv12
,rinv12
);
277 rinvsq13
= _mm_mul_pd(rinv13
,rinv13
);
278 rinvsq21
= _mm_mul_pd(rinv21
,rinv21
);
279 rinvsq22
= _mm_mul_pd(rinv22
,rinv22
);
280 rinvsq23
= _mm_mul_pd(rinv23
,rinv23
);
281 rinvsq31
= _mm_mul_pd(rinv31
,rinv31
);
282 rinvsq32
= _mm_mul_pd(rinv32
,rinv32
);
283 rinvsq33
= _mm_mul_pd(rinv33
,rinv33
);
285 fjx0
= _mm_setzero_pd();
286 fjy0
= _mm_setzero_pd();
287 fjz0
= _mm_setzero_pd();
288 fjx1
= _mm_setzero_pd();
289 fjy1
= _mm_setzero_pd();
290 fjz1
= _mm_setzero_pd();
291 fjx2
= _mm_setzero_pd();
292 fjy2
= _mm_setzero_pd();
293 fjz2
= _mm_setzero_pd();
294 fjx3
= _mm_setzero_pd();
295 fjy3
= _mm_setzero_pd();
296 fjz3
= _mm_setzero_pd();
298 /**************************
299 * CALCULATE INTERACTIONS *
300 **************************/
302 /* LENNARD-JONES DISPERSION/REPULSION */
304 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
305 vvdw6
= _mm_mul_pd(c6_00
,rinvsix
);
306 vvdw12
= _mm_mul_pd(c12_00
,_mm_mul_pd(rinvsix
,rinvsix
));
307 vvdw
= _mm_sub_pd( _mm_mul_pd(vvdw12
,one_twelfth
) , _mm_mul_pd(vvdw6
,one_sixth
) );
308 fvdw
= _mm_mul_pd(_mm_sub_pd(vvdw12
,vvdw6
),rinvsq00
);
310 /* Update potential sum for this i atom from the interaction with this j atom. */
311 vvdwsum
= _mm_add_pd(vvdwsum
,vvdw
);
315 /* Calculate temporary vectorial force */
316 tx
= _mm_mul_pd(fscal
,dx00
);
317 ty
= _mm_mul_pd(fscal
,dy00
);
318 tz
= _mm_mul_pd(fscal
,dz00
);
320 /* Update vectorial force */
321 fix0
= _mm_add_pd(fix0
,tx
);
322 fiy0
= _mm_add_pd(fiy0
,ty
);
323 fiz0
= _mm_add_pd(fiz0
,tz
);
325 fjx0
= _mm_add_pd(fjx0
,tx
);
326 fjy0
= _mm_add_pd(fjy0
,ty
);
327 fjz0
= _mm_add_pd(fjz0
,tz
);
329 /**************************
330 * CALCULATE INTERACTIONS *
331 **************************/
333 /* REACTION-FIELD ELECTROSTATICS */
334 velec
= _mm_mul_pd(qq11
,_mm_sub_pd(_mm_add_pd(rinv11
,_mm_mul_pd(krf
,rsq11
)),crf
));
335 felec
= _mm_mul_pd(qq11
,_mm_sub_pd(_mm_mul_pd(rinv11
,rinvsq11
),krf2
));
337 /* Update potential sum for this i atom from the interaction with this j atom. */
338 velecsum
= _mm_add_pd(velecsum
,velec
);
342 /* Calculate temporary vectorial force */
343 tx
= _mm_mul_pd(fscal
,dx11
);
344 ty
= _mm_mul_pd(fscal
,dy11
);
345 tz
= _mm_mul_pd(fscal
,dz11
);
347 /* Update vectorial force */
348 fix1
= _mm_add_pd(fix1
,tx
);
349 fiy1
= _mm_add_pd(fiy1
,ty
);
350 fiz1
= _mm_add_pd(fiz1
,tz
);
352 fjx1
= _mm_add_pd(fjx1
,tx
);
353 fjy1
= _mm_add_pd(fjy1
,ty
);
354 fjz1
= _mm_add_pd(fjz1
,tz
);
356 /**************************
357 * CALCULATE INTERACTIONS *
358 **************************/
360 /* REACTION-FIELD ELECTROSTATICS */
361 velec
= _mm_mul_pd(qq12
,_mm_sub_pd(_mm_add_pd(rinv12
,_mm_mul_pd(krf
,rsq12
)),crf
));
362 felec
= _mm_mul_pd(qq12
,_mm_sub_pd(_mm_mul_pd(rinv12
,rinvsq12
),krf2
));
364 /* Update potential sum for this i atom from the interaction with this j atom. */
365 velecsum
= _mm_add_pd(velecsum
,velec
);
369 /* Calculate temporary vectorial force */
370 tx
= _mm_mul_pd(fscal
,dx12
);
371 ty
= _mm_mul_pd(fscal
,dy12
);
372 tz
= _mm_mul_pd(fscal
,dz12
);
374 /* Update vectorial force */
375 fix1
= _mm_add_pd(fix1
,tx
);
376 fiy1
= _mm_add_pd(fiy1
,ty
);
377 fiz1
= _mm_add_pd(fiz1
,tz
);
379 fjx2
= _mm_add_pd(fjx2
,tx
);
380 fjy2
= _mm_add_pd(fjy2
,ty
);
381 fjz2
= _mm_add_pd(fjz2
,tz
);
383 /**************************
384 * CALCULATE INTERACTIONS *
385 **************************/
387 /* REACTION-FIELD ELECTROSTATICS */
388 velec
= _mm_mul_pd(qq13
,_mm_sub_pd(_mm_add_pd(rinv13
,_mm_mul_pd(krf
,rsq13
)),crf
));
389 felec
= _mm_mul_pd(qq13
,_mm_sub_pd(_mm_mul_pd(rinv13
,rinvsq13
),krf2
));
391 /* Update potential sum for this i atom from the interaction with this j atom. */
392 velecsum
= _mm_add_pd(velecsum
,velec
);
396 /* Calculate temporary vectorial force */
397 tx
= _mm_mul_pd(fscal
,dx13
);
398 ty
= _mm_mul_pd(fscal
,dy13
);
399 tz
= _mm_mul_pd(fscal
,dz13
);
401 /* Update vectorial force */
402 fix1
= _mm_add_pd(fix1
,tx
);
403 fiy1
= _mm_add_pd(fiy1
,ty
);
404 fiz1
= _mm_add_pd(fiz1
,tz
);
406 fjx3
= _mm_add_pd(fjx3
,tx
);
407 fjy3
= _mm_add_pd(fjy3
,ty
);
408 fjz3
= _mm_add_pd(fjz3
,tz
);
410 /**************************
411 * CALCULATE INTERACTIONS *
412 **************************/
414 /* REACTION-FIELD ELECTROSTATICS */
415 velec
= _mm_mul_pd(qq21
,_mm_sub_pd(_mm_add_pd(rinv21
,_mm_mul_pd(krf
,rsq21
)),crf
));
416 felec
= _mm_mul_pd(qq21
,_mm_sub_pd(_mm_mul_pd(rinv21
,rinvsq21
),krf2
));
418 /* Update potential sum for this i atom from the interaction with this j atom. */
419 velecsum
= _mm_add_pd(velecsum
,velec
);
423 /* Calculate temporary vectorial force */
424 tx
= _mm_mul_pd(fscal
,dx21
);
425 ty
= _mm_mul_pd(fscal
,dy21
);
426 tz
= _mm_mul_pd(fscal
,dz21
);
428 /* Update vectorial force */
429 fix2
= _mm_add_pd(fix2
,tx
);
430 fiy2
= _mm_add_pd(fiy2
,ty
);
431 fiz2
= _mm_add_pd(fiz2
,tz
);
433 fjx1
= _mm_add_pd(fjx1
,tx
);
434 fjy1
= _mm_add_pd(fjy1
,ty
);
435 fjz1
= _mm_add_pd(fjz1
,tz
);
437 /**************************
438 * CALCULATE INTERACTIONS *
439 **************************/
441 /* REACTION-FIELD ELECTROSTATICS */
442 velec
= _mm_mul_pd(qq22
,_mm_sub_pd(_mm_add_pd(rinv22
,_mm_mul_pd(krf
,rsq22
)),crf
));
443 felec
= _mm_mul_pd(qq22
,_mm_sub_pd(_mm_mul_pd(rinv22
,rinvsq22
),krf2
));
445 /* Update potential sum for this i atom from the interaction with this j atom. */
446 velecsum
= _mm_add_pd(velecsum
,velec
);
450 /* Calculate temporary vectorial force */
451 tx
= _mm_mul_pd(fscal
,dx22
);
452 ty
= _mm_mul_pd(fscal
,dy22
);
453 tz
= _mm_mul_pd(fscal
,dz22
);
455 /* Update vectorial force */
456 fix2
= _mm_add_pd(fix2
,tx
);
457 fiy2
= _mm_add_pd(fiy2
,ty
);
458 fiz2
= _mm_add_pd(fiz2
,tz
);
460 fjx2
= _mm_add_pd(fjx2
,tx
);
461 fjy2
= _mm_add_pd(fjy2
,ty
);
462 fjz2
= _mm_add_pd(fjz2
,tz
);
464 /**************************
465 * CALCULATE INTERACTIONS *
466 **************************/
468 /* REACTION-FIELD ELECTROSTATICS */
469 velec
= _mm_mul_pd(qq23
,_mm_sub_pd(_mm_add_pd(rinv23
,_mm_mul_pd(krf
,rsq23
)),crf
));
470 felec
= _mm_mul_pd(qq23
,_mm_sub_pd(_mm_mul_pd(rinv23
,rinvsq23
),krf2
));
472 /* Update potential sum for this i atom from the interaction with this j atom. */
473 velecsum
= _mm_add_pd(velecsum
,velec
);
477 /* Calculate temporary vectorial force */
478 tx
= _mm_mul_pd(fscal
,dx23
);
479 ty
= _mm_mul_pd(fscal
,dy23
);
480 tz
= _mm_mul_pd(fscal
,dz23
);
482 /* Update vectorial force */
483 fix2
= _mm_add_pd(fix2
,tx
);
484 fiy2
= _mm_add_pd(fiy2
,ty
);
485 fiz2
= _mm_add_pd(fiz2
,tz
);
487 fjx3
= _mm_add_pd(fjx3
,tx
);
488 fjy3
= _mm_add_pd(fjy3
,ty
);
489 fjz3
= _mm_add_pd(fjz3
,tz
);
491 /**************************
492 * CALCULATE INTERACTIONS *
493 **************************/
495 /* REACTION-FIELD ELECTROSTATICS */
496 velec
= _mm_mul_pd(qq31
,_mm_sub_pd(_mm_add_pd(rinv31
,_mm_mul_pd(krf
,rsq31
)),crf
));
497 felec
= _mm_mul_pd(qq31
,_mm_sub_pd(_mm_mul_pd(rinv31
,rinvsq31
),krf2
));
499 /* Update potential sum for this i atom from the interaction with this j atom. */
500 velecsum
= _mm_add_pd(velecsum
,velec
);
504 /* Calculate temporary vectorial force */
505 tx
= _mm_mul_pd(fscal
,dx31
);
506 ty
= _mm_mul_pd(fscal
,dy31
);
507 tz
= _mm_mul_pd(fscal
,dz31
);
509 /* Update vectorial force */
510 fix3
= _mm_add_pd(fix3
,tx
);
511 fiy3
= _mm_add_pd(fiy3
,ty
);
512 fiz3
= _mm_add_pd(fiz3
,tz
);
514 fjx1
= _mm_add_pd(fjx1
,tx
);
515 fjy1
= _mm_add_pd(fjy1
,ty
);
516 fjz1
= _mm_add_pd(fjz1
,tz
);
518 /**************************
519 * CALCULATE INTERACTIONS *
520 **************************/
522 /* REACTION-FIELD ELECTROSTATICS */
523 velec
= _mm_mul_pd(qq32
,_mm_sub_pd(_mm_add_pd(rinv32
,_mm_mul_pd(krf
,rsq32
)),crf
));
524 felec
= _mm_mul_pd(qq32
,_mm_sub_pd(_mm_mul_pd(rinv32
,rinvsq32
),krf2
));
526 /* Update potential sum for this i atom from the interaction with this j atom. */
527 velecsum
= _mm_add_pd(velecsum
,velec
);
531 /* Calculate temporary vectorial force */
532 tx
= _mm_mul_pd(fscal
,dx32
);
533 ty
= _mm_mul_pd(fscal
,dy32
);
534 tz
= _mm_mul_pd(fscal
,dz32
);
536 /* Update vectorial force */
537 fix3
= _mm_add_pd(fix3
,tx
);
538 fiy3
= _mm_add_pd(fiy3
,ty
);
539 fiz3
= _mm_add_pd(fiz3
,tz
);
541 fjx2
= _mm_add_pd(fjx2
,tx
);
542 fjy2
= _mm_add_pd(fjy2
,ty
);
543 fjz2
= _mm_add_pd(fjz2
,tz
);
545 /**************************
546 * CALCULATE INTERACTIONS *
547 **************************/
549 /* REACTION-FIELD ELECTROSTATICS */
550 velec
= _mm_mul_pd(qq33
,_mm_sub_pd(_mm_add_pd(rinv33
,_mm_mul_pd(krf
,rsq33
)),crf
));
551 felec
= _mm_mul_pd(qq33
,_mm_sub_pd(_mm_mul_pd(rinv33
,rinvsq33
),krf2
));
553 /* Update potential sum for this i atom from the interaction with this j atom. */
554 velecsum
= _mm_add_pd(velecsum
,velec
);
558 /* Calculate temporary vectorial force */
559 tx
= _mm_mul_pd(fscal
,dx33
);
560 ty
= _mm_mul_pd(fscal
,dy33
);
561 tz
= _mm_mul_pd(fscal
,dz33
);
563 /* Update vectorial force */
564 fix3
= _mm_add_pd(fix3
,tx
);
565 fiy3
= _mm_add_pd(fiy3
,ty
);
566 fiz3
= _mm_add_pd(fiz3
,tz
);
568 fjx3
= _mm_add_pd(fjx3
,tx
);
569 fjy3
= _mm_add_pd(fjy3
,ty
);
570 fjz3
= _mm_add_pd(fjz3
,tz
);
572 gmx_mm_decrement_4rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
,fjx1
,fjy1
,fjz1
,fjx2
,fjy2
,fjz2
,fjx3
,fjy3
,fjz3
);
574 /* Inner loop uses 323 flops */
581 j_coord_offsetA
= DIM
*jnrA
;
583 /* load j atom coordinates */
584 gmx_mm_load_4rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
585 &jx0
,&jy0
,&jz0
,&jx1
,&jy1
,&jz1
,&jx2
,
586 &jy2
,&jz2
,&jx3
,&jy3
,&jz3
);
588 /* Calculate displacement vector */
589 dx00
= _mm_sub_pd(ix0
,jx0
);
590 dy00
= _mm_sub_pd(iy0
,jy0
);
591 dz00
= _mm_sub_pd(iz0
,jz0
);
592 dx11
= _mm_sub_pd(ix1
,jx1
);
593 dy11
= _mm_sub_pd(iy1
,jy1
);
594 dz11
= _mm_sub_pd(iz1
,jz1
);
595 dx12
= _mm_sub_pd(ix1
,jx2
);
596 dy12
= _mm_sub_pd(iy1
,jy2
);
597 dz12
= _mm_sub_pd(iz1
,jz2
);
598 dx13
= _mm_sub_pd(ix1
,jx3
);
599 dy13
= _mm_sub_pd(iy1
,jy3
);
600 dz13
= _mm_sub_pd(iz1
,jz3
);
601 dx21
= _mm_sub_pd(ix2
,jx1
);
602 dy21
= _mm_sub_pd(iy2
,jy1
);
603 dz21
= _mm_sub_pd(iz2
,jz1
);
604 dx22
= _mm_sub_pd(ix2
,jx2
);
605 dy22
= _mm_sub_pd(iy2
,jy2
);
606 dz22
= _mm_sub_pd(iz2
,jz2
);
607 dx23
= _mm_sub_pd(ix2
,jx3
);
608 dy23
= _mm_sub_pd(iy2
,jy3
);
609 dz23
= _mm_sub_pd(iz2
,jz3
);
610 dx31
= _mm_sub_pd(ix3
,jx1
);
611 dy31
= _mm_sub_pd(iy3
,jy1
);
612 dz31
= _mm_sub_pd(iz3
,jz1
);
613 dx32
= _mm_sub_pd(ix3
,jx2
);
614 dy32
= _mm_sub_pd(iy3
,jy2
);
615 dz32
= _mm_sub_pd(iz3
,jz2
);
616 dx33
= _mm_sub_pd(ix3
,jx3
);
617 dy33
= _mm_sub_pd(iy3
,jy3
);
618 dz33
= _mm_sub_pd(iz3
,jz3
);
620 /* Calculate squared distance and things based on it */
621 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
622 rsq11
= gmx_mm_calc_rsq_pd(dx11
,dy11
,dz11
);
623 rsq12
= gmx_mm_calc_rsq_pd(dx12
,dy12
,dz12
);
624 rsq13
= gmx_mm_calc_rsq_pd(dx13
,dy13
,dz13
);
625 rsq21
= gmx_mm_calc_rsq_pd(dx21
,dy21
,dz21
);
626 rsq22
= gmx_mm_calc_rsq_pd(dx22
,dy22
,dz22
);
627 rsq23
= gmx_mm_calc_rsq_pd(dx23
,dy23
,dz23
);
628 rsq31
= gmx_mm_calc_rsq_pd(dx31
,dy31
,dz31
);
629 rsq32
= gmx_mm_calc_rsq_pd(dx32
,dy32
,dz32
);
630 rsq33
= gmx_mm_calc_rsq_pd(dx33
,dy33
,dz33
);
632 rinv11
= gmx_mm_invsqrt_pd(rsq11
);
633 rinv12
= gmx_mm_invsqrt_pd(rsq12
);
634 rinv13
= gmx_mm_invsqrt_pd(rsq13
);
635 rinv21
= gmx_mm_invsqrt_pd(rsq21
);
636 rinv22
= gmx_mm_invsqrt_pd(rsq22
);
637 rinv23
= gmx_mm_invsqrt_pd(rsq23
);
638 rinv31
= gmx_mm_invsqrt_pd(rsq31
);
639 rinv32
= gmx_mm_invsqrt_pd(rsq32
);
640 rinv33
= gmx_mm_invsqrt_pd(rsq33
);
642 rinvsq00
= gmx_mm_inv_pd(rsq00
);
643 rinvsq11
= _mm_mul_pd(rinv11
,rinv11
);
644 rinvsq12
= _mm_mul_pd(rinv12
,rinv12
);
645 rinvsq13
= _mm_mul_pd(rinv13
,rinv13
);
646 rinvsq21
= _mm_mul_pd(rinv21
,rinv21
);
647 rinvsq22
= _mm_mul_pd(rinv22
,rinv22
);
648 rinvsq23
= _mm_mul_pd(rinv23
,rinv23
);
649 rinvsq31
= _mm_mul_pd(rinv31
,rinv31
);
650 rinvsq32
= _mm_mul_pd(rinv32
,rinv32
);
651 rinvsq33
= _mm_mul_pd(rinv33
,rinv33
);
653 fjx0
= _mm_setzero_pd();
654 fjy0
= _mm_setzero_pd();
655 fjz0
= _mm_setzero_pd();
656 fjx1
= _mm_setzero_pd();
657 fjy1
= _mm_setzero_pd();
658 fjz1
= _mm_setzero_pd();
659 fjx2
= _mm_setzero_pd();
660 fjy2
= _mm_setzero_pd();
661 fjz2
= _mm_setzero_pd();
662 fjx3
= _mm_setzero_pd();
663 fjy3
= _mm_setzero_pd();
664 fjz3
= _mm_setzero_pd();
666 /**************************
667 * CALCULATE INTERACTIONS *
668 **************************/
670 /* LENNARD-JONES DISPERSION/REPULSION */
672 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
673 vvdw6
= _mm_mul_pd(c6_00
,rinvsix
);
674 vvdw12
= _mm_mul_pd(c12_00
,_mm_mul_pd(rinvsix
,rinvsix
));
675 vvdw
= _mm_sub_pd( _mm_mul_pd(vvdw12
,one_twelfth
) , _mm_mul_pd(vvdw6
,one_sixth
) );
676 fvdw
= _mm_mul_pd(_mm_sub_pd(vvdw12
,vvdw6
),rinvsq00
);
678 /* Update potential sum for this i atom from the interaction with this j atom. */
679 vvdw
= _mm_unpacklo_pd(vvdw
,_mm_setzero_pd());
680 vvdwsum
= _mm_add_pd(vvdwsum
,vvdw
);
684 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
686 /* Calculate temporary vectorial force */
687 tx
= _mm_mul_pd(fscal
,dx00
);
688 ty
= _mm_mul_pd(fscal
,dy00
);
689 tz
= _mm_mul_pd(fscal
,dz00
);
691 /* Update vectorial force */
692 fix0
= _mm_add_pd(fix0
,tx
);
693 fiy0
= _mm_add_pd(fiy0
,ty
);
694 fiz0
= _mm_add_pd(fiz0
,tz
);
696 fjx0
= _mm_add_pd(fjx0
,tx
);
697 fjy0
= _mm_add_pd(fjy0
,ty
);
698 fjz0
= _mm_add_pd(fjz0
,tz
);
700 /**************************
701 * CALCULATE INTERACTIONS *
702 **************************/
704 /* REACTION-FIELD ELECTROSTATICS */
705 velec
= _mm_mul_pd(qq11
,_mm_sub_pd(_mm_add_pd(rinv11
,_mm_mul_pd(krf
,rsq11
)),crf
));
706 felec
= _mm_mul_pd(qq11
,_mm_sub_pd(_mm_mul_pd(rinv11
,rinvsq11
),krf2
));
708 /* Update potential sum for this i atom from the interaction with this j atom. */
709 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
710 velecsum
= _mm_add_pd(velecsum
,velec
);
714 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
716 /* Calculate temporary vectorial force */
717 tx
= _mm_mul_pd(fscal
,dx11
);
718 ty
= _mm_mul_pd(fscal
,dy11
);
719 tz
= _mm_mul_pd(fscal
,dz11
);
721 /* Update vectorial force */
722 fix1
= _mm_add_pd(fix1
,tx
);
723 fiy1
= _mm_add_pd(fiy1
,ty
);
724 fiz1
= _mm_add_pd(fiz1
,tz
);
726 fjx1
= _mm_add_pd(fjx1
,tx
);
727 fjy1
= _mm_add_pd(fjy1
,ty
);
728 fjz1
= _mm_add_pd(fjz1
,tz
);
730 /**************************
731 * CALCULATE INTERACTIONS *
732 **************************/
734 /* REACTION-FIELD ELECTROSTATICS */
735 velec
= _mm_mul_pd(qq12
,_mm_sub_pd(_mm_add_pd(rinv12
,_mm_mul_pd(krf
,rsq12
)),crf
));
736 felec
= _mm_mul_pd(qq12
,_mm_sub_pd(_mm_mul_pd(rinv12
,rinvsq12
),krf2
));
738 /* Update potential sum for this i atom from the interaction with this j atom. */
739 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
740 velecsum
= _mm_add_pd(velecsum
,velec
);
744 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
746 /* Calculate temporary vectorial force */
747 tx
= _mm_mul_pd(fscal
,dx12
);
748 ty
= _mm_mul_pd(fscal
,dy12
);
749 tz
= _mm_mul_pd(fscal
,dz12
);
751 /* Update vectorial force */
752 fix1
= _mm_add_pd(fix1
,tx
);
753 fiy1
= _mm_add_pd(fiy1
,ty
);
754 fiz1
= _mm_add_pd(fiz1
,tz
);
756 fjx2
= _mm_add_pd(fjx2
,tx
);
757 fjy2
= _mm_add_pd(fjy2
,ty
);
758 fjz2
= _mm_add_pd(fjz2
,tz
);
760 /**************************
761 * CALCULATE INTERACTIONS *
762 **************************/
764 /* REACTION-FIELD ELECTROSTATICS */
765 velec
= _mm_mul_pd(qq13
,_mm_sub_pd(_mm_add_pd(rinv13
,_mm_mul_pd(krf
,rsq13
)),crf
));
766 felec
= _mm_mul_pd(qq13
,_mm_sub_pd(_mm_mul_pd(rinv13
,rinvsq13
),krf2
));
768 /* Update potential sum for this i atom from the interaction with this j atom. */
769 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
770 velecsum
= _mm_add_pd(velecsum
,velec
);
774 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
776 /* Calculate temporary vectorial force */
777 tx
= _mm_mul_pd(fscal
,dx13
);
778 ty
= _mm_mul_pd(fscal
,dy13
);
779 tz
= _mm_mul_pd(fscal
,dz13
);
781 /* Update vectorial force */
782 fix1
= _mm_add_pd(fix1
,tx
);
783 fiy1
= _mm_add_pd(fiy1
,ty
);
784 fiz1
= _mm_add_pd(fiz1
,tz
);
786 fjx3
= _mm_add_pd(fjx3
,tx
);
787 fjy3
= _mm_add_pd(fjy3
,ty
);
788 fjz3
= _mm_add_pd(fjz3
,tz
);
790 /**************************
791 * CALCULATE INTERACTIONS *
792 **************************/
794 /* REACTION-FIELD ELECTROSTATICS */
795 velec
= _mm_mul_pd(qq21
,_mm_sub_pd(_mm_add_pd(rinv21
,_mm_mul_pd(krf
,rsq21
)),crf
));
796 felec
= _mm_mul_pd(qq21
,_mm_sub_pd(_mm_mul_pd(rinv21
,rinvsq21
),krf2
));
798 /* Update potential sum for this i atom from the interaction with this j atom. */
799 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
800 velecsum
= _mm_add_pd(velecsum
,velec
);
804 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
806 /* Calculate temporary vectorial force */
807 tx
= _mm_mul_pd(fscal
,dx21
);
808 ty
= _mm_mul_pd(fscal
,dy21
);
809 tz
= _mm_mul_pd(fscal
,dz21
);
811 /* Update vectorial force */
812 fix2
= _mm_add_pd(fix2
,tx
);
813 fiy2
= _mm_add_pd(fiy2
,ty
);
814 fiz2
= _mm_add_pd(fiz2
,tz
);
816 fjx1
= _mm_add_pd(fjx1
,tx
);
817 fjy1
= _mm_add_pd(fjy1
,ty
);
818 fjz1
= _mm_add_pd(fjz1
,tz
);
820 /**************************
821 * CALCULATE INTERACTIONS *
822 **************************/
824 /* REACTION-FIELD ELECTROSTATICS */
825 velec
= _mm_mul_pd(qq22
,_mm_sub_pd(_mm_add_pd(rinv22
,_mm_mul_pd(krf
,rsq22
)),crf
));
826 felec
= _mm_mul_pd(qq22
,_mm_sub_pd(_mm_mul_pd(rinv22
,rinvsq22
),krf2
));
828 /* Update potential sum for this i atom from the interaction with this j atom. */
829 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
830 velecsum
= _mm_add_pd(velecsum
,velec
);
834 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
836 /* Calculate temporary vectorial force */
837 tx
= _mm_mul_pd(fscal
,dx22
);
838 ty
= _mm_mul_pd(fscal
,dy22
);
839 tz
= _mm_mul_pd(fscal
,dz22
);
841 /* Update vectorial force */
842 fix2
= _mm_add_pd(fix2
,tx
);
843 fiy2
= _mm_add_pd(fiy2
,ty
);
844 fiz2
= _mm_add_pd(fiz2
,tz
);
846 fjx2
= _mm_add_pd(fjx2
,tx
);
847 fjy2
= _mm_add_pd(fjy2
,ty
);
848 fjz2
= _mm_add_pd(fjz2
,tz
);
850 /**************************
851 * CALCULATE INTERACTIONS *
852 **************************/
854 /* REACTION-FIELD ELECTROSTATICS */
855 velec
= _mm_mul_pd(qq23
,_mm_sub_pd(_mm_add_pd(rinv23
,_mm_mul_pd(krf
,rsq23
)),crf
));
856 felec
= _mm_mul_pd(qq23
,_mm_sub_pd(_mm_mul_pd(rinv23
,rinvsq23
),krf2
));
858 /* Update potential sum for this i atom from the interaction with this j atom. */
859 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
860 velecsum
= _mm_add_pd(velecsum
,velec
);
864 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
866 /* Calculate temporary vectorial force */
867 tx
= _mm_mul_pd(fscal
,dx23
);
868 ty
= _mm_mul_pd(fscal
,dy23
);
869 tz
= _mm_mul_pd(fscal
,dz23
);
871 /* Update vectorial force */
872 fix2
= _mm_add_pd(fix2
,tx
);
873 fiy2
= _mm_add_pd(fiy2
,ty
);
874 fiz2
= _mm_add_pd(fiz2
,tz
);
876 fjx3
= _mm_add_pd(fjx3
,tx
);
877 fjy3
= _mm_add_pd(fjy3
,ty
);
878 fjz3
= _mm_add_pd(fjz3
,tz
);
880 /**************************
881 * CALCULATE INTERACTIONS *
882 **************************/
884 /* REACTION-FIELD ELECTROSTATICS */
885 velec
= _mm_mul_pd(qq31
,_mm_sub_pd(_mm_add_pd(rinv31
,_mm_mul_pd(krf
,rsq31
)),crf
));
886 felec
= _mm_mul_pd(qq31
,_mm_sub_pd(_mm_mul_pd(rinv31
,rinvsq31
),krf2
));
888 /* Update potential sum for this i atom from the interaction with this j atom. */
889 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
890 velecsum
= _mm_add_pd(velecsum
,velec
);
894 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
896 /* Calculate temporary vectorial force */
897 tx
= _mm_mul_pd(fscal
,dx31
);
898 ty
= _mm_mul_pd(fscal
,dy31
);
899 tz
= _mm_mul_pd(fscal
,dz31
);
901 /* Update vectorial force */
902 fix3
= _mm_add_pd(fix3
,tx
);
903 fiy3
= _mm_add_pd(fiy3
,ty
);
904 fiz3
= _mm_add_pd(fiz3
,tz
);
906 fjx1
= _mm_add_pd(fjx1
,tx
);
907 fjy1
= _mm_add_pd(fjy1
,ty
);
908 fjz1
= _mm_add_pd(fjz1
,tz
);
910 /**************************
911 * CALCULATE INTERACTIONS *
912 **************************/
914 /* REACTION-FIELD ELECTROSTATICS */
915 velec
= _mm_mul_pd(qq32
,_mm_sub_pd(_mm_add_pd(rinv32
,_mm_mul_pd(krf
,rsq32
)),crf
));
916 felec
= _mm_mul_pd(qq32
,_mm_sub_pd(_mm_mul_pd(rinv32
,rinvsq32
),krf2
));
918 /* Update potential sum for this i atom from the interaction with this j atom. */
919 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
920 velecsum
= _mm_add_pd(velecsum
,velec
);
924 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
926 /* Calculate temporary vectorial force */
927 tx
= _mm_mul_pd(fscal
,dx32
);
928 ty
= _mm_mul_pd(fscal
,dy32
);
929 tz
= _mm_mul_pd(fscal
,dz32
);
931 /* Update vectorial force */
932 fix3
= _mm_add_pd(fix3
,tx
);
933 fiy3
= _mm_add_pd(fiy3
,ty
);
934 fiz3
= _mm_add_pd(fiz3
,tz
);
936 fjx2
= _mm_add_pd(fjx2
,tx
);
937 fjy2
= _mm_add_pd(fjy2
,ty
);
938 fjz2
= _mm_add_pd(fjz2
,tz
);
940 /**************************
941 * CALCULATE INTERACTIONS *
942 **************************/
944 /* REACTION-FIELD ELECTROSTATICS */
945 velec
= _mm_mul_pd(qq33
,_mm_sub_pd(_mm_add_pd(rinv33
,_mm_mul_pd(krf
,rsq33
)),crf
));
946 felec
= _mm_mul_pd(qq33
,_mm_sub_pd(_mm_mul_pd(rinv33
,rinvsq33
),krf2
));
948 /* Update potential sum for this i atom from the interaction with this j atom. */
949 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
950 velecsum
= _mm_add_pd(velecsum
,velec
);
954 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
956 /* Calculate temporary vectorial force */
957 tx
= _mm_mul_pd(fscal
,dx33
);
958 ty
= _mm_mul_pd(fscal
,dy33
);
959 tz
= _mm_mul_pd(fscal
,dz33
);
961 /* Update vectorial force */
962 fix3
= _mm_add_pd(fix3
,tx
);
963 fiy3
= _mm_add_pd(fiy3
,ty
);
964 fiz3
= _mm_add_pd(fiz3
,tz
);
966 fjx3
= _mm_add_pd(fjx3
,tx
);
967 fjy3
= _mm_add_pd(fjy3
,ty
);
968 fjz3
= _mm_add_pd(fjz3
,tz
);
970 gmx_mm_decrement_4rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
,fjx1
,fjy1
,fjz1
,fjx2
,fjy2
,fjz2
,fjx3
,fjy3
,fjz3
);
972 /* Inner loop uses 323 flops */
975 /* End of innermost loop */
977 gmx_mm_update_iforce_4atom_swizzle_pd(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,fix3
,fiy3
,fiz3
,
978 f
+i_coord_offset
,fshift
+i_shift_offset
);
981 /* Update potential energies */
982 gmx_mm_update_1pot_pd(velecsum
,kernel_data
->energygrp_elec
+ggid
);
983 gmx_mm_update_1pot_pd(vvdwsum
,kernel_data
->energygrp_vdw
+ggid
);
985 /* Increment number of inner iterations */
986 inneriter
+= j_index_end
- j_index_start
;
988 /* Outer loop uses 26 flops */
991 /* Increment number of outer iterations */
994 /* Update outer/inner flops */
996 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4W4_VF
,outeriter
*26 + inneriter
*323);
999 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_sse2_double
1000 * Electrostatics interaction: ReactionField
1001 * VdW interaction: LennardJones
1002 * Geometry: Water4-Water4
1003 * Calculate force/pot: Force
1006 nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_sse2_double
1007 (t_nblist
* gmx_restrict nlist
,
1008 rvec
* gmx_restrict xx
,
1009 rvec
* gmx_restrict ff
,
1010 t_forcerec
* gmx_restrict fr
,
1011 t_mdatoms
* gmx_restrict mdatoms
,
1012 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
1013 t_nrnb
* gmx_restrict nrnb
)
1015 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1016 * just 0 for non-waters.
1017 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
1018 * jnr indices corresponding to data put in the four positions in the SIMD register.
1020 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
1021 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
1023 int j_coord_offsetA
,j_coord_offsetB
;
1024 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
1025 real rcutoff_scalar
;
1026 real
*shiftvec
,*fshift
,*x
,*f
;
1027 __m128d tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
1029 __m128d ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
1031 __m128d ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
1033 __m128d ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
1035 __m128d ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
1036 int vdwjidx0A
,vdwjidx0B
;
1037 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
1038 int vdwjidx1A
,vdwjidx1B
;
1039 __m128d jx1
,jy1
,jz1
,fjx1
,fjy1
,fjz1
,jq1
,isaj1
;
1040 int vdwjidx2A
,vdwjidx2B
;
1041 __m128d jx2
,jy2
,jz2
,fjx2
,fjy2
,fjz2
,jq2
,isaj2
;
1042 int vdwjidx3A
,vdwjidx3B
;
1043 __m128d jx3
,jy3
,jz3
,fjx3
,fjy3
,fjz3
,jq3
,isaj3
;
1044 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
1045 __m128d dx11
,dy11
,dz11
,rsq11
,rinv11
,rinvsq11
,r11
,qq11
,c6_11
,c12_11
;
1046 __m128d dx12
,dy12
,dz12
,rsq12
,rinv12
,rinvsq12
,r12
,qq12
,c6_12
,c12_12
;
1047 __m128d dx13
,dy13
,dz13
,rsq13
,rinv13
,rinvsq13
,r13
,qq13
,c6_13
,c12_13
;
1048 __m128d dx21
,dy21
,dz21
,rsq21
,rinv21
,rinvsq21
,r21
,qq21
,c6_21
,c12_21
;
1049 __m128d dx22
,dy22
,dz22
,rsq22
,rinv22
,rinvsq22
,r22
,qq22
,c6_22
,c12_22
;
1050 __m128d dx23
,dy23
,dz23
,rsq23
,rinv23
,rinvsq23
,r23
,qq23
,c6_23
,c12_23
;
1051 __m128d dx31
,dy31
,dz31
,rsq31
,rinv31
,rinvsq31
,r31
,qq31
,c6_31
,c12_31
;
1052 __m128d dx32
,dy32
,dz32
,rsq32
,rinv32
,rinvsq32
,r32
,qq32
,c6_32
,c12_32
;
1053 __m128d dx33
,dy33
,dz33
,rsq33
,rinv33
,rinvsq33
,r33
,qq33
,c6_33
,c12_33
;
1054 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
1057 __m128d rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
1060 __m128d one_sixth
= _mm_set1_pd(1.0/6.0);
1061 __m128d one_twelfth
= _mm_set1_pd(1.0/12.0);
1062 __m128d dummy_mask
,cutoff_mask
;
1063 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
1064 __m128d one
= _mm_set1_pd(1.0);
1065 __m128d two
= _mm_set1_pd(2.0);
1071 jindex
= nlist
->jindex
;
1073 shiftidx
= nlist
->shift
;
1075 shiftvec
= fr
->shift_vec
[0];
1076 fshift
= fr
->fshift
[0];
1077 facel
= _mm_set1_pd(fr
->epsfac
);
1078 charge
= mdatoms
->chargeA
;
1079 krf
= _mm_set1_pd(fr
->ic
->k_rf
);
1080 krf2
= _mm_set1_pd(fr
->ic
->k_rf
*2.0);
1081 crf
= _mm_set1_pd(fr
->ic
->c_rf
);
1082 nvdwtype
= fr
->ntype
;
1083 vdwparam
= fr
->nbfp
;
1084 vdwtype
= mdatoms
->typeA
;
1086 /* Setup water-specific parameters */
1087 inr
= nlist
->iinr
[0];
1088 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
1089 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
1090 iq3
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+3]));
1091 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
1093 jq1
= _mm_set1_pd(charge
[inr
+1]);
1094 jq2
= _mm_set1_pd(charge
[inr
+2]);
1095 jq3
= _mm_set1_pd(charge
[inr
+3]);
1096 vdwjidx0A
= 2*vdwtype
[inr
+0];
1097 c6_00
= _mm_set1_pd(vdwparam
[vdwioffset0
+vdwjidx0A
]);
1098 c12_00
= _mm_set1_pd(vdwparam
[vdwioffset0
+vdwjidx0A
+1]);
1099 qq11
= _mm_mul_pd(iq1
,jq1
);
1100 qq12
= _mm_mul_pd(iq1
,jq2
);
1101 qq13
= _mm_mul_pd(iq1
,jq3
);
1102 qq21
= _mm_mul_pd(iq2
,jq1
);
1103 qq22
= _mm_mul_pd(iq2
,jq2
);
1104 qq23
= _mm_mul_pd(iq2
,jq3
);
1105 qq31
= _mm_mul_pd(iq3
,jq1
);
1106 qq32
= _mm_mul_pd(iq3
,jq2
);
1107 qq33
= _mm_mul_pd(iq3
,jq3
);
1109 /* Avoid stupid compiler warnings */
1111 j_coord_offsetA
= 0;
1112 j_coord_offsetB
= 0;
1117 /* Start outer loop over neighborlists */
1118 for(iidx
=0; iidx
<nri
; iidx
++)
1120 /* Load shift vector for this list */
1121 i_shift_offset
= DIM
*shiftidx
[iidx
];
1123 /* Load limits for loop over neighbors */
1124 j_index_start
= jindex
[iidx
];
1125 j_index_end
= jindex
[iidx
+1];
1127 /* Get outer coordinate index */
1129 i_coord_offset
= DIM
*inr
;
1131 /* Load i particle coords and add shift vector */
1132 gmx_mm_load_shift_and_4rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
1133 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
,&ix3
,&iy3
,&iz3
);
1135 fix0
= _mm_setzero_pd();
1136 fiy0
= _mm_setzero_pd();
1137 fiz0
= _mm_setzero_pd();
1138 fix1
= _mm_setzero_pd();
1139 fiy1
= _mm_setzero_pd();
1140 fiz1
= _mm_setzero_pd();
1141 fix2
= _mm_setzero_pd();
1142 fiy2
= _mm_setzero_pd();
1143 fiz2
= _mm_setzero_pd();
1144 fix3
= _mm_setzero_pd();
1145 fiy3
= _mm_setzero_pd();
1146 fiz3
= _mm_setzero_pd();
1148 /* Start inner kernel loop */
1149 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
1152 /* Get j neighbor index, and coordinate index */
1154 jnrB
= jjnr
[jidx
+1];
1155 j_coord_offsetA
= DIM
*jnrA
;
1156 j_coord_offsetB
= DIM
*jnrB
;
1158 /* load j atom coordinates */
1159 gmx_mm_load_4rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
1160 &jx0
,&jy0
,&jz0
,&jx1
,&jy1
,&jz1
,&jx2
,
1161 &jy2
,&jz2
,&jx3
,&jy3
,&jz3
);
1163 /* Calculate displacement vector */
1164 dx00
= _mm_sub_pd(ix0
,jx0
);
1165 dy00
= _mm_sub_pd(iy0
,jy0
);
1166 dz00
= _mm_sub_pd(iz0
,jz0
);
1167 dx11
= _mm_sub_pd(ix1
,jx1
);
1168 dy11
= _mm_sub_pd(iy1
,jy1
);
1169 dz11
= _mm_sub_pd(iz1
,jz1
);
1170 dx12
= _mm_sub_pd(ix1
,jx2
);
1171 dy12
= _mm_sub_pd(iy1
,jy2
);
1172 dz12
= _mm_sub_pd(iz1
,jz2
);
1173 dx13
= _mm_sub_pd(ix1
,jx3
);
1174 dy13
= _mm_sub_pd(iy1
,jy3
);
1175 dz13
= _mm_sub_pd(iz1
,jz3
);
1176 dx21
= _mm_sub_pd(ix2
,jx1
);
1177 dy21
= _mm_sub_pd(iy2
,jy1
);
1178 dz21
= _mm_sub_pd(iz2
,jz1
);
1179 dx22
= _mm_sub_pd(ix2
,jx2
);
1180 dy22
= _mm_sub_pd(iy2
,jy2
);
1181 dz22
= _mm_sub_pd(iz2
,jz2
);
1182 dx23
= _mm_sub_pd(ix2
,jx3
);
1183 dy23
= _mm_sub_pd(iy2
,jy3
);
1184 dz23
= _mm_sub_pd(iz2
,jz3
);
1185 dx31
= _mm_sub_pd(ix3
,jx1
);
1186 dy31
= _mm_sub_pd(iy3
,jy1
);
1187 dz31
= _mm_sub_pd(iz3
,jz1
);
1188 dx32
= _mm_sub_pd(ix3
,jx2
);
1189 dy32
= _mm_sub_pd(iy3
,jy2
);
1190 dz32
= _mm_sub_pd(iz3
,jz2
);
1191 dx33
= _mm_sub_pd(ix3
,jx3
);
1192 dy33
= _mm_sub_pd(iy3
,jy3
);
1193 dz33
= _mm_sub_pd(iz3
,jz3
);
1195 /* Calculate squared distance and things based on it */
1196 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
1197 rsq11
= gmx_mm_calc_rsq_pd(dx11
,dy11
,dz11
);
1198 rsq12
= gmx_mm_calc_rsq_pd(dx12
,dy12
,dz12
);
1199 rsq13
= gmx_mm_calc_rsq_pd(dx13
,dy13
,dz13
);
1200 rsq21
= gmx_mm_calc_rsq_pd(dx21
,dy21
,dz21
);
1201 rsq22
= gmx_mm_calc_rsq_pd(dx22
,dy22
,dz22
);
1202 rsq23
= gmx_mm_calc_rsq_pd(dx23
,dy23
,dz23
);
1203 rsq31
= gmx_mm_calc_rsq_pd(dx31
,dy31
,dz31
);
1204 rsq32
= gmx_mm_calc_rsq_pd(dx32
,dy32
,dz32
);
1205 rsq33
= gmx_mm_calc_rsq_pd(dx33
,dy33
,dz33
);
1207 rinv11
= gmx_mm_invsqrt_pd(rsq11
);
1208 rinv12
= gmx_mm_invsqrt_pd(rsq12
);
1209 rinv13
= gmx_mm_invsqrt_pd(rsq13
);
1210 rinv21
= gmx_mm_invsqrt_pd(rsq21
);
1211 rinv22
= gmx_mm_invsqrt_pd(rsq22
);
1212 rinv23
= gmx_mm_invsqrt_pd(rsq23
);
1213 rinv31
= gmx_mm_invsqrt_pd(rsq31
);
1214 rinv32
= gmx_mm_invsqrt_pd(rsq32
);
1215 rinv33
= gmx_mm_invsqrt_pd(rsq33
);
1217 rinvsq00
= gmx_mm_inv_pd(rsq00
);
1218 rinvsq11
= _mm_mul_pd(rinv11
,rinv11
);
1219 rinvsq12
= _mm_mul_pd(rinv12
,rinv12
);
1220 rinvsq13
= _mm_mul_pd(rinv13
,rinv13
);
1221 rinvsq21
= _mm_mul_pd(rinv21
,rinv21
);
1222 rinvsq22
= _mm_mul_pd(rinv22
,rinv22
);
1223 rinvsq23
= _mm_mul_pd(rinv23
,rinv23
);
1224 rinvsq31
= _mm_mul_pd(rinv31
,rinv31
);
1225 rinvsq32
= _mm_mul_pd(rinv32
,rinv32
);
1226 rinvsq33
= _mm_mul_pd(rinv33
,rinv33
);
1228 fjx0
= _mm_setzero_pd();
1229 fjy0
= _mm_setzero_pd();
1230 fjz0
= _mm_setzero_pd();
1231 fjx1
= _mm_setzero_pd();
1232 fjy1
= _mm_setzero_pd();
1233 fjz1
= _mm_setzero_pd();
1234 fjx2
= _mm_setzero_pd();
1235 fjy2
= _mm_setzero_pd();
1236 fjz2
= _mm_setzero_pd();
1237 fjx3
= _mm_setzero_pd();
1238 fjy3
= _mm_setzero_pd();
1239 fjz3
= _mm_setzero_pd();
1241 /**************************
1242 * CALCULATE INTERACTIONS *
1243 **************************/
1245 /* LENNARD-JONES DISPERSION/REPULSION */
1247 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
1248 fvdw
= _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00
,rinvsix
),c6_00
),_mm_mul_pd(rinvsix
,rinvsq00
));
1252 /* Calculate temporary vectorial force */
1253 tx
= _mm_mul_pd(fscal
,dx00
);
1254 ty
= _mm_mul_pd(fscal
,dy00
);
1255 tz
= _mm_mul_pd(fscal
,dz00
);
1257 /* Update vectorial force */
1258 fix0
= _mm_add_pd(fix0
,tx
);
1259 fiy0
= _mm_add_pd(fiy0
,ty
);
1260 fiz0
= _mm_add_pd(fiz0
,tz
);
1262 fjx0
= _mm_add_pd(fjx0
,tx
);
1263 fjy0
= _mm_add_pd(fjy0
,ty
);
1264 fjz0
= _mm_add_pd(fjz0
,tz
);
1266 /**************************
1267 * CALCULATE INTERACTIONS *
1268 **************************/
1270 /* REACTION-FIELD ELECTROSTATICS */
1271 felec
= _mm_mul_pd(qq11
,_mm_sub_pd(_mm_mul_pd(rinv11
,rinvsq11
),krf2
));
1275 /* Calculate temporary vectorial force */
1276 tx
= _mm_mul_pd(fscal
,dx11
);
1277 ty
= _mm_mul_pd(fscal
,dy11
);
1278 tz
= _mm_mul_pd(fscal
,dz11
);
1280 /* Update vectorial force */
1281 fix1
= _mm_add_pd(fix1
,tx
);
1282 fiy1
= _mm_add_pd(fiy1
,ty
);
1283 fiz1
= _mm_add_pd(fiz1
,tz
);
1285 fjx1
= _mm_add_pd(fjx1
,tx
);
1286 fjy1
= _mm_add_pd(fjy1
,ty
);
1287 fjz1
= _mm_add_pd(fjz1
,tz
);
1289 /**************************
1290 * CALCULATE INTERACTIONS *
1291 **************************/
1293 /* REACTION-FIELD ELECTROSTATICS */
1294 felec
= _mm_mul_pd(qq12
,_mm_sub_pd(_mm_mul_pd(rinv12
,rinvsq12
),krf2
));
1298 /* Calculate temporary vectorial force */
1299 tx
= _mm_mul_pd(fscal
,dx12
);
1300 ty
= _mm_mul_pd(fscal
,dy12
);
1301 tz
= _mm_mul_pd(fscal
,dz12
);
1303 /* Update vectorial force */
1304 fix1
= _mm_add_pd(fix1
,tx
);
1305 fiy1
= _mm_add_pd(fiy1
,ty
);
1306 fiz1
= _mm_add_pd(fiz1
,tz
);
1308 fjx2
= _mm_add_pd(fjx2
,tx
);
1309 fjy2
= _mm_add_pd(fjy2
,ty
);
1310 fjz2
= _mm_add_pd(fjz2
,tz
);
1312 /**************************
1313 * CALCULATE INTERACTIONS *
1314 **************************/
1316 /* REACTION-FIELD ELECTROSTATICS */
1317 felec
= _mm_mul_pd(qq13
,_mm_sub_pd(_mm_mul_pd(rinv13
,rinvsq13
),krf2
));
1321 /* Calculate temporary vectorial force */
1322 tx
= _mm_mul_pd(fscal
,dx13
);
1323 ty
= _mm_mul_pd(fscal
,dy13
);
1324 tz
= _mm_mul_pd(fscal
,dz13
);
1326 /* Update vectorial force */
1327 fix1
= _mm_add_pd(fix1
,tx
);
1328 fiy1
= _mm_add_pd(fiy1
,ty
);
1329 fiz1
= _mm_add_pd(fiz1
,tz
);
1331 fjx3
= _mm_add_pd(fjx3
,tx
);
1332 fjy3
= _mm_add_pd(fjy3
,ty
);
1333 fjz3
= _mm_add_pd(fjz3
,tz
);
1335 /**************************
1336 * CALCULATE INTERACTIONS *
1337 **************************/
1339 /* REACTION-FIELD ELECTROSTATICS */
1340 felec
= _mm_mul_pd(qq21
,_mm_sub_pd(_mm_mul_pd(rinv21
,rinvsq21
),krf2
));
1344 /* Calculate temporary vectorial force */
1345 tx
= _mm_mul_pd(fscal
,dx21
);
1346 ty
= _mm_mul_pd(fscal
,dy21
);
1347 tz
= _mm_mul_pd(fscal
,dz21
);
1349 /* Update vectorial force */
1350 fix2
= _mm_add_pd(fix2
,tx
);
1351 fiy2
= _mm_add_pd(fiy2
,ty
);
1352 fiz2
= _mm_add_pd(fiz2
,tz
);
1354 fjx1
= _mm_add_pd(fjx1
,tx
);
1355 fjy1
= _mm_add_pd(fjy1
,ty
);
1356 fjz1
= _mm_add_pd(fjz1
,tz
);
1358 /**************************
1359 * CALCULATE INTERACTIONS *
1360 **************************/
1362 /* REACTION-FIELD ELECTROSTATICS */
1363 felec
= _mm_mul_pd(qq22
,_mm_sub_pd(_mm_mul_pd(rinv22
,rinvsq22
),krf2
));
1367 /* Calculate temporary vectorial force */
1368 tx
= _mm_mul_pd(fscal
,dx22
);
1369 ty
= _mm_mul_pd(fscal
,dy22
);
1370 tz
= _mm_mul_pd(fscal
,dz22
);
1372 /* Update vectorial force */
1373 fix2
= _mm_add_pd(fix2
,tx
);
1374 fiy2
= _mm_add_pd(fiy2
,ty
);
1375 fiz2
= _mm_add_pd(fiz2
,tz
);
1377 fjx2
= _mm_add_pd(fjx2
,tx
);
1378 fjy2
= _mm_add_pd(fjy2
,ty
);
1379 fjz2
= _mm_add_pd(fjz2
,tz
);
1381 /**************************
1382 * CALCULATE INTERACTIONS *
1383 **************************/
1385 /* REACTION-FIELD ELECTROSTATICS */
1386 felec
= _mm_mul_pd(qq23
,_mm_sub_pd(_mm_mul_pd(rinv23
,rinvsq23
),krf2
));
1390 /* Calculate temporary vectorial force */
1391 tx
= _mm_mul_pd(fscal
,dx23
);
1392 ty
= _mm_mul_pd(fscal
,dy23
);
1393 tz
= _mm_mul_pd(fscal
,dz23
);
1395 /* Update vectorial force */
1396 fix2
= _mm_add_pd(fix2
,tx
);
1397 fiy2
= _mm_add_pd(fiy2
,ty
);
1398 fiz2
= _mm_add_pd(fiz2
,tz
);
1400 fjx3
= _mm_add_pd(fjx3
,tx
);
1401 fjy3
= _mm_add_pd(fjy3
,ty
);
1402 fjz3
= _mm_add_pd(fjz3
,tz
);
1404 /**************************
1405 * CALCULATE INTERACTIONS *
1406 **************************/
1408 /* REACTION-FIELD ELECTROSTATICS */
1409 felec
= _mm_mul_pd(qq31
,_mm_sub_pd(_mm_mul_pd(rinv31
,rinvsq31
),krf2
));
1413 /* Calculate temporary vectorial force */
1414 tx
= _mm_mul_pd(fscal
,dx31
);
1415 ty
= _mm_mul_pd(fscal
,dy31
);
1416 tz
= _mm_mul_pd(fscal
,dz31
);
1418 /* Update vectorial force */
1419 fix3
= _mm_add_pd(fix3
,tx
);
1420 fiy3
= _mm_add_pd(fiy3
,ty
);
1421 fiz3
= _mm_add_pd(fiz3
,tz
);
1423 fjx1
= _mm_add_pd(fjx1
,tx
);
1424 fjy1
= _mm_add_pd(fjy1
,ty
);
1425 fjz1
= _mm_add_pd(fjz1
,tz
);
1427 /**************************
1428 * CALCULATE INTERACTIONS *
1429 **************************/
1431 /* REACTION-FIELD ELECTROSTATICS */
1432 felec
= _mm_mul_pd(qq32
,_mm_sub_pd(_mm_mul_pd(rinv32
,rinvsq32
),krf2
));
1436 /* Calculate temporary vectorial force */
1437 tx
= _mm_mul_pd(fscal
,dx32
);
1438 ty
= _mm_mul_pd(fscal
,dy32
);
1439 tz
= _mm_mul_pd(fscal
,dz32
);
1441 /* Update vectorial force */
1442 fix3
= _mm_add_pd(fix3
,tx
);
1443 fiy3
= _mm_add_pd(fiy3
,ty
);
1444 fiz3
= _mm_add_pd(fiz3
,tz
);
1446 fjx2
= _mm_add_pd(fjx2
,tx
);
1447 fjy2
= _mm_add_pd(fjy2
,ty
);
1448 fjz2
= _mm_add_pd(fjz2
,tz
);
1450 /**************************
1451 * CALCULATE INTERACTIONS *
1452 **************************/
1454 /* REACTION-FIELD ELECTROSTATICS */
1455 felec
= _mm_mul_pd(qq33
,_mm_sub_pd(_mm_mul_pd(rinv33
,rinvsq33
),krf2
));
1459 /* Calculate temporary vectorial force */
1460 tx
= _mm_mul_pd(fscal
,dx33
);
1461 ty
= _mm_mul_pd(fscal
,dy33
);
1462 tz
= _mm_mul_pd(fscal
,dz33
);
1464 /* Update vectorial force */
1465 fix3
= _mm_add_pd(fix3
,tx
);
1466 fiy3
= _mm_add_pd(fiy3
,ty
);
1467 fiz3
= _mm_add_pd(fiz3
,tz
);
1469 fjx3
= _mm_add_pd(fjx3
,tx
);
1470 fjy3
= _mm_add_pd(fjy3
,ty
);
1471 fjz3
= _mm_add_pd(fjz3
,tz
);
1473 gmx_mm_decrement_4rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
,fjx1
,fjy1
,fjz1
,fjx2
,fjy2
,fjz2
,fjx3
,fjy3
,fjz3
);
1475 /* Inner loop uses 273 flops */
1478 if(jidx
<j_index_end
)
1482 j_coord_offsetA
= DIM
*jnrA
;
1484 /* load j atom coordinates */
1485 gmx_mm_load_4rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
1486 &jx0
,&jy0
,&jz0
,&jx1
,&jy1
,&jz1
,&jx2
,
1487 &jy2
,&jz2
,&jx3
,&jy3
,&jz3
);
1489 /* Calculate displacement vector */
1490 dx00
= _mm_sub_pd(ix0
,jx0
);
1491 dy00
= _mm_sub_pd(iy0
,jy0
);
1492 dz00
= _mm_sub_pd(iz0
,jz0
);
1493 dx11
= _mm_sub_pd(ix1
,jx1
);
1494 dy11
= _mm_sub_pd(iy1
,jy1
);
1495 dz11
= _mm_sub_pd(iz1
,jz1
);
1496 dx12
= _mm_sub_pd(ix1
,jx2
);
1497 dy12
= _mm_sub_pd(iy1
,jy2
);
1498 dz12
= _mm_sub_pd(iz1
,jz2
);
1499 dx13
= _mm_sub_pd(ix1
,jx3
);
1500 dy13
= _mm_sub_pd(iy1
,jy3
);
1501 dz13
= _mm_sub_pd(iz1
,jz3
);
1502 dx21
= _mm_sub_pd(ix2
,jx1
);
1503 dy21
= _mm_sub_pd(iy2
,jy1
);
1504 dz21
= _mm_sub_pd(iz2
,jz1
);
1505 dx22
= _mm_sub_pd(ix2
,jx2
);
1506 dy22
= _mm_sub_pd(iy2
,jy2
);
1507 dz22
= _mm_sub_pd(iz2
,jz2
);
1508 dx23
= _mm_sub_pd(ix2
,jx3
);
1509 dy23
= _mm_sub_pd(iy2
,jy3
);
1510 dz23
= _mm_sub_pd(iz2
,jz3
);
1511 dx31
= _mm_sub_pd(ix3
,jx1
);
1512 dy31
= _mm_sub_pd(iy3
,jy1
);
1513 dz31
= _mm_sub_pd(iz3
,jz1
);
1514 dx32
= _mm_sub_pd(ix3
,jx2
);
1515 dy32
= _mm_sub_pd(iy3
,jy2
);
1516 dz32
= _mm_sub_pd(iz3
,jz2
);
1517 dx33
= _mm_sub_pd(ix3
,jx3
);
1518 dy33
= _mm_sub_pd(iy3
,jy3
);
1519 dz33
= _mm_sub_pd(iz3
,jz3
);
1521 /* Calculate squared distance and things based on it */
1522 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
1523 rsq11
= gmx_mm_calc_rsq_pd(dx11
,dy11
,dz11
);
1524 rsq12
= gmx_mm_calc_rsq_pd(dx12
,dy12
,dz12
);
1525 rsq13
= gmx_mm_calc_rsq_pd(dx13
,dy13
,dz13
);
1526 rsq21
= gmx_mm_calc_rsq_pd(dx21
,dy21
,dz21
);
1527 rsq22
= gmx_mm_calc_rsq_pd(dx22
,dy22
,dz22
);
1528 rsq23
= gmx_mm_calc_rsq_pd(dx23
,dy23
,dz23
);
1529 rsq31
= gmx_mm_calc_rsq_pd(dx31
,dy31
,dz31
);
1530 rsq32
= gmx_mm_calc_rsq_pd(dx32
,dy32
,dz32
);
1531 rsq33
= gmx_mm_calc_rsq_pd(dx33
,dy33
,dz33
);
1533 rinv11
= gmx_mm_invsqrt_pd(rsq11
);
1534 rinv12
= gmx_mm_invsqrt_pd(rsq12
);
1535 rinv13
= gmx_mm_invsqrt_pd(rsq13
);
1536 rinv21
= gmx_mm_invsqrt_pd(rsq21
);
1537 rinv22
= gmx_mm_invsqrt_pd(rsq22
);
1538 rinv23
= gmx_mm_invsqrt_pd(rsq23
);
1539 rinv31
= gmx_mm_invsqrt_pd(rsq31
);
1540 rinv32
= gmx_mm_invsqrt_pd(rsq32
);
1541 rinv33
= gmx_mm_invsqrt_pd(rsq33
);
1543 rinvsq00
= gmx_mm_inv_pd(rsq00
);
1544 rinvsq11
= _mm_mul_pd(rinv11
,rinv11
);
1545 rinvsq12
= _mm_mul_pd(rinv12
,rinv12
);
1546 rinvsq13
= _mm_mul_pd(rinv13
,rinv13
);
1547 rinvsq21
= _mm_mul_pd(rinv21
,rinv21
);
1548 rinvsq22
= _mm_mul_pd(rinv22
,rinv22
);
1549 rinvsq23
= _mm_mul_pd(rinv23
,rinv23
);
1550 rinvsq31
= _mm_mul_pd(rinv31
,rinv31
);
1551 rinvsq32
= _mm_mul_pd(rinv32
,rinv32
);
1552 rinvsq33
= _mm_mul_pd(rinv33
,rinv33
);
1554 fjx0
= _mm_setzero_pd();
1555 fjy0
= _mm_setzero_pd();
1556 fjz0
= _mm_setzero_pd();
1557 fjx1
= _mm_setzero_pd();
1558 fjy1
= _mm_setzero_pd();
1559 fjz1
= _mm_setzero_pd();
1560 fjx2
= _mm_setzero_pd();
1561 fjy2
= _mm_setzero_pd();
1562 fjz2
= _mm_setzero_pd();
1563 fjx3
= _mm_setzero_pd();
1564 fjy3
= _mm_setzero_pd();
1565 fjz3
= _mm_setzero_pd();
1567 /**************************
1568 * CALCULATE INTERACTIONS *
1569 **************************/
1571 /* LENNARD-JONES DISPERSION/REPULSION */
1573 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
1574 fvdw
= _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00
,rinvsix
),c6_00
),_mm_mul_pd(rinvsix
,rinvsq00
));
1578 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1580 /* Calculate temporary vectorial force */
1581 tx
= _mm_mul_pd(fscal
,dx00
);
1582 ty
= _mm_mul_pd(fscal
,dy00
);
1583 tz
= _mm_mul_pd(fscal
,dz00
);
1585 /* Update vectorial force */
1586 fix0
= _mm_add_pd(fix0
,tx
);
1587 fiy0
= _mm_add_pd(fiy0
,ty
);
1588 fiz0
= _mm_add_pd(fiz0
,tz
);
1590 fjx0
= _mm_add_pd(fjx0
,tx
);
1591 fjy0
= _mm_add_pd(fjy0
,ty
);
1592 fjz0
= _mm_add_pd(fjz0
,tz
);
1594 /**************************
1595 * CALCULATE INTERACTIONS *
1596 **************************/
1598 /* REACTION-FIELD ELECTROSTATICS */
1599 felec
= _mm_mul_pd(qq11
,_mm_sub_pd(_mm_mul_pd(rinv11
,rinvsq11
),krf2
));
1603 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1605 /* Calculate temporary vectorial force */
1606 tx
= _mm_mul_pd(fscal
,dx11
);
1607 ty
= _mm_mul_pd(fscal
,dy11
);
1608 tz
= _mm_mul_pd(fscal
,dz11
);
1610 /* Update vectorial force */
1611 fix1
= _mm_add_pd(fix1
,tx
);
1612 fiy1
= _mm_add_pd(fiy1
,ty
);
1613 fiz1
= _mm_add_pd(fiz1
,tz
);
1615 fjx1
= _mm_add_pd(fjx1
,tx
);
1616 fjy1
= _mm_add_pd(fjy1
,ty
);
1617 fjz1
= _mm_add_pd(fjz1
,tz
);
1619 /**************************
1620 * CALCULATE INTERACTIONS *
1621 **************************/
1623 /* REACTION-FIELD ELECTROSTATICS */
1624 felec
= _mm_mul_pd(qq12
,_mm_sub_pd(_mm_mul_pd(rinv12
,rinvsq12
),krf2
));
1628 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1630 /* Calculate temporary vectorial force */
1631 tx
= _mm_mul_pd(fscal
,dx12
);
1632 ty
= _mm_mul_pd(fscal
,dy12
);
1633 tz
= _mm_mul_pd(fscal
,dz12
);
1635 /* Update vectorial force */
1636 fix1
= _mm_add_pd(fix1
,tx
);
1637 fiy1
= _mm_add_pd(fiy1
,ty
);
1638 fiz1
= _mm_add_pd(fiz1
,tz
);
1640 fjx2
= _mm_add_pd(fjx2
,tx
);
1641 fjy2
= _mm_add_pd(fjy2
,ty
);
1642 fjz2
= _mm_add_pd(fjz2
,tz
);
1644 /**************************
1645 * CALCULATE INTERACTIONS *
1646 **************************/
1648 /* REACTION-FIELD ELECTROSTATICS */
1649 felec
= _mm_mul_pd(qq13
,_mm_sub_pd(_mm_mul_pd(rinv13
,rinvsq13
),krf2
));
1653 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1655 /* Calculate temporary vectorial force */
1656 tx
= _mm_mul_pd(fscal
,dx13
);
1657 ty
= _mm_mul_pd(fscal
,dy13
);
1658 tz
= _mm_mul_pd(fscal
,dz13
);
1660 /* Update vectorial force */
1661 fix1
= _mm_add_pd(fix1
,tx
);
1662 fiy1
= _mm_add_pd(fiy1
,ty
);
1663 fiz1
= _mm_add_pd(fiz1
,tz
);
1665 fjx3
= _mm_add_pd(fjx3
,tx
);
1666 fjy3
= _mm_add_pd(fjy3
,ty
);
1667 fjz3
= _mm_add_pd(fjz3
,tz
);
1669 /**************************
1670 * CALCULATE INTERACTIONS *
1671 **************************/
1673 /* REACTION-FIELD ELECTROSTATICS */
1674 felec
= _mm_mul_pd(qq21
,_mm_sub_pd(_mm_mul_pd(rinv21
,rinvsq21
),krf2
));
1678 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1680 /* Calculate temporary vectorial force */
1681 tx
= _mm_mul_pd(fscal
,dx21
);
1682 ty
= _mm_mul_pd(fscal
,dy21
);
1683 tz
= _mm_mul_pd(fscal
,dz21
);
1685 /* Update vectorial force */
1686 fix2
= _mm_add_pd(fix2
,tx
);
1687 fiy2
= _mm_add_pd(fiy2
,ty
);
1688 fiz2
= _mm_add_pd(fiz2
,tz
);
1690 fjx1
= _mm_add_pd(fjx1
,tx
);
1691 fjy1
= _mm_add_pd(fjy1
,ty
);
1692 fjz1
= _mm_add_pd(fjz1
,tz
);
1694 /**************************
1695 * CALCULATE INTERACTIONS *
1696 **************************/
1698 /* REACTION-FIELD ELECTROSTATICS */
1699 felec
= _mm_mul_pd(qq22
,_mm_sub_pd(_mm_mul_pd(rinv22
,rinvsq22
),krf2
));
1703 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1705 /* Calculate temporary vectorial force */
1706 tx
= _mm_mul_pd(fscal
,dx22
);
1707 ty
= _mm_mul_pd(fscal
,dy22
);
1708 tz
= _mm_mul_pd(fscal
,dz22
);
1710 /* Update vectorial force */
1711 fix2
= _mm_add_pd(fix2
,tx
);
1712 fiy2
= _mm_add_pd(fiy2
,ty
);
1713 fiz2
= _mm_add_pd(fiz2
,tz
);
1715 fjx2
= _mm_add_pd(fjx2
,tx
);
1716 fjy2
= _mm_add_pd(fjy2
,ty
);
1717 fjz2
= _mm_add_pd(fjz2
,tz
);
1719 /**************************
1720 * CALCULATE INTERACTIONS *
1721 **************************/
1723 /* REACTION-FIELD ELECTROSTATICS */
1724 felec
= _mm_mul_pd(qq23
,_mm_sub_pd(_mm_mul_pd(rinv23
,rinvsq23
),krf2
));
1728 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1730 /* Calculate temporary vectorial force */
1731 tx
= _mm_mul_pd(fscal
,dx23
);
1732 ty
= _mm_mul_pd(fscal
,dy23
);
1733 tz
= _mm_mul_pd(fscal
,dz23
);
1735 /* Update vectorial force */
1736 fix2
= _mm_add_pd(fix2
,tx
);
1737 fiy2
= _mm_add_pd(fiy2
,ty
);
1738 fiz2
= _mm_add_pd(fiz2
,tz
);
1740 fjx3
= _mm_add_pd(fjx3
,tx
);
1741 fjy3
= _mm_add_pd(fjy3
,ty
);
1742 fjz3
= _mm_add_pd(fjz3
,tz
);
1744 /**************************
1745 * CALCULATE INTERACTIONS *
1746 **************************/
1748 /* REACTION-FIELD ELECTROSTATICS */
1749 felec
= _mm_mul_pd(qq31
,_mm_sub_pd(_mm_mul_pd(rinv31
,rinvsq31
),krf2
));
1753 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1755 /* Calculate temporary vectorial force */
1756 tx
= _mm_mul_pd(fscal
,dx31
);
1757 ty
= _mm_mul_pd(fscal
,dy31
);
1758 tz
= _mm_mul_pd(fscal
,dz31
);
1760 /* Update vectorial force */
1761 fix3
= _mm_add_pd(fix3
,tx
);
1762 fiy3
= _mm_add_pd(fiy3
,ty
);
1763 fiz3
= _mm_add_pd(fiz3
,tz
);
1765 fjx1
= _mm_add_pd(fjx1
,tx
);
1766 fjy1
= _mm_add_pd(fjy1
,ty
);
1767 fjz1
= _mm_add_pd(fjz1
,tz
);
1769 /**************************
1770 * CALCULATE INTERACTIONS *
1771 **************************/
1773 /* REACTION-FIELD ELECTROSTATICS */
1774 felec
= _mm_mul_pd(qq32
,_mm_sub_pd(_mm_mul_pd(rinv32
,rinvsq32
),krf2
));
1778 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1780 /* Calculate temporary vectorial force */
1781 tx
= _mm_mul_pd(fscal
,dx32
);
1782 ty
= _mm_mul_pd(fscal
,dy32
);
1783 tz
= _mm_mul_pd(fscal
,dz32
);
1785 /* Update vectorial force */
1786 fix3
= _mm_add_pd(fix3
,tx
);
1787 fiy3
= _mm_add_pd(fiy3
,ty
);
1788 fiz3
= _mm_add_pd(fiz3
,tz
);
1790 fjx2
= _mm_add_pd(fjx2
,tx
);
1791 fjy2
= _mm_add_pd(fjy2
,ty
);
1792 fjz2
= _mm_add_pd(fjz2
,tz
);
1794 /**************************
1795 * CALCULATE INTERACTIONS *
1796 **************************/
1798 /* REACTION-FIELD ELECTROSTATICS */
1799 felec
= _mm_mul_pd(qq33
,_mm_sub_pd(_mm_mul_pd(rinv33
,rinvsq33
),krf2
));
1803 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1805 /* Calculate temporary vectorial force */
1806 tx
= _mm_mul_pd(fscal
,dx33
);
1807 ty
= _mm_mul_pd(fscal
,dy33
);
1808 tz
= _mm_mul_pd(fscal
,dz33
);
1810 /* Update vectorial force */
1811 fix3
= _mm_add_pd(fix3
,tx
);
1812 fiy3
= _mm_add_pd(fiy3
,ty
);
1813 fiz3
= _mm_add_pd(fiz3
,tz
);
1815 fjx3
= _mm_add_pd(fjx3
,tx
);
1816 fjy3
= _mm_add_pd(fjy3
,ty
);
1817 fjz3
= _mm_add_pd(fjz3
,tz
);
1819 gmx_mm_decrement_4rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
,fjx1
,fjy1
,fjz1
,fjx2
,fjy2
,fjz2
,fjx3
,fjy3
,fjz3
);
1821 /* Inner loop uses 273 flops */
1824 /* End of innermost loop */
1826 gmx_mm_update_iforce_4atom_swizzle_pd(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,fix3
,fiy3
,fiz3
,
1827 f
+i_coord_offset
,fshift
+i_shift_offset
);
1829 /* Increment number of inner iterations */
1830 inneriter
+= j_index_end
- j_index_start
;
1832 /* Outer loop uses 24 flops */
1835 /* Increment number of outer iterations */
1838 /* Update outer/inner flops */
1840 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4W4_F
,outeriter
*24 + inneriter
*273);