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_ElecEwSh_VdwNone_GeomW3P1_VF_sse2_double
53 * Electrostatics interaction: Ewald
54 * VdW interaction: None
55 * Geometry: Water3-Particle
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecEwSh_VdwNone_GeomW3P1_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
;
87 int vdwjidx0A
,vdwjidx0B
;
88 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
89 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
90 __m128d dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
91 __m128d dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
92 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
95 __m128d ewtabscale
,eweps
,sh_ewald
,ewrt
,ewtabhalfspace
,ewtabF
,ewtabFn
,ewtabD
,ewtabV
;
97 __m128d dummy_mask
,cutoff_mask
;
98 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
99 __m128d one
= _mm_set1_pd(1.0);
100 __m128d two
= _mm_set1_pd(2.0);
106 jindex
= nlist
->jindex
;
108 shiftidx
= nlist
->shift
;
110 shiftvec
= fr
->shift_vec
[0];
111 fshift
= fr
->fshift
[0];
112 facel
= _mm_set1_pd(fr
->epsfac
);
113 charge
= mdatoms
->chargeA
;
115 sh_ewald
= _mm_set1_pd(fr
->ic
->sh_ewald
);
116 ewtab
= fr
->ic
->tabq_coul_FDV0
;
117 ewtabscale
= _mm_set1_pd(fr
->ic
->tabq_scale
);
118 ewtabhalfspace
= _mm_set1_pd(0.5/fr
->ic
->tabq_scale
);
120 /* Setup water-specific parameters */
121 inr
= nlist
->iinr
[0];
122 iq0
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+0]));
123 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
124 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
126 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
127 rcutoff_scalar
= fr
->rcoulomb
;
128 rcutoff
= _mm_set1_pd(rcutoff_scalar
);
129 rcutoff2
= _mm_mul_pd(rcutoff
,rcutoff
);
131 /* Avoid stupid compiler warnings */
139 /* Start outer loop over neighborlists */
140 for(iidx
=0; iidx
<nri
; iidx
++)
142 /* Load shift vector for this list */
143 i_shift_offset
= DIM
*shiftidx
[iidx
];
145 /* Load limits for loop over neighbors */
146 j_index_start
= jindex
[iidx
];
147 j_index_end
= jindex
[iidx
+1];
149 /* Get outer coordinate index */
151 i_coord_offset
= DIM
*inr
;
153 /* Load i particle coords and add shift vector */
154 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
155 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
);
157 fix0
= _mm_setzero_pd();
158 fiy0
= _mm_setzero_pd();
159 fiz0
= _mm_setzero_pd();
160 fix1
= _mm_setzero_pd();
161 fiy1
= _mm_setzero_pd();
162 fiz1
= _mm_setzero_pd();
163 fix2
= _mm_setzero_pd();
164 fiy2
= _mm_setzero_pd();
165 fiz2
= _mm_setzero_pd();
167 /* Reset potential sums */
168 velecsum
= _mm_setzero_pd();
170 /* Start inner kernel loop */
171 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
174 /* Get j neighbor index, and coordinate index */
177 j_coord_offsetA
= DIM
*jnrA
;
178 j_coord_offsetB
= DIM
*jnrB
;
180 /* load j atom coordinates */
181 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
184 /* Calculate displacement vector */
185 dx00
= _mm_sub_pd(ix0
,jx0
);
186 dy00
= _mm_sub_pd(iy0
,jy0
);
187 dz00
= _mm_sub_pd(iz0
,jz0
);
188 dx10
= _mm_sub_pd(ix1
,jx0
);
189 dy10
= _mm_sub_pd(iy1
,jy0
);
190 dz10
= _mm_sub_pd(iz1
,jz0
);
191 dx20
= _mm_sub_pd(ix2
,jx0
);
192 dy20
= _mm_sub_pd(iy2
,jy0
);
193 dz20
= _mm_sub_pd(iz2
,jz0
);
195 /* Calculate squared distance and things based on it */
196 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
197 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
198 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
200 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
201 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
202 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
204 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
205 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
206 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
208 /* Load parameters for j particles */
209 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
211 fjx0
= _mm_setzero_pd();
212 fjy0
= _mm_setzero_pd();
213 fjz0
= _mm_setzero_pd();
215 /**************************
216 * CALCULATE INTERACTIONS *
217 **************************/
219 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
222 r00
= _mm_mul_pd(rsq00
,rinv00
);
224 /* Compute parameters for interactions between i and j atoms */
225 qq00
= _mm_mul_pd(iq0
,jq0
);
227 /* EWALD ELECTROSTATICS */
229 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
230 ewrt
= _mm_mul_pd(r00
,ewtabscale
);
231 ewitab
= _mm_cvttpd_epi32(ewrt
);
232 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
233 ewitab
= _mm_slli_epi32(ewitab
,2);
234 ewtabF
= _mm_load_pd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
235 ewtabD
= _mm_load_pd( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
236 GMX_MM_TRANSPOSE2_PD(ewtabF
,ewtabD
);
237 ewtabV
= _mm_load_sd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) +2);
238 ewtabFn
= _mm_load_sd( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) +2);
239 GMX_MM_TRANSPOSE2_PD(ewtabV
,ewtabFn
);
240 felec
= _mm_add_pd(ewtabF
,_mm_mul_pd(eweps
,ewtabD
));
241 velec
= _mm_sub_pd(ewtabV
,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace
,eweps
),_mm_add_pd(ewtabF
,felec
)));
242 velec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_sub_pd(rinv00
,sh_ewald
),velec
));
243 felec
= _mm_mul_pd(_mm_mul_pd(qq00
,rinv00
),_mm_sub_pd(rinvsq00
,felec
));
245 cutoff_mask
= _mm_cmplt_pd(rsq00
,rcutoff2
);
247 /* Update potential sum for this i atom from the interaction with this j atom. */
248 velec
= _mm_and_pd(velec
,cutoff_mask
);
249 velecsum
= _mm_add_pd(velecsum
,velec
);
253 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
255 /* Calculate temporary vectorial force */
256 tx
= _mm_mul_pd(fscal
,dx00
);
257 ty
= _mm_mul_pd(fscal
,dy00
);
258 tz
= _mm_mul_pd(fscal
,dz00
);
260 /* Update vectorial force */
261 fix0
= _mm_add_pd(fix0
,tx
);
262 fiy0
= _mm_add_pd(fiy0
,ty
);
263 fiz0
= _mm_add_pd(fiz0
,tz
);
265 fjx0
= _mm_add_pd(fjx0
,tx
);
266 fjy0
= _mm_add_pd(fjy0
,ty
);
267 fjz0
= _mm_add_pd(fjz0
,tz
);
271 /**************************
272 * CALCULATE INTERACTIONS *
273 **************************/
275 if (gmx_mm_any_lt(rsq10
,rcutoff2
))
278 r10
= _mm_mul_pd(rsq10
,rinv10
);
280 /* Compute parameters for interactions between i and j atoms */
281 qq10
= _mm_mul_pd(iq1
,jq0
);
283 /* EWALD ELECTROSTATICS */
285 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
286 ewrt
= _mm_mul_pd(r10
,ewtabscale
);
287 ewitab
= _mm_cvttpd_epi32(ewrt
);
288 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
289 ewitab
= _mm_slli_epi32(ewitab
,2);
290 ewtabF
= _mm_load_pd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
291 ewtabD
= _mm_load_pd( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
292 GMX_MM_TRANSPOSE2_PD(ewtabF
,ewtabD
);
293 ewtabV
= _mm_load_sd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) +2);
294 ewtabFn
= _mm_load_sd( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) +2);
295 GMX_MM_TRANSPOSE2_PD(ewtabV
,ewtabFn
);
296 felec
= _mm_add_pd(ewtabF
,_mm_mul_pd(eweps
,ewtabD
));
297 velec
= _mm_sub_pd(ewtabV
,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace
,eweps
),_mm_add_pd(ewtabF
,felec
)));
298 velec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_sub_pd(rinv10
,sh_ewald
),velec
));
299 felec
= _mm_mul_pd(_mm_mul_pd(qq10
,rinv10
),_mm_sub_pd(rinvsq10
,felec
));
301 cutoff_mask
= _mm_cmplt_pd(rsq10
,rcutoff2
);
303 /* Update potential sum for this i atom from the interaction with this j atom. */
304 velec
= _mm_and_pd(velec
,cutoff_mask
);
305 velecsum
= _mm_add_pd(velecsum
,velec
);
309 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
311 /* Calculate temporary vectorial force */
312 tx
= _mm_mul_pd(fscal
,dx10
);
313 ty
= _mm_mul_pd(fscal
,dy10
);
314 tz
= _mm_mul_pd(fscal
,dz10
);
316 /* Update vectorial force */
317 fix1
= _mm_add_pd(fix1
,tx
);
318 fiy1
= _mm_add_pd(fiy1
,ty
);
319 fiz1
= _mm_add_pd(fiz1
,tz
);
321 fjx0
= _mm_add_pd(fjx0
,tx
);
322 fjy0
= _mm_add_pd(fjy0
,ty
);
323 fjz0
= _mm_add_pd(fjz0
,tz
);
327 /**************************
328 * CALCULATE INTERACTIONS *
329 **************************/
331 if (gmx_mm_any_lt(rsq20
,rcutoff2
))
334 r20
= _mm_mul_pd(rsq20
,rinv20
);
336 /* Compute parameters for interactions between i and j atoms */
337 qq20
= _mm_mul_pd(iq2
,jq0
);
339 /* EWALD ELECTROSTATICS */
341 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
342 ewrt
= _mm_mul_pd(r20
,ewtabscale
);
343 ewitab
= _mm_cvttpd_epi32(ewrt
);
344 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
345 ewitab
= _mm_slli_epi32(ewitab
,2);
346 ewtabF
= _mm_load_pd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
347 ewtabD
= _mm_load_pd( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) );
348 GMX_MM_TRANSPOSE2_PD(ewtabF
,ewtabD
);
349 ewtabV
= _mm_load_sd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) +2);
350 ewtabFn
= _mm_load_sd( ewtab
+ gmx_mm_extract_epi32(ewitab
,1) +2);
351 GMX_MM_TRANSPOSE2_PD(ewtabV
,ewtabFn
);
352 felec
= _mm_add_pd(ewtabF
,_mm_mul_pd(eweps
,ewtabD
));
353 velec
= _mm_sub_pd(ewtabV
,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace
,eweps
),_mm_add_pd(ewtabF
,felec
)));
354 velec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_sub_pd(rinv20
,sh_ewald
),velec
));
355 felec
= _mm_mul_pd(_mm_mul_pd(qq20
,rinv20
),_mm_sub_pd(rinvsq20
,felec
));
357 cutoff_mask
= _mm_cmplt_pd(rsq20
,rcutoff2
);
359 /* Update potential sum for this i atom from the interaction with this j atom. */
360 velec
= _mm_and_pd(velec
,cutoff_mask
);
361 velecsum
= _mm_add_pd(velecsum
,velec
);
365 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
367 /* Calculate temporary vectorial force */
368 tx
= _mm_mul_pd(fscal
,dx20
);
369 ty
= _mm_mul_pd(fscal
,dy20
);
370 tz
= _mm_mul_pd(fscal
,dz20
);
372 /* Update vectorial force */
373 fix2
= _mm_add_pd(fix2
,tx
);
374 fiy2
= _mm_add_pd(fiy2
,ty
);
375 fiz2
= _mm_add_pd(fiz2
,tz
);
377 fjx0
= _mm_add_pd(fjx0
,tx
);
378 fjy0
= _mm_add_pd(fjy0
,ty
);
379 fjz0
= _mm_add_pd(fjz0
,tz
);
383 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
);
385 /* Inner loop uses 141 flops */
392 j_coord_offsetA
= DIM
*jnrA
;
394 /* load j atom coordinates */
395 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
398 /* Calculate displacement vector */
399 dx00
= _mm_sub_pd(ix0
,jx0
);
400 dy00
= _mm_sub_pd(iy0
,jy0
);
401 dz00
= _mm_sub_pd(iz0
,jz0
);
402 dx10
= _mm_sub_pd(ix1
,jx0
);
403 dy10
= _mm_sub_pd(iy1
,jy0
);
404 dz10
= _mm_sub_pd(iz1
,jz0
);
405 dx20
= _mm_sub_pd(ix2
,jx0
);
406 dy20
= _mm_sub_pd(iy2
,jy0
);
407 dz20
= _mm_sub_pd(iz2
,jz0
);
409 /* Calculate squared distance and things based on it */
410 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
411 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
412 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
414 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
415 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
416 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
418 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
419 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
420 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
422 /* Load parameters for j particles */
423 jq0
= _mm_load_sd(charge
+jnrA
+0);
425 fjx0
= _mm_setzero_pd();
426 fjy0
= _mm_setzero_pd();
427 fjz0
= _mm_setzero_pd();
429 /**************************
430 * CALCULATE INTERACTIONS *
431 **************************/
433 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
436 r00
= _mm_mul_pd(rsq00
,rinv00
);
438 /* Compute parameters for interactions between i and j atoms */
439 qq00
= _mm_mul_pd(iq0
,jq0
);
441 /* EWALD ELECTROSTATICS */
443 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
444 ewrt
= _mm_mul_pd(r00
,ewtabscale
);
445 ewitab
= _mm_cvttpd_epi32(ewrt
);
446 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
447 ewitab
= _mm_slli_epi32(ewitab
,2);
448 ewtabF
= _mm_load_pd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
449 ewtabD
= _mm_setzero_pd();
450 GMX_MM_TRANSPOSE2_PD(ewtabF
,ewtabD
);
451 ewtabV
= _mm_load_sd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) +2);
452 ewtabFn
= _mm_setzero_pd();
453 GMX_MM_TRANSPOSE2_PD(ewtabV
,ewtabFn
);
454 felec
= _mm_add_pd(ewtabF
,_mm_mul_pd(eweps
,ewtabD
));
455 velec
= _mm_sub_pd(ewtabV
,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace
,eweps
),_mm_add_pd(ewtabF
,felec
)));
456 velec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_sub_pd(rinv00
,sh_ewald
),velec
));
457 felec
= _mm_mul_pd(_mm_mul_pd(qq00
,rinv00
),_mm_sub_pd(rinvsq00
,felec
));
459 cutoff_mask
= _mm_cmplt_pd(rsq00
,rcutoff2
);
461 /* Update potential sum for this i atom from the interaction with this j atom. */
462 velec
= _mm_and_pd(velec
,cutoff_mask
);
463 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
464 velecsum
= _mm_add_pd(velecsum
,velec
);
468 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
470 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
472 /* Calculate temporary vectorial force */
473 tx
= _mm_mul_pd(fscal
,dx00
);
474 ty
= _mm_mul_pd(fscal
,dy00
);
475 tz
= _mm_mul_pd(fscal
,dz00
);
477 /* Update vectorial force */
478 fix0
= _mm_add_pd(fix0
,tx
);
479 fiy0
= _mm_add_pd(fiy0
,ty
);
480 fiz0
= _mm_add_pd(fiz0
,tz
);
482 fjx0
= _mm_add_pd(fjx0
,tx
);
483 fjy0
= _mm_add_pd(fjy0
,ty
);
484 fjz0
= _mm_add_pd(fjz0
,tz
);
488 /**************************
489 * CALCULATE INTERACTIONS *
490 **************************/
492 if (gmx_mm_any_lt(rsq10
,rcutoff2
))
495 r10
= _mm_mul_pd(rsq10
,rinv10
);
497 /* Compute parameters for interactions between i and j atoms */
498 qq10
= _mm_mul_pd(iq1
,jq0
);
500 /* EWALD ELECTROSTATICS */
502 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
503 ewrt
= _mm_mul_pd(r10
,ewtabscale
);
504 ewitab
= _mm_cvttpd_epi32(ewrt
);
505 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
506 ewitab
= _mm_slli_epi32(ewitab
,2);
507 ewtabF
= _mm_load_pd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
508 ewtabD
= _mm_setzero_pd();
509 GMX_MM_TRANSPOSE2_PD(ewtabF
,ewtabD
);
510 ewtabV
= _mm_load_sd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) +2);
511 ewtabFn
= _mm_setzero_pd();
512 GMX_MM_TRANSPOSE2_PD(ewtabV
,ewtabFn
);
513 felec
= _mm_add_pd(ewtabF
,_mm_mul_pd(eweps
,ewtabD
));
514 velec
= _mm_sub_pd(ewtabV
,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace
,eweps
),_mm_add_pd(ewtabF
,felec
)));
515 velec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_sub_pd(rinv10
,sh_ewald
),velec
));
516 felec
= _mm_mul_pd(_mm_mul_pd(qq10
,rinv10
),_mm_sub_pd(rinvsq10
,felec
));
518 cutoff_mask
= _mm_cmplt_pd(rsq10
,rcutoff2
);
520 /* Update potential sum for this i atom from the interaction with this j atom. */
521 velec
= _mm_and_pd(velec
,cutoff_mask
);
522 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
523 velecsum
= _mm_add_pd(velecsum
,velec
);
527 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
529 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
531 /* Calculate temporary vectorial force */
532 tx
= _mm_mul_pd(fscal
,dx10
);
533 ty
= _mm_mul_pd(fscal
,dy10
);
534 tz
= _mm_mul_pd(fscal
,dz10
);
536 /* Update vectorial force */
537 fix1
= _mm_add_pd(fix1
,tx
);
538 fiy1
= _mm_add_pd(fiy1
,ty
);
539 fiz1
= _mm_add_pd(fiz1
,tz
);
541 fjx0
= _mm_add_pd(fjx0
,tx
);
542 fjy0
= _mm_add_pd(fjy0
,ty
);
543 fjz0
= _mm_add_pd(fjz0
,tz
);
547 /**************************
548 * CALCULATE INTERACTIONS *
549 **************************/
551 if (gmx_mm_any_lt(rsq20
,rcutoff2
))
554 r20
= _mm_mul_pd(rsq20
,rinv20
);
556 /* Compute parameters for interactions between i and j atoms */
557 qq20
= _mm_mul_pd(iq2
,jq0
);
559 /* EWALD ELECTROSTATICS */
561 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
562 ewrt
= _mm_mul_pd(r20
,ewtabscale
);
563 ewitab
= _mm_cvttpd_epi32(ewrt
);
564 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
565 ewitab
= _mm_slli_epi32(ewitab
,2);
566 ewtabF
= _mm_load_pd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) );
567 ewtabD
= _mm_setzero_pd();
568 GMX_MM_TRANSPOSE2_PD(ewtabF
,ewtabD
);
569 ewtabV
= _mm_load_sd( ewtab
+ gmx_mm_extract_epi32(ewitab
,0) +2);
570 ewtabFn
= _mm_setzero_pd();
571 GMX_MM_TRANSPOSE2_PD(ewtabV
,ewtabFn
);
572 felec
= _mm_add_pd(ewtabF
,_mm_mul_pd(eweps
,ewtabD
));
573 velec
= _mm_sub_pd(ewtabV
,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace
,eweps
),_mm_add_pd(ewtabF
,felec
)));
574 velec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_sub_pd(rinv20
,sh_ewald
),velec
));
575 felec
= _mm_mul_pd(_mm_mul_pd(qq20
,rinv20
),_mm_sub_pd(rinvsq20
,felec
));
577 cutoff_mask
= _mm_cmplt_pd(rsq20
,rcutoff2
);
579 /* Update potential sum for this i atom from the interaction with this j atom. */
580 velec
= _mm_and_pd(velec
,cutoff_mask
);
581 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
582 velecsum
= _mm_add_pd(velecsum
,velec
);
586 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
588 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
590 /* Calculate temporary vectorial force */
591 tx
= _mm_mul_pd(fscal
,dx20
);
592 ty
= _mm_mul_pd(fscal
,dy20
);
593 tz
= _mm_mul_pd(fscal
,dz20
);
595 /* Update vectorial force */
596 fix2
= _mm_add_pd(fix2
,tx
);
597 fiy2
= _mm_add_pd(fiy2
,ty
);
598 fiz2
= _mm_add_pd(fiz2
,tz
);
600 fjx0
= _mm_add_pd(fjx0
,tx
);
601 fjy0
= _mm_add_pd(fjy0
,ty
);
602 fjz0
= _mm_add_pd(fjz0
,tz
);
606 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
);
608 /* Inner loop uses 141 flops */
611 /* End of innermost loop */
613 gmx_mm_update_iforce_3atom_swizzle_pd(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,
614 f
+i_coord_offset
,fshift
+i_shift_offset
);
617 /* Update potential energies */
618 gmx_mm_update_1pot_pd(velecsum
,kernel_data
->energygrp_elec
+ggid
);
620 /* Increment number of inner iterations */
621 inneriter
+= j_index_end
- j_index_start
;
623 /* Outer loop uses 19 flops */
626 /* Increment number of outer iterations */
629 /* Update outer/inner flops */
631 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_W3_VF
,outeriter
*19 + inneriter
*141);
634 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW3P1_F_sse2_double
635 * Electrostatics interaction: Ewald
636 * VdW interaction: None
637 * Geometry: Water3-Particle
638 * Calculate force/pot: Force
641 nb_kernel_ElecEwSh_VdwNone_GeomW3P1_F_sse2_double
642 (t_nblist
* gmx_restrict nlist
,
643 rvec
* gmx_restrict xx
,
644 rvec
* gmx_restrict ff
,
645 t_forcerec
* gmx_restrict fr
,
646 t_mdatoms
* gmx_restrict mdatoms
,
647 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
648 t_nrnb
* gmx_restrict nrnb
)
650 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
651 * just 0 for non-waters.
652 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
653 * jnr indices corresponding to data put in the four positions in the SIMD register.
655 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
656 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
658 int j_coord_offsetA
,j_coord_offsetB
;
659 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
661 real
*shiftvec
,*fshift
,*x
,*f
;
662 __m128d tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
664 __m128d ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
666 __m128d ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
668 __m128d ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
669 int vdwjidx0A
,vdwjidx0B
;
670 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
671 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
672 __m128d dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
673 __m128d dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
674 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
677 __m128d ewtabscale
,eweps
,sh_ewald
,ewrt
,ewtabhalfspace
,ewtabF
,ewtabFn
,ewtabD
,ewtabV
;
679 __m128d dummy_mask
,cutoff_mask
;
680 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
681 __m128d one
= _mm_set1_pd(1.0);
682 __m128d two
= _mm_set1_pd(2.0);
688 jindex
= nlist
->jindex
;
690 shiftidx
= nlist
->shift
;
692 shiftvec
= fr
->shift_vec
[0];
693 fshift
= fr
->fshift
[0];
694 facel
= _mm_set1_pd(fr
->epsfac
);
695 charge
= mdatoms
->chargeA
;
697 sh_ewald
= _mm_set1_pd(fr
->ic
->sh_ewald
);
698 ewtab
= fr
->ic
->tabq_coul_F
;
699 ewtabscale
= _mm_set1_pd(fr
->ic
->tabq_scale
);
700 ewtabhalfspace
= _mm_set1_pd(0.5/fr
->ic
->tabq_scale
);
702 /* Setup water-specific parameters */
703 inr
= nlist
->iinr
[0];
704 iq0
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+0]));
705 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
706 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
708 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
709 rcutoff_scalar
= fr
->rcoulomb
;
710 rcutoff
= _mm_set1_pd(rcutoff_scalar
);
711 rcutoff2
= _mm_mul_pd(rcutoff
,rcutoff
);
713 /* Avoid stupid compiler warnings */
721 /* Start outer loop over neighborlists */
722 for(iidx
=0; iidx
<nri
; iidx
++)
724 /* Load shift vector for this list */
725 i_shift_offset
= DIM
*shiftidx
[iidx
];
727 /* Load limits for loop over neighbors */
728 j_index_start
= jindex
[iidx
];
729 j_index_end
= jindex
[iidx
+1];
731 /* Get outer coordinate index */
733 i_coord_offset
= DIM
*inr
;
735 /* Load i particle coords and add shift vector */
736 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
737 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
);
739 fix0
= _mm_setzero_pd();
740 fiy0
= _mm_setzero_pd();
741 fiz0
= _mm_setzero_pd();
742 fix1
= _mm_setzero_pd();
743 fiy1
= _mm_setzero_pd();
744 fiz1
= _mm_setzero_pd();
745 fix2
= _mm_setzero_pd();
746 fiy2
= _mm_setzero_pd();
747 fiz2
= _mm_setzero_pd();
749 /* Start inner kernel loop */
750 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
753 /* Get j neighbor index, and coordinate index */
756 j_coord_offsetA
= DIM
*jnrA
;
757 j_coord_offsetB
= DIM
*jnrB
;
759 /* load j atom coordinates */
760 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
763 /* Calculate displacement vector */
764 dx00
= _mm_sub_pd(ix0
,jx0
);
765 dy00
= _mm_sub_pd(iy0
,jy0
);
766 dz00
= _mm_sub_pd(iz0
,jz0
);
767 dx10
= _mm_sub_pd(ix1
,jx0
);
768 dy10
= _mm_sub_pd(iy1
,jy0
);
769 dz10
= _mm_sub_pd(iz1
,jz0
);
770 dx20
= _mm_sub_pd(ix2
,jx0
);
771 dy20
= _mm_sub_pd(iy2
,jy0
);
772 dz20
= _mm_sub_pd(iz2
,jz0
);
774 /* Calculate squared distance and things based on it */
775 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
776 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
777 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
779 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
780 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
781 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
783 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
784 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
785 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
787 /* Load parameters for j particles */
788 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
790 fjx0
= _mm_setzero_pd();
791 fjy0
= _mm_setzero_pd();
792 fjz0
= _mm_setzero_pd();
794 /**************************
795 * CALCULATE INTERACTIONS *
796 **************************/
798 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
801 r00
= _mm_mul_pd(rsq00
,rinv00
);
803 /* Compute parameters for interactions between i and j atoms */
804 qq00
= _mm_mul_pd(iq0
,jq0
);
806 /* EWALD ELECTROSTATICS */
808 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
809 ewrt
= _mm_mul_pd(r00
,ewtabscale
);
810 ewitab
= _mm_cvttpd_epi32(ewrt
);
811 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
812 gmx_mm_load_2pair_swizzle_pd(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
814 felec
= _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one
,eweps
),ewtabF
),_mm_mul_pd(eweps
,ewtabFn
));
815 felec
= _mm_mul_pd(_mm_mul_pd(qq00
,rinv00
),_mm_sub_pd(rinvsq00
,felec
));
817 cutoff_mask
= _mm_cmplt_pd(rsq00
,rcutoff2
);
821 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
823 /* Calculate temporary vectorial force */
824 tx
= _mm_mul_pd(fscal
,dx00
);
825 ty
= _mm_mul_pd(fscal
,dy00
);
826 tz
= _mm_mul_pd(fscal
,dz00
);
828 /* Update vectorial force */
829 fix0
= _mm_add_pd(fix0
,tx
);
830 fiy0
= _mm_add_pd(fiy0
,ty
);
831 fiz0
= _mm_add_pd(fiz0
,tz
);
833 fjx0
= _mm_add_pd(fjx0
,tx
);
834 fjy0
= _mm_add_pd(fjy0
,ty
);
835 fjz0
= _mm_add_pd(fjz0
,tz
);
839 /**************************
840 * CALCULATE INTERACTIONS *
841 **************************/
843 if (gmx_mm_any_lt(rsq10
,rcutoff2
))
846 r10
= _mm_mul_pd(rsq10
,rinv10
);
848 /* Compute parameters for interactions between i and j atoms */
849 qq10
= _mm_mul_pd(iq1
,jq0
);
851 /* EWALD ELECTROSTATICS */
853 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
854 ewrt
= _mm_mul_pd(r10
,ewtabscale
);
855 ewitab
= _mm_cvttpd_epi32(ewrt
);
856 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
857 gmx_mm_load_2pair_swizzle_pd(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
859 felec
= _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one
,eweps
),ewtabF
),_mm_mul_pd(eweps
,ewtabFn
));
860 felec
= _mm_mul_pd(_mm_mul_pd(qq10
,rinv10
),_mm_sub_pd(rinvsq10
,felec
));
862 cutoff_mask
= _mm_cmplt_pd(rsq10
,rcutoff2
);
866 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
868 /* Calculate temporary vectorial force */
869 tx
= _mm_mul_pd(fscal
,dx10
);
870 ty
= _mm_mul_pd(fscal
,dy10
);
871 tz
= _mm_mul_pd(fscal
,dz10
);
873 /* Update vectorial force */
874 fix1
= _mm_add_pd(fix1
,tx
);
875 fiy1
= _mm_add_pd(fiy1
,ty
);
876 fiz1
= _mm_add_pd(fiz1
,tz
);
878 fjx0
= _mm_add_pd(fjx0
,tx
);
879 fjy0
= _mm_add_pd(fjy0
,ty
);
880 fjz0
= _mm_add_pd(fjz0
,tz
);
884 /**************************
885 * CALCULATE INTERACTIONS *
886 **************************/
888 if (gmx_mm_any_lt(rsq20
,rcutoff2
))
891 r20
= _mm_mul_pd(rsq20
,rinv20
);
893 /* Compute parameters for interactions between i and j atoms */
894 qq20
= _mm_mul_pd(iq2
,jq0
);
896 /* EWALD ELECTROSTATICS */
898 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
899 ewrt
= _mm_mul_pd(r20
,ewtabscale
);
900 ewitab
= _mm_cvttpd_epi32(ewrt
);
901 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
902 gmx_mm_load_2pair_swizzle_pd(ewtab
+gmx_mm_extract_epi32(ewitab
,0),ewtab
+gmx_mm_extract_epi32(ewitab
,1),
904 felec
= _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one
,eweps
),ewtabF
),_mm_mul_pd(eweps
,ewtabFn
));
905 felec
= _mm_mul_pd(_mm_mul_pd(qq20
,rinv20
),_mm_sub_pd(rinvsq20
,felec
));
907 cutoff_mask
= _mm_cmplt_pd(rsq20
,rcutoff2
);
911 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
913 /* Calculate temporary vectorial force */
914 tx
= _mm_mul_pd(fscal
,dx20
);
915 ty
= _mm_mul_pd(fscal
,dy20
);
916 tz
= _mm_mul_pd(fscal
,dz20
);
918 /* Update vectorial force */
919 fix2
= _mm_add_pd(fix2
,tx
);
920 fiy2
= _mm_add_pd(fiy2
,ty
);
921 fiz2
= _mm_add_pd(fiz2
,tz
);
923 fjx0
= _mm_add_pd(fjx0
,tx
);
924 fjy0
= _mm_add_pd(fjy0
,ty
);
925 fjz0
= _mm_add_pd(fjz0
,tz
);
929 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
);
931 /* Inner loop uses 120 flops */
938 j_coord_offsetA
= DIM
*jnrA
;
940 /* load j atom coordinates */
941 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
944 /* Calculate displacement vector */
945 dx00
= _mm_sub_pd(ix0
,jx0
);
946 dy00
= _mm_sub_pd(iy0
,jy0
);
947 dz00
= _mm_sub_pd(iz0
,jz0
);
948 dx10
= _mm_sub_pd(ix1
,jx0
);
949 dy10
= _mm_sub_pd(iy1
,jy0
);
950 dz10
= _mm_sub_pd(iz1
,jz0
);
951 dx20
= _mm_sub_pd(ix2
,jx0
);
952 dy20
= _mm_sub_pd(iy2
,jy0
);
953 dz20
= _mm_sub_pd(iz2
,jz0
);
955 /* Calculate squared distance and things based on it */
956 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
957 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
958 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
960 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
961 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
962 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
964 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
965 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
966 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
968 /* Load parameters for j particles */
969 jq0
= _mm_load_sd(charge
+jnrA
+0);
971 fjx0
= _mm_setzero_pd();
972 fjy0
= _mm_setzero_pd();
973 fjz0
= _mm_setzero_pd();
975 /**************************
976 * CALCULATE INTERACTIONS *
977 **************************/
979 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
982 r00
= _mm_mul_pd(rsq00
,rinv00
);
984 /* Compute parameters for interactions between i and j atoms */
985 qq00
= _mm_mul_pd(iq0
,jq0
);
987 /* EWALD ELECTROSTATICS */
989 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
990 ewrt
= _mm_mul_pd(r00
,ewtabscale
);
991 ewitab
= _mm_cvttpd_epi32(ewrt
);
992 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
993 gmx_mm_load_1pair_swizzle_pd(ewtab
+gmx_mm_extract_epi32(ewitab
,0),&ewtabF
,&ewtabFn
);
994 felec
= _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one
,eweps
),ewtabF
),_mm_mul_pd(eweps
,ewtabFn
));
995 felec
= _mm_mul_pd(_mm_mul_pd(qq00
,rinv00
),_mm_sub_pd(rinvsq00
,felec
));
997 cutoff_mask
= _mm_cmplt_pd(rsq00
,rcutoff2
);
1001 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
1003 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1005 /* Calculate temporary vectorial force */
1006 tx
= _mm_mul_pd(fscal
,dx00
);
1007 ty
= _mm_mul_pd(fscal
,dy00
);
1008 tz
= _mm_mul_pd(fscal
,dz00
);
1010 /* Update vectorial force */
1011 fix0
= _mm_add_pd(fix0
,tx
);
1012 fiy0
= _mm_add_pd(fiy0
,ty
);
1013 fiz0
= _mm_add_pd(fiz0
,tz
);
1015 fjx0
= _mm_add_pd(fjx0
,tx
);
1016 fjy0
= _mm_add_pd(fjy0
,ty
);
1017 fjz0
= _mm_add_pd(fjz0
,tz
);
1021 /**************************
1022 * CALCULATE INTERACTIONS *
1023 **************************/
1025 if (gmx_mm_any_lt(rsq10
,rcutoff2
))
1028 r10
= _mm_mul_pd(rsq10
,rinv10
);
1030 /* Compute parameters for interactions between i and j atoms */
1031 qq10
= _mm_mul_pd(iq1
,jq0
);
1033 /* EWALD ELECTROSTATICS */
1035 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1036 ewrt
= _mm_mul_pd(r10
,ewtabscale
);
1037 ewitab
= _mm_cvttpd_epi32(ewrt
);
1038 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
1039 gmx_mm_load_1pair_swizzle_pd(ewtab
+gmx_mm_extract_epi32(ewitab
,0),&ewtabF
,&ewtabFn
);
1040 felec
= _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one
,eweps
),ewtabF
),_mm_mul_pd(eweps
,ewtabFn
));
1041 felec
= _mm_mul_pd(_mm_mul_pd(qq10
,rinv10
),_mm_sub_pd(rinvsq10
,felec
));
1043 cutoff_mask
= _mm_cmplt_pd(rsq10
,rcutoff2
);
1047 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
1049 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1051 /* Calculate temporary vectorial force */
1052 tx
= _mm_mul_pd(fscal
,dx10
);
1053 ty
= _mm_mul_pd(fscal
,dy10
);
1054 tz
= _mm_mul_pd(fscal
,dz10
);
1056 /* Update vectorial force */
1057 fix1
= _mm_add_pd(fix1
,tx
);
1058 fiy1
= _mm_add_pd(fiy1
,ty
);
1059 fiz1
= _mm_add_pd(fiz1
,tz
);
1061 fjx0
= _mm_add_pd(fjx0
,tx
);
1062 fjy0
= _mm_add_pd(fjy0
,ty
);
1063 fjz0
= _mm_add_pd(fjz0
,tz
);
1067 /**************************
1068 * CALCULATE INTERACTIONS *
1069 **************************/
1071 if (gmx_mm_any_lt(rsq20
,rcutoff2
))
1074 r20
= _mm_mul_pd(rsq20
,rinv20
);
1076 /* Compute parameters for interactions between i and j atoms */
1077 qq20
= _mm_mul_pd(iq2
,jq0
);
1079 /* EWALD ELECTROSTATICS */
1081 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1082 ewrt
= _mm_mul_pd(r20
,ewtabscale
);
1083 ewitab
= _mm_cvttpd_epi32(ewrt
);
1084 eweps
= _mm_sub_pd(ewrt
,_mm_cvtepi32_pd(ewitab
));
1085 gmx_mm_load_1pair_swizzle_pd(ewtab
+gmx_mm_extract_epi32(ewitab
,0),&ewtabF
,&ewtabFn
);
1086 felec
= _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one
,eweps
),ewtabF
),_mm_mul_pd(eweps
,ewtabFn
));
1087 felec
= _mm_mul_pd(_mm_mul_pd(qq20
,rinv20
),_mm_sub_pd(rinvsq20
,felec
));
1089 cutoff_mask
= _mm_cmplt_pd(rsq20
,rcutoff2
);
1093 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
1095 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
1097 /* Calculate temporary vectorial force */
1098 tx
= _mm_mul_pd(fscal
,dx20
);
1099 ty
= _mm_mul_pd(fscal
,dy20
);
1100 tz
= _mm_mul_pd(fscal
,dz20
);
1102 /* Update vectorial force */
1103 fix2
= _mm_add_pd(fix2
,tx
);
1104 fiy2
= _mm_add_pd(fiy2
,ty
);
1105 fiz2
= _mm_add_pd(fiz2
,tz
);
1107 fjx0
= _mm_add_pd(fjx0
,tx
);
1108 fjy0
= _mm_add_pd(fjy0
,ty
);
1109 fjz0
= _mm_add_pd(fjz0
,tz
);
1113 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
);
1115 /* Inner loop uses 120 flops */
1118 /* End of innermost loop */
1120 gmx_mm_update_iforce_3atom_swizzle_pd(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,
1121 f
+i_coord_offset
,fshift
+i_shift_offset
);
1123 /* Increment number of inner iterations */
1124 inneriter
+= j_index_end
- j_index_start
;
1126 /* Outer loop uses 18 flops */
1129 /* Increment number of outer iterations */
1132 /* Update outer/inner flops */
1134 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_W3_F
,outeriter
*18 + inneriter
*120);