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_VdwNone_GeomW3P1_VF_sse2_double
53 * Electrostatics interaction: ReactionField
54 * VdW interaction: None
55 * Geometry: Water3-Particle
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecRF_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
;
94 __m128d dummy_mask
,cutoff_mask
;
95 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
96 __m128d one
= _mm_set1_pd(1.0);
97 __m128d two
= _mm_set1_pd(2.0);
103 jindex
= nlist
->jindex
;
105 shiftidx
= nlist
->shift
;
107 shiftvec
= fr
->shift_vec
[0];
108 fshift
= fr
->fshift
[0];
109 facel
= _mm_set1_pd(fr
->epsfac
);
110 charge
= mdatoms
->chargeA
;
111 krf
= _mm_set1_pd(fr
->ic
->k_rf
);
112 krf2
= _mm_set1_pd(fr
->ic
->k_rf
*2.0);
113 crf
= _mm_set1_pd(fr
->ic
->c_rf
);
115 /* Setup water-specific parameters */
116 inr
= nlist
->iinr
[0];
117 iq0
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+0]));
118 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
119 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
121 /* Avoid stupid compiler warnings */
129 /* Start outer loop over neighborlists */
130 for(iidx
=0; iidx
<nri
; iidx
++)
132 /* Load shift vector for this list */
133 i_shift_offset
= DIM
*shiftidx
[iidx
];
135 /* Load limits for loop over neighbors */
136 j_index_start
= jindex
[iidx
];
137 j_index_end
= jindex
[iidx
+1];
139 /* Get outer coordinate index */
141 i_coord_offset
= DIM
*inr
;
143 /* Load i particle coords and add shift vector */
144 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
145 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
);
147 fix0
= _mm_setzero_pd();
148 fiy0
= _mm_setzero_pd();
149 fiz0
= _mm_setzero_pd();
150 fix1
= _mm_setzero_pd();
151 fiy1
= _mm_setzero_pd();
152 fiz1
= _mm_setzero_pd();
153 fix2
= _mm_setzero_pd();
154 fiy2
= _mm_setzero_pd();
155 fiz2
= _mm_setzero_pd();
157 /* Reset potential sums */
158 velecsum
= _mm_setzero_pd();
160 /* Start inner kernel loop */
161 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
164 /* Get j neighbor index, and coordinate index */
167 j_coord_offsetA
= DIM
*jnrA
;
168 j_coord_offsetB
= DIM
*jnrB
;
170 /* load j atom coordinates */
171 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
174 /* Calculate displacement vector */
175 dx00
= _mm_sub_pd(ix0
,jx0
);
176 dy00
= _mm_sub_pd(iy0
,jy0
);
177 dz00
= _mm_sub_pd(iz0
,jz0
);
178 dx10
= _mm_sub_pd(ix1
,jx0
);
179 dy10
= _mm_sub_pd(iy1
,jy0
);
180 dz10
= _mm_sub_pd(iz1
,jz0
);
181 dx20
= _mm_sub_pd(ix2
,jx0
);
182 dy20
= _mm_sub_pd(iy2
,jy0
);
183 dz20
= _mm_sub_pd(iz2
,jz0
);
185 /* Calculate squared distance and things based on it */
186 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
187 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
188 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
190 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
191 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
192 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
194 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
195 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
196 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
198 /* Load parameters for j particles */
199 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
201 fjx0
= _mm_setzero_pd();
202 fjy0
= _mm_setzero_pd();
203 fjz0
= _mm_setzero_pd();
205 /**************************
206 * CALCULATE INTERACTIONS *
207 **************************/
209 /* Compute parameters for interactions between i and j atoms */
210 qq00
= _mm_mul_pd(iq0
,jq0
);
212 /* REACTION-FIELD ELECTROSTATICS */
213 velec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_add_pd(rinv00
,_mm_mul_pd(krf
,rsq00
)),crf
));
214 felec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_mul_pd(rinv00
,rinvsq00
),krf2
));
216 /* Update potential sum for this i atom from the interaction with this j atom. */
217 velecsum
= _mm_add_pd(velecsum
,velec
);
221 /* Calculate temporary vectorial force */
222 tx
= _mm_mul_pd(fscal
,dx00
);
223 ty
= _mm_mul_pd(fscal
,dy00
);
224 tz
= _mm_mul_pd(fscal
,dz00
);
226 /* Update vectorial force */
227 fix0
= _mm_add_pd(fix0
,tx
);
228 fiy0
= _mm_add_pd(fiy0
,ty
);
229 fiz0
= _mm_add_pd(fiz0
,tz
);
231 fjx0
= _mm_add_pd(fjx0
,tx
);
232 fjy0
= _mm_add_pd(fjy0
,ty
);
233 fjz0
= _mm_add_pd(fjz0
,tz
);
235 /**************************
236 * CALCULATE INTERACTIONS *
237 **************************/
239 /* Compute parameters for interactions between i and j atoms */
240 qq10
= _mm_mul_pd(iq1
,jq0
);
242 /* REACTION-FIELD ELECTROSTATICS */
243 velec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_add_pd(rinv10
,_mm_mul_pd(krf
,rsq10
)),crf
));
244 felec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_mul_pd(rinv10
,rinvsq10
),krf2
));
246 /* Update potential sum for this i atom from the interaction with this j atom. */
247 velecsum
= _mm_add_pd(velecsum
,velec
);
251 /* Calculate temporary vectorial force */
252 tx
= _mm_mul_pd(fscal
,dx10
);
253 ty
= _mm_mul_pd(fscal
,dy10
);
254 tz
= _mm_mul_pd(fscal
,dz10
);
256 /* Update vectorial force */
257 fix1
= _mm_add_pd(fix1
,tx
);
258 fiy1
= _mm_add_pd(fiy1
,ty
);
259 fiz1
= _mm_add_pd(fiz1
,tz
);
261 fjx0
= _mm_add_pd(fjx0
,tx
);
262 fjy0
= _mm_add_pd(fjy0
,ty
);
263 fjz0
= _mm_add_pd(fjz0
,tz
);
265 /**************************
266 * CALCULATE INTERACTIONS *
267 **************************/
269 /* Compute parameters for interactions between i and j atoms */
270 qq20
= _mm_mul_pd(iq2
,jq0
);
272 /* REACTION-FIELD ELECTROSTATICS */
273 velec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_add_pd(rinv20
,_mm_mul_pd(krf
,rsq20
)),crf
));
274 felec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_mul_pd(rinv20
,rinvsq20
),krf2
));
276 /* Update potential sum for this i atom from the interaction with this j atom. */
277 velecsum
= _mm_add_pd(velecsum
,velec
);
281 /* Calculate temporary vectorial force */
282 tx
= _mm_mul_pd(fscal
,dx20
);
283 ty
= _mm_mul_pd(fscal
,dy20
);
284 tz
= _mm_mul_pd(fscal
,dz20
);
286 /* Update vectorial force */
287 fix2
= _mm_add_pd(fix2
,tx
);
288 fiy2
= _mm_add_pd(fiy2
,ty
);
289 fiz2
= _mm_add_pd(fiz2
,tz
);
291 fjx0
= _mm_add_pd(fjx0
,tx
);
292 fjy0
= _mm_add_pd(fjy0
,ty
);
293 fjz0
= _mm_add_pd(fjz0
,tz
);
295 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
);
297 /* Inner loop uses 99 flops */
304 j_coord_offsetA
= DIM
*jnrA
;
306 /* load j atom coordinates */
307 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
310 /* Calculate displacement vector */
311 dx00
= _mm_sub_pd(ix0
,jx0
);
312 dy00
= _mm_sub_pd(iy0
,jy0
);
313 dz00
= _mm_sub_pd(iz0
,jz0
);
314 dx10
= _mm_sub_pd(ix1
,jx0
);
315 dy10
= _mm_sub_pd(iy1
,jy0
);
316 dz10
= _mm_sub_pd(iz1
,jz0
);
317 dx20
= _mm_sub_pd(ix2
,jx0
);
318 dy20
= _mm_sub_pd(iy2
,jy0
);
319 dz20
= _mm_sub_pd(iz2
,jz0
);
321 /* Calculate squared distance and things based on it */
322 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
323 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
324 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
326 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
327 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
328 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
330 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
331 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
332 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
334 /* Load parameters for j particles */
335 jq0
= _mm_load_sd(charge
+jnrA
+0);
337 fjx0
= _mm_setzero_pd();
338 fjy0
= _mm_setzero_pd();
339 fjz0
= _mm_setzero_pd();
341 /**************************
342 * CALCULATE INTERACTIONS *
343 **************************/
345 /* Compute parameters for interactions between i and j atoms */
346 qq00
= _mm_mul_pd(iq0
,jq0
);
348 /* REACTION-FIELD ELECTROSTATICS */
349 velec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_add_pd(rinv00
,_mm_mul_pd(krf
,rsq00
)),crf
));
350 felec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_mul_pd(rinv00
,rinvsq00
),krf2
));
352 /* Update potential sum for this i atom from the interaction with this j atom. */
353 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
354 velecsum
= _mm_add_pd(velecsum
,velec
);
358 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
360 /* Calculate temporary vectorial force */
361 tx
= _mm_mul_pd(fscal
,dx00
);
362 ty
= _mm_mul_pd(fscal
,dy00
);
363 tz
= _mm_mul_pd(fscal
,dz00
);
365 /* Update vectorial force */
366 fix0
= _mm_add_pd(fix0
,tx
);
367 fiy0
= _mm_add_pd(fiy0
,ty
);
368 fiz0
= _mm_add_pd(fiz0
,tz
);
370 fjx0
= _mm_add_pd(fjx0
,tx
);
371 fjy0
= _mm_add_pd(fjy0
,ty
);
372 fjz0
= _mm_add_pd(fjz0
,tz
);
374 /**************************
375 * CALCULATE INTERACTIONS *
376 **************************/
378 /* Compute parameters for interactions between i and j atoms */
379 qq10
= _mm_mul_pd(iq1
,jq0
);
381 /* REACTION-FIELD ELECTROSTATICS */
382 velec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_add_pd(rinv10
,_mm_mul_pd(krf
,rsq10
)),crf
));
383 felec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_mul_pd(rinv10
,rinvsq10
),krf2
));
385 /* Update potential sum for this i atom from the interaction with this j atom. */
386 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
387 velecsum
= _mm_add_pd(velecsum
,velec
);
391 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
393 /* Calculate temporary vectorial force */
394 tx
= _mm_mul_pd(fscal
,dx10
);
395 ty
= _mm_mul_pd(fscal
,dy10
);
396 tz
= _mm_mul_pd(fscal
,dz10
);
398 /* Update vectorial force */
399 fix1
= _mm_add_pd(fix1
,tx
);
400 fiy1
= _mm_add_pd(fiy1
,ty
);
401 fiz1
= _mm_add_pd(fiz1
,tz
);
403 fjx0
= _mm_add_pd(fjx0
,tx
);
404 fjy0
= _mm_add_pd(fjy0
,ty
);
405 fjz0
= _mm_add_pd(fjz0
,tz
);
407 /**************************
408 * CALCULATE INTERACTIONS *
409 **************************/
411 /* Compute parameters for interactions between i and j atoms */
412 qq20
= _mm_mul_pd(iq2
,jq0
);
414 /* REACTION-FIELD ELECTROSTATICS */
415 velec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_add_pd(rinv20
,_mm_mul_pd(krf
,rsq20
)),crf
));
416 felec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_mul_pd(rinv20
,rinvsq20
),krf2
));
418 /* Update potential sum for this i atom from the interaction with this j atom. */
419 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
420 velecsum
= _mm_add_pd(velecsum
,velec
);
424 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
426 /* Calculate temporary vectorial force */
427 tx
= _mm_mul_pd(fscal
,dx20
);
428 ty
= _mm_mul_pd(fscal
,dy20
);
429 tz
= _mm_mul_pd(fscal
,dz20
);
431 /* Update vectorial force */
432 fix2
= _mm_add_pd(fix2
,tx
);
433 fiy2
= _mm_add_pd(fiy2
,ty
);
434 fiz2
= _mm_add_pd(fiz2
,tz
);
436 fjx0
= _mm_add_pd(fjx0
,tx
);
437 fjy0
= _mm_add_pd(fjy0
,ty
);
438 fjz0
= _mm_add_pd(fjz0
,tz
);
440 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
);
442 /* Inner loop uses 99 flops */
445 /* End of innermost loop */
447 gmx_mm_update_iforce_3atom_swizzle_pd(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,
448 f
+i_coord_offset
,fshift
+i_shift_offset
);
451 /* Update potential energies */
452 gmx_mm_update_1pot_pd(velecsum
,kernel_data
->energygrp_elec
+ggid
);
454 /* Increment number of inner iterations */
455 inneriter
+= j_index_end
- j_index_start
;
457 /* Outer loop uses 19 flops */
460 /* Increment number of outer iterations */
463 /* Update outer/inner flops */
465 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_W3_VF
,outeriter
*19 + inneriter
*99);
468 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW3P1_F_sse2_double
469 * Electrostatics interaction: ReactionField
470 * VdW interaction: None
471 * Geometry: Water3-Particle
472 * Calculate force/pot: Force
475 nb_kernel_ElecRF_VdwNone_GeomW3P1_F_sse2_double
476 (t_nblist
* gmx_restrict nlist
,
477 rvec
* gmx_restrict xx
,
478 rvec
* gmx_restrict ff
,
479 t_forcerec
* gmx_restrict fr
,
480 t_mdatoms
* gmx_restrict mdatoms
,
481 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
482 t_nrnb
* gmx_restrict nrnb
)
484 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
485 * just 0 for non-waters.
486 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
487 * jnr indices corresponding to data put in the four positions in the SIMD register.
489 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
490 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
492 int j_coord_offsetA
,j_coord_offsetB
;
493 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
495 real
*shiftvec
,*fshift
,*x
,*f
;
496 __m128d tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
498 __m128d ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
500 __m128d ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
502 __m128d ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
503 int vdwjidx0A
,vdwjidx0B
;
504 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
505 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
506 __m128d dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
;
507 __m128d dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
;
508 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
510 __m128d dummy_mask
,cutoff_mask
;
511 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
512 __m128d one
= _mm_set1_pd(1.0);
513 __m128d two
= _mm_set1_pd(2.0);
519 jindex
= nlist
->jindex
;
521 shiftidx
= nlist
->shift
;
523 shiftvec
= fr
->shift_vec
[0];
524 fshift
= fr
->fshift
[0];
525 facel
= _mm_set1_pd(fr
->epsfac
);
526 charge
= mdatoms
->chargeA
;
527 krf
= _mm_set1_pd(fr
->ic
->k_rf
);
528 krf2
= _mm_set1_pd(fr
->ic
->k_rf
*2.0);
529 crf
= _mm_set1_pd(fr
->ic
->c_rf
);
531 /* Setup water-specific parameters */
532 inr
= nlist
->iinr
[0];
533 iq0
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+0]));
534 iq1
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+1]));
535 iq2
= _mm_mul_pd(facel
,_mm_set1_pd(charge
[inr
+2]));
537 /* Avoid stupid compiler warnings */
545 /* Start outer loop over neighborlists */
546 for(iidx
=0; iidx
<nri
; iidx
++)
548 /* Load shift vector for this list */
549 i_shift_offset
= DIM
*shiftidx
[iidx
];
551 /* Load limits for loop over neighbors */
552 j_index_start
= jindex
[iidx
];
553 j_index_end
= jindex
[iidx
+1];
555 /* Get outer coordinate index */
557 i_coord_offset
= DIM
*inr
;
559 /* Load i particle coords and add shift vector */
560 gmx_mm_load_shift_and_3rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,
561 &ix0
,&iy0
,&iz0
,&ix1
,&iy1
,&iz1
,&ix2
,&iy2
,&iz2
);
563 fix0
= _mm_setzero_pd();
564 fiy0
= _mm_setzero_pd();
565 fiz0
= _mm_setzero_pd();
566 fix1
= _mm_setzero_pd();
567 fiy1
= _mm_setzero_pd();
568 fiz1
= _mm_setzero_pd();
569 fix2
= _mm_setzero_pd();
570 fiy2
= _mm_setzero_pd();
571 fiz2
= _mm_setzero_pd();
573 /* Start inner kernel loop */
574 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
577 /* Get j neighbor index, and coordinate index */
580 j_coord_offsetA
= DIM
*jnrA
;
581 j_coord_offsetB
= DIM
*jnrB
;
583 /* load j atom coordinates */
584 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
587 /* Calculate displacement vector */
588 dx00
= _mm_sub_pd(ix0
,jx0
);
589 dy00
= _mm_sub_pd(iy0
,jy0
);
590 dz00
= _mm_sub_pd(iz0
,jz0
);
591 dx10
= _mm_sub_pd(ix1
,jx0
);
592 dy10
= _mm_sub_pd(iy1
,jy0
);
593 dz10
= _mm_sub_pd(iz1
,jz0
);
594 dx20
= _mm_sub_pd(ix2
,jx0
);
595 dy20
= _mm_sub_pd(iy2
,jy0
);
596 dz20
= _mm_sub_pd(iz2
,jz0
);
598 /* Calculate squared distance and things based on it */
599 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
600 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
601 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
603 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
604 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
605 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
607 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
608 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
609 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
611 /* Load parameters for j particles */
612 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
614 fjx0
= _mm_setzero_pd();
615 fjy0
= _mm_setzero_pd();
616 fjz0
= _mm_setzero_pd();
618 /**************************
619 * CALCULATE INTERACTIONS *
620 **************************/
622 /* Compute parameters for interactions between i and j atoms */
623 qq00
= _mm_mul_pd(iq0
,jq0
);
625 /* REACTION-FIELD ELECTROSTATICS */
626 felec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_mul_pd(rinv00
,rinvsq00
),krf2
));
630 /* Calculate temporary vectorial force */
631 tx
= _mm_mul_pd(fscal
,dx00
);
632 ty
= _mm_mul_pd(fscal
,dy00
);
633 tz
= _mm_mul_pd(fscal
,dz00
);
635 /* Update vectorial force */
636 fix0
= _mm_add_pd(fix0
,tx
);
637 fiy0
= _mm_add_pd(fiy0
,ty
);
638 fiz0
= _mm_add_pd(fiz0
,tz
);
640 fjx0
= _mm_add_pd(fjx0
,tx
);
641 fjy0
= _mm_add_pd(fjy0
,ty
);
642 fjz0
= _mm_add_pd(fjz0
,tz
);
644 /**************************
645 * CALCULATE INTERACTIONS *
646 **************************/
648 /* Compute parameters for interactions between i and j atoms */
649 qq10
= _mm_mul_pd(iq1
,jq0
);
651 /* REACTION-FIELD ELECTROSTATICS */
652 felec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_mul_pd(rinv10
,rinvsq10
),krf2
));
656 /* Calculate temporary vectorial force */
657 tx
= _mm_mul_pd(fscal
,dx10
);
658 ty
= _mm_mul_pd(fscal
,dy10
);
659 tz
= _mm_mul_pd(fscal
,dz10
);
661 /* Update vectorial force */
662 fix1
= _mm_add_pd(fix1
,tx
);
663 fiy1
= _mm_add_pd(fiy1
,ty
);
664 fiz1
= _mm_add_pd(fiz1
,tz
);
666 fjx0
= _mm_add_pd(fjx0
,tx
);
667 fjy0
= _mm_add_pd(fjy0
,ty
);
668 fjz0
= _mm_add_pd(fjz0
,tz
);
670 /**************************
671 * CALCULATE INTERACTIONS *
672 **************************/
674 /* Compute parameters for interactions between i and j atoms */
675 qq20
= _mm_mul_pd(iq2
,jq0
);
677 /* REACTION-FIELD ELECTROSTATICS */
678 felec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_mul_pd(rinv20
,rinvsq20
),krf2
));
682 /* Calculate temporary vectorial force */
683 tx
= _mm_mul_pd(fscal
,dx20
);
684 ty
= _mm_mul_pd(fscal
,dy20
);
685 tz
= _mm_mul_pd(fscal
,dz20
);
687 /* Update vectorial force */
688 fix2
= _mm_add_pd(fix2
,tx
);
689 fiy2
= _mm_add_pd(fiy2
,ty
);
690 fiz2
= _mm_add_pd(fiz2
,tz
);
692 fjx0
= _mm_add_pd(fjx0
,tx
);
693 fjy0
= _mm_add_pd(fjy0
,ty
);
694 fjz0
= _mm_add_pd(fjz0
,tz
);
696 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,fjx0
,fjy0
,fjz0
);
698 /* Inner loop uses 84 flops */
705 j_coord_offsetA
= DIM
*jnrA
;
707 /* load j atom coordinates */
708 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
711 /* Calculate displacement vector */
712 dx00
= _mm_sub_pd(ix0
,jx0
);
713 dy00
= _mm_sub_pd(iy0
,jy0
);
714 dz00
= _mm_sub_pd(iz0
,jz0
);
715 dx10
= _mm_sub_pd(ix1
,jx0
);
716 dy10
= _mm_sub_pd(iy1
,jy0
);
717 dz10
= _mm_sub_pd(iz1
,jz0
);
718 dx20
= _mm_sub_pd(ix2
,jx0
);
719 dy20
= _mm_sub_pd(iy2
,jy0
);
720 dz20
= _mm_sub_pd(iz2
,jz0
);
722 /* Calculate squared distance and things based on it */
723 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
724 rsq10
= gmx_mm_calc_rsq_pd(dx10
,dy10
,dz10
);
725 rsq20
= gmx_mm_calc_rsq_pd(dx20
,dy20
,dz20
);
727 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
728 rinv10
= gmx_mm_invsqrt_pd(rsq10
);
729 rinv20
= gmx_mm_invsqrt_pd(rsq20
);
731 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
732 rinvsq10
= _mm_mul_pd(rinv10
,rinv10
);
733 rinvsq20
= _mm_mul_pd(rinv20
,rinv20
);
735 /* Load parameters for j particles */
736 jq0
= _mm_load_sd(charge
+jnrA
+0);
738 fjx0
= _mm_setzero_pd();
739 fjy0
= _mm_setzero_pd();
740 fjz0
= _mm_setzero_pd();
742 /**************************
743 * CALCULATE INTERACTIONS *
744 **************************/
746 /* Compute parameters for interactions between i and j atoms */
747 qq00
= _mm_mul_pd(iq0
,jq0
);
749 /* REACTION-FIELD ELECTROSTATICS */
750 felec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_mul_pd(rinv00
,rinvsq00
),krf2
));
754 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
756 /* Calculate temporary vectorial force */
757 tx
= _mm_mul_pd(fscal
,dx00
);
758 ty
= _mm_mul_pd(fscal
,dy00
);
759 tz
= _mm_mul_pd(fscal
,dz00
);
761 /* Update vectorial force */
762 fix0
= _mm_add_pd(fix0
,tx
);
763 fiy0
= _mm_add_pd(fiy0
,ty
);
764 fiz0
= _mm_add_pd(fiz0
,tz
);
766 fjx0
= _mm_add_pd(fjx0
,tx
);
767 fjy0
= _mm_add_pd(fjy0
,ty
);
768 fjz0
= _mm_add_pd(fjz0
,tz
);
770 /**************************
771 * CALCULATE INTERACTIONS *
772 **************************/
774 /* Compute parameters for interactions between i and j atoms */
775 qq10
= _mm_mul_pd(iq1
,jq0
);
777 /* REACTION-FIELD ELECTROSTATICS */
778 felec
= _mm_mul_pd(qq10
,_mm_sub_pd(_mm_mul_pd(rinv10
,rinvsq10
),krf2
));
782 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
784 /* Calculate temporary vectorial force */
785 tx
= _mm_mul_pd(fscal
,dx10
);
786 ty
= _mm_mul_pd(fscal
,dy10
);
787 tz
= _mm_mul_pd(fscal
,dz10
);
789 /* Update vectorial force */
790 fix1
= _mm_add_pd(fix1
,tx
);
791 fiy1
= _mm_add_pd(fiy1
,ty
);
792 fiz1
= _mm_add_pd(fiz1
,tz
);
794 fjx0
= _mm_add_pd(fjx0
,tx
);
795 fjy0
= _mm_add_pd(fjy0
,ty
);
796 fjz0
= _mm_add_pd(fjz0
,tz
);
798 /**************************
799 * CALCULATE INTERACTIONS *
800 **************************/
802 /* Compute parameters for interactions between i and j atoms */
803 qq20
= _mm_mul_pd(iq2
,jq0
);
805 /* REACTION-FIELD ELECTROSTATICS */
806 felec
= _mm_mul_pd(qq20
,_mm_sub_pd(_mm_mul_pd(rinv20
,rinvsq20
),krf2
));
810 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
812 /* Calculate temporary vectorial force */
813 tx
= _mm_mul_pd(fscal
,dx20
);
814 ty
= _mm_mul_pd(fscal
,dy20
);
815 tz
= _mm_mul_pd(fscal
,dz20
);
817 /* Update vectorial force */
818 fix2
= _mm_add_pd(fix2
,tx
);
819 fiy2
= _mm_add_pd(fiy2
,ty
);
820 fiz2
= _mm_add_pd(fiz2
,tz
);
822 fjx0
= _mm_add_pd(fjx0
,tx
);
823 fjy0
= _mm_add_pd(fjy0
,ty
);
824 fjz0
= _mm_add_pd(fjz0
,tz
);
826 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,fjx0
,fjy0
,fjz0
);
828 /* Inner loop uses 84 flops */
831 /* End of innermost loop */
833 gmx_mm_update_iforce_3atom_swizzle_pd(fix0
,fiy0
,fiz0
,fix1
,fiy1
,fiz1
,fix2
,fiy2
,fiz2
,
834 f
+i_coord_offset
,fshift
+i_shift_offset
);
836 /* Increment number of inner iterations */
837 inneriter
+= j_index_end
- j_index_start
;
839 /* Outer loop uses 18 flops */
842 /* Increment number of outer iterations */
845 /* Update outer/inner flops */
847 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_W3_F
,outeriter
*18 + inneriter
*84);