2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS sse4_1_double kernel generator.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "gromacs/simd/math_x86_sse4_1_double.h"
48 #include "kernelutil_x86_sse4_1_double.h"
51 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4P1_VF_sse4_1_double
52 * Electrostatics interaction: ReactionField
53 * VdW interaction: None
54 * Geometry: Water4-Particle
55 * Calculate force/pot: PotentialAndForce
58 nb_kernel_ElecRF_VdwNone_GeomW4P1_VF_sse4_1_double
59 (t_nblist
* gmx_restrict nlist
,
60 rvec
* gmx_restrict xx
,
61 rvec
* gmx_restrict ff
,
62 t_forcerec
* gmx_restrict fr
,
63 t_mdatoms
* gmx_restrict mdatoms
,
64 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
65 t_nrnb
* gmx_restrict nrnb
)
67 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68 * just 0 for non-waters.
69 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
70 * jnr indices corresponding to data put in the four positions in the SIMD register.
72 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
73 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
75 int j_coord_offsetA
,j_coord_offsetB
;
76 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
78 real
*shiftvec
,*fshift
,*x
,*f
;
79 __m128d tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
81 __m128d ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
83 __m128d ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
85 __m128d ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
86 int vdwjidx0A
,vdwjidx0B
;
87 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
88 __m128d dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
89 __m128d dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
90 __m128d dx30
,dy30
,dz30
,rsq30
,rinv30
,rinvsq30
,r30
,qq30
,c6_30
,c12_30
;
91 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
93 __m128d dummy_mask
,cutoff_mask
;
94 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
95 __m128d one
= _mm_set1_pd(1.0);
96 __m128d two
= _mm_set1_pd(2.0);
102 jindex
= nlist
->jindex
;
104 shiftidx
= nlist
->shift
;
106 shiftvec
= fr
->shift_vec
[0];
107 fshift
= fr
->fshift
[0];
108 facel
= _mm_set1_pd(fr
->epsfac
);
109 charge
= mdatoms
->chargeA
;
110 krf
= _mm_set1_pd(fr
->ic
->k_rf
);
111 krf2
= _mm_set1_pd(fr
->ic
->k_rf
*2.0);
112 crf
= _mm_set1_pd(fr
->ic
->c_rf
);
114 /* Setup water-specific parameters */
115 inr
= nlist
->iinr
[0];
116 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
117 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
118 iq3
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+3]));
120 /* Avoid stupid compiler warnings */
128 /* Start outer loop over neighborlists */
129 for(iidx
=0; iidx
<nri
; iidx
++)
131 /* Load shift vector for this list */
132 i_shift_offset
= DIM
*shiftidx
[iidx
];
134 /* Load limits for loop over neighbors */
135 j_index_start
= jindex
[iidx
];
136 j_index_end
= jindex
[iidx
+1];
138 /* Get outer coordinate index */
140 i_coord_offset
= DIM
*inr
;
142 /* Load i particle coords and add shift vector */
143 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
+DIM
,
144 &ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
,&ix3
,&iy3
,&iz3
);
146 fix1
= _mm_setzero_pd();
147 fiy1
= _mm_setzero_pd();
148 fiz1
= _mm_setzero_pd();
149 fix2
= _mm_setzero_pd();
150 fiy2
= _mm_setzero_pd();
151 fiz2
= _mm_setzero_pd();
152 fix3
= _mm_setzero_pd();
153 fiy3
= _mm_setzero_pd();
154 fiz3
= _mm_setzero_pd();
156 /* Reset potential sums */
157 velecsum
= _mm_setzero_pd();
159 /* Start inner kernel loop */
160 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
163 /* Get j neighbor index, and coordinate index */
166 j_coord_offsetA
= DIM
*jnrA
;
167 j_coord_offsetB
= DIM
*jnrB
;
169 /* load j atom coordinates */
170 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
173 /* Calculate displacement vector */
174 dx10
= _mm_sub_pd(ix1
,jx0
);
175 dy10
= _mm_sub_pd(iy1
,jy0
);
176 dz10
= _mm_sub_pd(iz1
,jz0
);
177 dx20
= _mm_sub_pd(ix2
,jx0
);
178 dy20
= _mm_sub_pd(iy2
,jy0
);
179 dz20
= _mm_sub_pd(iz2
,jz0
);
180 dx30
= _mm_sub_pd(ix3
,jx0
);
181 dy30
= _mm_sub_pd(iy3
,jy0
);
182 dz30
= _mm_sub_pd(iz3
,jz0
);
184 /* Calculate squared distance and things based on it */
185 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
186 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
187 rsq30
= gmx_mm_calc_rsq_pd(dx30
,dy30
,dz30
);
189 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
190 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
191 rinv30
= gmx_mm_invsqrt_pd(rsq30
);
193 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
194 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
195 rinvsq30
= _mm_mul_pd(rinv30
,rinv30
);
197 /* Load parameters for j particles */
198 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
200 fjx0
= _mm_setzero_pd();
201 fjy0
= _mm_setzero_pd();
202 fjz0
= _mm_setzero_pd();
204 /**************************
205 * CALCULATE INTERACTIONS *
206 **************************/
208 /* Compute parameters for interactions between i and j atoms */
209 qq10
= _mm_mul_pd(iq1
,jq0
);
211 /* REACTION-FIELD ELECTROSTATICS */
212 velec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_add_pd(rinv10
,_mm_mul_pd(krf
,rsq10
)),crf
));
213 felec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_mul_pd(rinv10
,rinvsq10
),krf2
));
215 /* Update potential sum for this i atom from the interaction with this j atom. */
216 velecsum
= _mm_add_pd(velecsum
,velec
);
220 /* Calculate temporary vectorial force */
221 tx
= _mm_mul_pd(fscal
,dx10
);
222 ty
= _mm_mul_pd(fscal
,dy10
);
223 tz
= _mm_mul_pd(fscal
,dz10
);
225 /* Update vectorial force */
226 fix1
= _mm_add_pd(fix1
,tx
);
227 fiy1
= _mm_add_pd(fiy1
,ty
);
228 fiz1
= _mm_add_pd(fiz1
,tz
);
230 fjx0
= _mm_add_pd(fjx0
,tx
);
231 fjy0
= _mm_add_pd(fjy0
,ty
);
232 fjz0
= _mm_add_pd(fjz0
,tz
);
234 /**************************
235 * CALCULATE INTERACTIONS *
236 **************************/
238 /* Compute parameters for interactions between i and j atoms */
239 qq20
= _mm_mul_pd(iq2
,jq0
);
241 /* REACTION-FIELD ELECTROSTATICS */
242 velec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_add_pd(rinv20
,_mm_mul_pd(krf
,rsq20
)),crf
));
243 felec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_mul_pd(rinv20
,rinvsq20
),krf2
));
245 /* Update potential sum for this i atom from the interaction with this j atom. */
246 velecsum
= _mm_add_pd(velecsum
,velec
);
250 /* Calculate temporary vectorial force */
251 tx
= _mm_mul_pd(fscal
,dx20
);
252 ty
= _mm_mul_pd(fscal
,dy20
);
253 tz
= _mm_mul_pd(fscal
,dz20
);
255 /* Update vectorial force */
256 fix2
= _mm_add_pd(fix2
,tx
);
257 fiy2
= _mm_add_pd(fiy2
,ty
);
258 fiz2
= _mm_add_pd(fiz2
,tz
);
260 fjx0
= _mm_add_pd(fjx0
,tx
);
261 fjy0
= _mm_add_pd(fjy0
,ty
);
262 fjz0
= _mm_add_pd(fjz0
,tz
);
264 /**************************
265 * CALCULATE INTERACTIONS *
266 **************************/
268 /* Compute parameters for interactions between i and j atoms */
269 qq30
= _mm_mul_pd(iq3
,jq0
);
271 /* REACTION-FIELD ELECTROSTATICS */
272 velec
= _mm_mul_pd(qq30
,_mm_sub_pd(_mm_add_pd(rinv30
,_mm_mul_pd(krf
,rsq30
)),crf
));
273 felec
= _mm_mul_pd(qq30
,_mm_sub_pd(_mm_mul_pd(rinv30
,rinvsq30
),krf2
));
275 /* Update potential sum for this i atom from the interaction with this j atom. */
276 velecsum
= _mm_add_pd(velecsum
,velec
);
280 /* Calculate temporary vectorial force */
281 tx
= _mm_mul_pd(fscal
,dx30
);
282 ty
= _mm_mul_pd(fscal
,dy30
);
283 tz
= _mm_mul_pd(fscal
,dz30
);
285 /* Update vectorial force */
286 fix3
= _mm_add_pd(fix3
,tx
);
287 fiy3
= _mm_add_pd(fiy3
,ty
);
288 fiz3
= _mm_add_pd(fiz3
,tz
);
290 fjx0
= _mm_add_pd(fjx0
,tx
);
291 fjy0
= _mm_add_pd(fjy0
,ty
);
292 fjz0
= _mm_add_pd(fjz0
,tz
);
294 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
);
296 /* Inner loop uses 99 flops */
303 j_coord_offsetA
= DIM
*jnrA
;
305 /* load j atom coordinates */
306 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
309 /* Calculate displacement vector */
310 dx10
= _mm_sub_pd(ix1
,jx0
);
311 dy10
= _mm_sub_pd(iy1
,jy0
);
312 dz10
= _mm_sub_pd(iz1
,jz0
);
313 dx20
= _mm_sub_pd(ix2
,jx0
);
314 dy20
= _mm_sub_pd(iy2
,jy0
);
315 dz20
= _mm_sub_pd(iz2
,jz0
);
316 dx30
= _mm_sub_pd(ix3
,jx0
);
317 dy30
= _mm_sub_pd(iy3
,jy0
);
318 dz30
= _mm_sub_pd(iz3
,jz0
);
320 /* Calculate squared distance and things based on it */
321 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
322 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
323 rsq30
= gmx_mm_calc_rsq_pd(dx30
,dy30
,dz30
);
325 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
326 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
327 rinv30
= gmx_mm_invsqrt_pd(rsq30
);
329 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
330 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
331 rinvsq30
= _mm_mul_pd(rinv30
,rinv30
);
333 /* Load parameters for j particles */
334 jq0
= _mm_load_sd(charge
+jnrA
+0);
336 fjx0
= _mm_setzero_pd();
337 fjy0
= _mm_setzero_pd();
338 fjz0
= _mm_setzero_pd();
340 /**************************
341 * CALCULATE INTERACTIONS *
342 **************************/
344 /* Compute parameters for interactions between i and j atoms */
345 qq10
= _mm_mul_pd(iq1
,jq0
);
347 /* REACTION-FIELD ELECTROSTATICS */
348 velec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_add_pd(rinv10
,_mm_mul_pd(krf
,rsq10
)),crf
));
349 felec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_mul_pd(rinv10
,rinvsq10
),krf2
));
351 /* Update potential sum for this i atom from the interaction with this j atom. */
352 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
353 velecsum
= _mm_add_pd(velecsum
,velec
);
357 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
359 /* Calculate temporary vectorial force */
360 tx
= _mm_mul_pd(fscal
,dx10
);
361 ty
= _mm_mul_pd(fscal
,dy10
);
362 tz
= _mm_mul_pd(fscal
,dz10
);
364 /* Update vectorial force */
365 fix1
= _mm_add_pd(fix1
,tx
);
366 fiy1
= _mm_add_pd(fiy1
,ty
);
367 fiz1
= _mm_add_pd(fiz1
,tz
);
369 fjx0
= _mm_add_pd(fjx0
,tx
);
370 fjy0
= _mm_add_pd(fjy0
,ty
);
371 fjz0
= _mm_add_pd(fjz0
,tz
);
373 /**************************
374 * CALCULATE INTERACTIONS *
375 **************************/
377 /* Compute parameters for interactions between i and j atoms */
378 qq20
= _mm_mul_pd(iq2
,jq0
);
380 /* REACTION-FIELD ELECTROSTATICS */
381 velec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_add_pd(rinv20
,_mm_mul_pd(krf
,rsq20
)),crf
));
382 felec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_mul_pd(rinv20
,rinvsq20
),krf2
));
384 /* Update potential sum for this i atom from the interaction with this j atom. */
385 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
386 velecsum
= _mm_add_pd(velecsum
,velec
);
390 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
392 /* Calculate temporary vectorial force */
393 tx
= _mm_mul_pd(fscal
,dx20
);
394 ty
= _mm_mul_pd(fscal
,dy20
);
395 tz
= _mm_mul_pd(fscal
,dz20
);
397 /* Update vectorial force */
398 fix2
= _mm_add_pd(fix2
,tx
);
399 fiy2
= _mm_add_pd(fiy2
,ty
);
400 fiz2
= _mm_add_pd(fiz2
,tz
);
402 fjx0
= _mm_add_pd(fjx0
,tx
);
403 fjy0
= _mm_add_pd(fjy0
,ty
);
404 fjz0
= _mm_add_pd(fjz0
,tz
);
406 /**************************
407 * CALCULATE INTERACTIONS *
408 **************************/
410 /* Compute parameters for interactions between i and j atoms */
411 qq30
= _mm_mul_pd(iq3
,jq0
);
413 /* REACTION-FIELD ELECTROSTATICS */
414 velec
= _mm_mul_pd(qq30
,_mm_sub_pd(_mm_add_pd(rinv30
,_mm_mul_pd(krf
,rsq30
)),crf
));
415 felec
= _mm_mul_pd(qq30
,_mm_sub_pd(_mm_mul_pd(rinv30
,rinvsq30
),krf2
));
417 /* Update potential sum for this i atom from the interaction with this j atom. */
418 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
419 velecsum
= _mm_add_pd(velecsum
,velec
);
423 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
425 /* Calculate temporary vectorial force */
426 tx
= _mm_mul_pd(fscal
,dx30
);
427 ty
= _mm_mul_pd(fscal
,dy30
);
428 tz
= _mm_mul_pd(fscal
,dz30
);
430 /* Update vectorial force */
431 fix3
= _mm_add_pd(fix3
,tx
);
432 fiy3
= _mm_add_pd(fiy3
,ty
);
433 fiz3
= _mm_add_pd(fiz3
,tz
);
435 fjx0
= _mm_add_pd(fjx0
,tx
);
436 fjy0
= _mm_add_pd(fjy0
,ty
);
437 fjz0
= _mm_add_pd(fjz0
,tz
);
439 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
);
441 /* Inner loop uses 99 flops */
444 /* End of innermost loop */
446 gmx_mm_update_iforce_3atom_swizzle_pd(fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,fix3
,fiy3
,fiz3
,
447 f
+i_coord_offset
+DIM
,fshift
+i_shift_offset
);
450 /* Update potential energies */
451 gmx_mm_update_1pot_pd(velecsum
,kernel_data
->energygrp_elec
+ggid
);
453 /* Increment number of inner iterations */
454 inneriter
+= j_index_end
- j_index_start
;
456 /* Outer loop uses 19 flops */
459 /* Increment number of outer iterations */
462 /* Update outer/inner flops */
464 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_W4_VF
,outeriter
*19 + inneriter
*99);
467 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4P1_F_sse4_1_double
468 * Electrostatics interaction: ReactionField
469 * VdW interaction: None
470 * Geometry: Water4-Particle
471 * Calculate force/pot: Force
474 nb_kernel_ElecRF_VdwNone_GeomW4P1_F_sse4_1_double
475 (t_nblist
* gmx_restrict nlist
,
476 rvec
* gmx_restrict xx
,
477 rvec
* gmx_restrict ff
,
478 t_forcerec
* gmx_restrict fr
,
479 t_mdatoms
* gmx_restrict mdatoms
,
480 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
481 t_nrnb
* gmx_restrict nrnb
)
483 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
484 * just 0 for non-waters.
485 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
486 * jnr indices corresponding to data put in the four positions in the SIMD register.
488 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
489 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
491 int j_coord_offsetA
,j_coord_offsetB
;
492 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
494 real
*shiftvec
,*fshift
,*x
,*f
;
495 __m128d tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
497 __m128d ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
499 __m128d ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
501 __m128d ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
502 int vdwjidx0A
,vdwjidx0B
;
503 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
504 __m128d dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
505 __m128d dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
506 __m128d dx30
,dy30
,dz30
,rsq30
,rinv30
,rinvsq30
,r30
,qq30
,c6_30
,c12_30
;
507 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
509 __m128d dummy_mask
,cutoff_mask
;
510 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
511 __m128d one
= _mm_set1_pd(1.0);
512 __m128d two
= _mm_set1_pd(2.0);
518 jindex
= nlist
->jindex
;
520 shiftidx
= nlist
->shift
;
522 shiftvec
= fr
->shift_vec
[0];
523 fshift
= fr
->fshift
[0];
524 facel
= _mm_set1_pd(fr
->epsfac
);
525 charge
= mdatoms
->chargeA
;
526 krf
= _mm_set1_pd(fr
->ic
->k_rf
);
527 krf2
= _mm_set1_pd(fr
->ic
->k_rf
*2.0);
528 crf
= _mm_set1_pd(fr
->ic
->c_rf
);
530 /* Setup water-specific parameters */
531 inr
= nlist
->iinr
[0];
532 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
533 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
534 iq3
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+3]));
536 /* Avoid stupid compiler warnings */
544 /* Start outer loop over neighborlists */
545 for(iidx
=0; iidx
<nri
; iidx
++)
547 /* Load shift vector for this list */
548 i_shift_offset
= DIM
*shiftidx
[iidx
];
550 /* Load limits for loop over neighbors */
551 j_index_start
= jindex
[iidx
];
552 j_index_end
= jindex
[iidx
+1];
554 /* Get outer coordinate index */
556 i_coord_offset
= DIM
*inr
;
558 /* Load i particle coords and add shift vector */
559 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
+DIM
,
560 &ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
,&ix3
,&iy3
,&iz3
);
562 fix1
= _mm_setzero_pd();
563 fiy1
= _mm_setzero_pd();
564 fiz1
= _mm_setzero_pd();
565 fix2
= _mm_setzero_pd();
566 fiy2
= _mm_setzero_pd();
567 fiz2
= _mm_setzero_pd();
568 fix3
= _mm_setzero_pd();
569 fiy3
= _mm_setzero_pd();
570 fiz3
= _mm_setzero_pd();
572 /* Start inner kernel loop */
573 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
576 /* Get j neighbor index, and coordinate index */
579 j_coord_offsetA
= DIM
*jnrA
;
580 j_coord_offsetB
= DIM
*jnrB
;
582 /* load j atom coordinates */
583 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
586 /* Calculate displacement vector */
587 dx10
= _mm_sub_pd(ix1
,jx0
);
588 dy10
= _mm_sub_pd(iy1
,jy0
);
589 dz10
= _mm_sub_pd(iz1
,jz0
);
590 dx20
= _mm_sub_pd(ix2
,jx0
);
591 dy20
= _mm_sub_pd(iy2
,jy0
);
592 dz20
= _mm_sub_pd(iz2
,jz0
);
593 dx30
= _mm_sub_pd(ix3
,jx0
);
594 dy30
= _mm_sub_pd(iy3
,jy0
);
595 dz30
= _mm_sub_pd(iz3
,jz0
);
597 /* Calculate squared distance and things based on it */
598 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
599 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
600 rsq30
= gmx_mm_calc_rsq_pd(dx30
,dy30
,dz30
);
602 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
603 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
604 rinv30
= gmx_mm_invsqrt_pd(rsq30
);
606 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
607 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
608 rinvsq30
= _mm_mul_pd(rinv30
,rinv30
);
610 /* Load parameters for j particles */
611 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
613 fjx0
= _mm_setzero_pd();
614 fjy0
= _mm_setzero_pd();
615 fjz0
= _mm_setzero_pd();
617 /**************************
618 * CALCULATE INTERACTIONS *
619 **************************/
621 /* Compute parameters for interactions between i and j atoms */
622 qq10
= _mm_mul_pd(iq1
,jq0
);
624 /* REACTION-FIELD ELECTROSTATICS */
625 felec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_mul_pd(rinv10
,rinvsq10
),krf2
));
629 /* Calculate temporary vectorial force */
630 tx
= _mm_mul_pd(fscal
,dx10
);
631 ty
= _mm_mul_pd(fscal
,dy10
);
632 tz
= _mm_mul_pd(fscal
,dz10
);
634 /* Update vectorial force */
635 fix1
= _mm_add_pd(fix1
,tx
);
636 fiy1
= _mm_add_pd(fiy1
,ty
);
637 fiz1
= _mm_add_pd(fiz1
,tz
);
639 fjx0
= _mm_add_pd(fjx0
,tx
);
640 fjy0
= _mm_add_pd(fjy0
,ty
);
641 fjz0
= _mm_add_pd(fjz0
,tz
);
643 /**************************
644 * CALCULATE INTERACTIONS *
645 **************************/
647 /* Compute parameters for interactions between i and j atoms */
648 qq20
= _mm_mul_pd(iq2
,jq0
);
650 /* REACTION-FIELD ELECTROSTATICS */
651 felec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_mul_pd(rinv20
,rinvsq20
),krf2
));
655 /* Calculate temporary vectorial force */
656 tx
= _mm_mul_pd(fscal
,dx20
);
657 ty
= _mm_mul_pd(fscal
,dy20
);
658 tz
= _mm_mul_pd(fscal
,dz20
);
660 /* Update vectorial force */
661 fix2
= _mm_add_pd(fix2
,tx
);
662 fiy2
= _mm_add_pd(fiy2
,ty
);
663 fiz2
= _mm_add_pd(fiz2
,tz
);
665 fjx0
= _mm_add_pd(fjx0
,tx
);
666 fjy0
= _mm_add_pd(fjy0
,ty
);
667 fjz0
= _mm_add_pd(fjz0
,tz
);
669 /**************************
670 * CALCULATE INTERACTIONS *
671 **************************/
673 /* Compute parameters for interactions between i and j atoms */
674 qq30
= _mm_mul_pd(iq3
,jq0
);
676 /* REACTION-FIELD ELECTROSTATICS */
677 felec
= _mm_mul_pd(qq30
,_mm_sub_pd(_mm_mul_pd(rinv30
,rinvsq30
),krf2
));
681 /* Calculate temporary vectorial force */
682 tx
= _mm_mul_pd(fscal
,dx30
);
683 ty
= _mm_mul_pd(fscal
,dy30
);
684 tz
= _mm_mul_pd(fscal
,dz30
);
686 /* Update vectorial force */
687 fix3
= _mm_add_pd(fix3
,tx
);
688 fiy3
= _mm_add_pd(fiy3
,ty
);
689 fiz3
= _mm_add_pd(fiz3
,tz
);
691 fjx0
= _mm_add_pd(fjx0
,tx
);
692 fjy0
= _mm_add_pd(fjy0
,ty
);
693 fjz0
= _mm_add_pd(fjz0
,tz
);
695 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
);
697 /* Inner loop uses 84 flops */
704 j_coord_offsetA
= DIM
*jnrA
;
706 /* load j atom coordinates */
707 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
710 /* Calculate displacement vector */
711 dx10
= _mm_sub_pd(ix1
,jx0
);
712 dy10
= _mm_sub_pd(iy1
,jy0
);
713 dz10
= _mm_sub_pd(iz1
,jz0
);
714 dx20
= _mm_sub_pd(ix2
,jx0
);
715 dy20
= _mm_sub_pd(iy2
,jy0
);
716 dz20
= _mm_sub_pd(iz2
,jz0
);
717 dx30
= _mm_sub_pd(ix3
,jx0
);
718 dy30
= _mm_sub_pd(iy3
,jy0
);
719 dz30
= _mm_sub_pd(iz3
,jz0
);
721 /* Calculate squared distance and things based on it */
722 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
723 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
724 rsq30
= gmx_mm_calc_rsq_pd(dx30
,dy30
,dz30
);
726 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
727 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
728 rinv30
= gmx_mm_invsqrt_pd(rsq30
);
730 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
731 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
732 rinvsq30
= _mm_mul_pd(rinv30
,rinv30
);
734 /* Load parameters for j particles */
735 jq0
= _mm_load_sd(charge
+jnrA
+0);
737 fjx0
= _mm_setzero_pd();
738 fjy0
= _mm_setzero_pd();
739 fjz0
= _mm_setzero_pd();
741 /**************************
742 * CALCULATE INTERACTIONS *
743 **************************/
745 /* Compute parameters for interactions between i and j atoms */
746 qq10
= _mm_mul_pd(iq1
,jq0
);
748 /* REACTION-FIELD ELECTROSTATICS */
749 felec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_mul_pd(rinv10
,rinvsq10
),krf2
));
753 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
755 /* Calculate temporary vectorial force */
756 tx
= _mm_mul_pd(fscal
,dx10
);
757 ty
= _mm_mul_pd(fscal
,dy10
);
758 tz
= _mm_mul_pd(fscal
,dz10
);
760 /* Update vectorial force */
761 fix1
= _mm_add_pd(fix1
,tx
);
762 fiy1
= _mm_add_pd(fiy1
,ty
);
763 fiz1
= _mm_add_pd(fiz1
,tz
);
765 fjx0
= _mm_add_pd(fjx0
,tx
);
766 fjy0
= _mm_add_pd(fjy0
,ty
);
767 fjz0
= _mm_add_pd(fjz0
,tz
);
769 /**************************
770 * CALCULATE INTERACTIONS *
771 **************************/
773 /* Compute parameters for interactions between i and j atoms */
774 qq20
= _mm_mul_pd(iq2
,jq0
);
776 /* REACTION-FIELD ELECTROSTATICS */
777 felec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_mul_pd(rinv20
,rinvsq20
),krf2
));
781 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
783 /* Calculate temporary vectorial force */
784 tx
= _mm_mul_pd(fscal
,dx20
);
785 ty
= _mm_mul_pd(fscal
,dy20
);
786 tz
= _mm_mul_pd(fscal
,dz20
);
788 /* Update vectorial force */
789 fix2
= _mm_add_pd(fix2
,tx
);
790 fiy2
= _mm_add_pd(fiy2
,ty
);
791 fiz2
= _mm_add_pd(fiz2
,tz
);
793 fjx0
= _mm_add_pd(fjx0
,tx
);
794 fjy0
= _mm_add_pd(fjy0
,ty
);
795 fjz0
= _mm_add_pd(fjz0
,tz
);
797 /**************************
798 * CALCULATE INTERACTIONS *
799 **************************/
801 /* Compute parameters for interactions between i and j atoms */
802 qq30
= _mm_mul_pd(iq3
,jq0
);
804 /* REACTION-FIELD ELECTROSTATICS */
805 felec
= _mm_mul_pd(qq30
,_mm_sub_pd(_mm_mul_pd(rinv30
,rinvsq30
),krf2
));
809 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
811 /* Calculate temporary vectorial force */
812 tx
= _mm_mul_pd(fscal
,dx30
);
813 ty
= _mm_mul_pd(fscal
,dy30
);
814 tz
= _mm_mul_pd(fscal
,dz30
);
816 /* Update vectorial force */
817 fix3
= _mm_add_pd(fix3
,tx
);
818 fiy3
= _mm_add_pd(fiy3
,ty
);
819 fiz3
= _mm_add_pd(fiz3
,tz
);
821 fjx0
= _mm_add_pd(fjx0
,tx
);
822 fjy0
= _mm_add_pd(fjy0
,ty
);
823 fjz0
= _mm_add_pd(fjz0
,tz
);
825 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
);
827 /* Inner loop uses 84 flops */
830 /* End of innermost loop */
832 gmx_mm_update_iforce_3atom_swizzle_pd(fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,fix3
,fiy3
,fiz3
,
833 f
+i_coord_offset
+DIM
,fshift
+i_shift_offset
);
835 /* Increment number of inner iterations */
836 inneriter
+= j_index_end
- j_index_start
;
838 /* Outer loop uses 18 flops */
841 /* Increment number of outer iterations */
844 /* Update outer/inner flops */
846 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_W4_F
,outeriter
*18 + inneriter
*84);