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 sse4_1_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_sse4_1_double.h"
49 #include "kernelutil_x86_sse4_1_double.h"
52 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_VF_sse4_1_double
53 * Electrostatics interaction: ReactionField
54 * VdW interaction: LennardJones
55 * Geometry: Particle-Particle
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_VF_sse4_1_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
;
83 int vdwjidx0A
,vdwjidx0B
;
84 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
85 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
86 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
89 __m128d rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
92 __m128d one_sixth
= _mm_set1_pd(1.0/6.0);
93 __m128d one_twelfth
= _mm_set1_pd(1.0/12.0);
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
);
114 nvdwtype
= fr
->ntype
;
116 vdwtype
= mdatoms
->typeA
;
118 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
119 rcutoff_scalar
= fr
->rcoulomb
;
120 rcutoff
= _mm_set1_pd(rcutoff_scalar
);
121 rcutoff2
= _mm_mul_pd(rcutoff
,rcutoff
);
123 sh_vdw_invrcut6
= _mm_set1_pd(fr
->ic
->sh_invrc6
);
124 rvdw
= _mm_set1_pd(fr
->rvdw
);
126 /* Avoid stupid compiler warnings */
134 /* Start outer loop over neighborlists */
135 for(iidx
=0; iidx
<nri
; iidx
++)
137 /* Load shift vector for this list */
138 i_shift_offset
= DIM
*shiftidx
[iidx
];
140 /* Load limits for loop over neighbors */
141 j_index_start
= jindex
[iidx
];
142 j_index_end
= jindex
[iidx
+1];
144 /* Get outer coordinate index */
146 i_coord_offset
= DIM
*inr
;
148 /* Load i particle coords and add shift vector */
149 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,&ix0
,&iy0
,&iz0
);
151 fix0
= _mm_setzero_pd();
152 fiy0
= _mm_setzero_pd();
153 fiz0
= _mm_setzero_pd();
155 /* Load parameters for i particles */
156 iq0
= _mm_mul_pd(facel
,_mm_load1_pd(charge
+inr
+0));
157 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
159 /* Reset potential sums */
160 velecsum
= _mm_setzero_pd();
161 vvdwsum
= _mm_setzero_pd();
163 /* Start inner kernel loop */
164 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
167 /* Get j neighbor index, and coordinate index */
170 j_coord_offsetA
= DIM
*jnrA
;
171 j_coord_offsetB
= DIM
*jnrB
;
173 /* load j atom coordinates */
174 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
177 /* Calculate displacement vector */
178 dx00
= _mm_sub_pd(ix0
,jx0
);
179 dy00
= _mm_sub_pd(iy0
,jy0
);
180 dz00
= _mm_sub_pd(iz0
,jz0
);
182 /* Calculate squared distance and things based on it */
183 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
185 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
187 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
189 /* Load parameters for j particles */
190 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
191 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
192 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
194 /**************************
195 * CALCULATE INTERACTIONS *
196 **************************/
198 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
201 /* Compute parameters for interactions between i and j atoms */
202 qq00
= _mm_mul_pd(iq0
,jq0
);
203 gmx_mm_load_2pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,
204 vdwparam
+vdwioffset0
+vdwjidx0B
,&c6_00
,&c12_00
);
206 /* REACTION-FIELD ELECTROSTATICS */
207 velec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_add_pd(rinv00
,_mm_mul_pd(krf
,rsq00
)),crf
));
208 felec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_mul_pd(rinv00
,rinvsq00
),krf2
));
210 /* LENNARD-JONES DISPERSION/REPULSION */
212 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
213 vvdw6
= _mm_mul_pd(c6_00
,rinvsix
);
214 vvdw12
= _mm_mul_pd(c12_00
,_mm_mul_pd(rinvsix
,rinvsix
));
215 vvdw
= _mm_sub_pd(_mm_mul_pd( _mm_sub_pd(vvdw12
, _mm_mul_pd(c12_00
,_mm_mul_pd(sh_vdw_invrcut6
,sh_vdw_invrcut6
))), one_twelfth
) ,
216 _mm_mul_pd( _mm_sub_pd(vvdw6
,_mm_mul_pd(c6_00
,sh_vdw_invrcut6
)),one_sixth
));
217 fvdw
= _mm_mul_pd(_mm_sub_pd(vvdw12
,vvdw6
),rinvsq00
);
219 cutoff_mask
= _mm_cmplt_pd(rsq00
,rcutoff2
);
221 /* Update potential sum for this i atom from the interaction with this j atom. */
222 velec
= _mm_and_pd(velec
,cutoff_mask
);
223 velecsum
= _mm_add_pd(velecsum
,velec
);
224 vvdw
= _mm_and_pd(vvdw
,cutoff_mask
);
225 vvdwsum
= _mm_add_pd(vvdwsum
,vvdw
);
227 fscal
= _mm_add_pd(felec
,fvdw
);
229 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
231 /* Calculate temporary vectorial force */
232 tx
= _mm_mul_pd(fscal
,dx00
);
233 ty
= _mm_mul_pd(fscal
,dy00
);
234 tz
= _mm_mul_pd(fscal
,dz00
);
236 /* Update vectorial force */
237 fix0
= _mm_add_pd(fix0
,tx
);
238 fiy0
= _mm_add_pd(fiy0
,ty
);
239 fiz0
= _mm_add_pd(fiz0
,tz
);
241 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,tx
,ty
,tz
);
245 /* Inner loop uses 54 flops */
252 j_coord_offsetA
= DIM
*jnrA
;
254 /* load j atom coordinates */
255 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
258 /* Calculate displacement vector */
259 dx00
= _mm_sub_pd(ix0
,jx0
);
260 dy00
= _mm_sub_pd(iy0
,jy0
);
261 dz00
= _mm_sub_pd(iz0
,jz0
);
263 /* Calculate squared distance and things based on it */
264 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
266 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
268 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
270 /* Load parameters for j particles */
271 jq0
= _mm_load_sd(charge
+jnrA
+0);
272 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
274 /**************************
275 * CALCULATE INTERACTIONS *
276 **************************/
278 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
281 /* Compute parameters for interactions between i and j atoms */
282 qq00
= _mm_mul_pd(iq0
,jq0
);
283 gmx_mm_load_1pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,&c6_00
,&c12_00
);
285 /* REACTION-FIELD ELECTROSTATICS */
286 velec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_add_pd(rinv00
,_mm_mul_pd(krf
,rsq00
)),crf
));
287 felec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_mul_pd(rinv00
,rinvsq00
),krf2
));
289 /* LENNARD-JONES DISPERSION/REPULSION */
291 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
292 vvdw6
= _mm_mul_pd(c6_00
,rinvsix
);
293 vvdw12
= _mm_mul_pd(c12_00
,_mm_mul_pd(rinvsix
,rinvsix
));
294 vvdw
= _mm_sub_pd(_mm_mul_pd( _mm_sub_pd(vvdw12
, _mm_mul_pd(c12_00
,_mm_mul_pd(sh_vdw_invrcut6
,sh_vdw_invrcut6
))), one_twelfth
) ,
295 _mm_mul_pd( _mm_sub_pd(vvdw6
,_mm_mul_pd(c6_00
,sh_vdw_invrcut6
)),one_sixth
));
296 fvdw
= _mm_mul_pd(_mm_sub_pd(vvdw12
,vvdw6
),rinvsq00
);
298 cutoff_mask
= _mm_cmplt_pd(rsq00
,rcutoff2
);
300 /* Update potential sum for this i atom from the interaction with this j atom. */
301 velec
= _mm_and_pd(velec
,cutoff_mask
);
302 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
303 velecsum
= _mm_add_pd(velecsum
,velec
);
304 vvdw
= _mm_and_pd(vvdw
,cutoff_mask
);
305 vvdw
= _mm_unpacklo_pd(vvdw
,_mm_setzero_pd());
306 vvdwsum
= _mm_add_pd(vvdwsum
,vvdw
);
308 fscal
= _mm_add_pd(felec
,fvdw
);
310 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
312 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
314 /* Calculate temporary vectorial force */
315 tx
= _mm_mul_pd(fscal
,dx00
);
316 ty
= _mm_mul_pd(fscal
,dy00
);
317 tz
= _mm_mul_pd(fscal
,dz00
);
319 /* Update vectorial force */
320 fix0
= _mm_add_pd(fix0
,tx
);
321 fiy0
= _mm_add_pd(fiy0
,ty
);
322 fiz0
= _mm_add_pd(fiz0
,tz
);
324 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,tx
,ty
,tz
);
328 /* Inner loop uses 54 flops */
331 /* End of innermost loop */
333 gmx_mm_update_iforce_1atom_swizzle_pd(fix0
,fiy0
,fiz0
,
334 f
+i_coord_offset
,fshift
+i_shift_offset
);
337 /* Update potential energies */
338 gmx_mm_update_1pot_pd(velecsum
,kernel_data
->energygrp_elec
+ggid
);
339 gmx_mm_update_1pot_pd(vvdwsum
,kernel_data
->energygrp_vdw
+ggid
);
341 /* Increment number of inner iterations */
342 inneriter
+= j_index_end
- j_index_start
;
344 /* Outer loop uses 9 flops */
347 /* Increment number of outer iterations */
350 /* Update outer/inner flops */
352 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_VF
,outeriter
*9 + inneriter
*54);
355 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_F_sse4_1_double
356 * Electrostatics interaction: ReactionField
357 * VdW interaction: LennardJones
358 * Geometry: Particle-Particle
359 * Calculate force/pot: Force
362 nb_kernel_ElecRFCut_VdwLJSh_GeomP1P1_F_sse4_1_double
363 (t_nblist
* gmx_restrict nlist
,
364 rvec
* gmx_restrict xx
,
365 rvec
* gmx_restrict ff
,
366 t_forcerec
* gmx_restrict fr
,
367 t_mdatoms
* gmx_restrict mdatoms
,
368 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
369 t_nrnb
* gmx_restrict nrnb
)
371 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
372 * just 0 for non-waters.
373 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
374 * jnr indices corresponding to data put in the four positions in the SIMD register.
376 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
377 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
379 int j_coord_offsetA
,j_coord_offsetB
;
380 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
382 real
*shiftvec
,*fshift
,*x
,*f
;
383 __m128d tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
385 __m128d ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
386 int vdwjidx0A
,vdwjidx0B
;
387 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
388 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
389 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
392 __m128d rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,sh_vdw_invrcut6
;
395 __m128d one_sixth
= _mm_set1_pd(1.0/6.0);
396 __m128d one_twelfth
= _mm_set1_pd(1.0/12.0);
397 __m128d dummy_mask
,cutoff_mask
;
398 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
399 __m128d one
= _mm_set1_pd(1.0);
400 __m128d two
= _mm_set1_pd(2.0);
406 jindex
= nlist
->jindex
;
408 shiftidx
= nlist
->shift
;
410 shiftvec
= fr
->shift_vec
[0];
411 fshift
= fr
->fshift
[0];
412 facel
= _mm_set1_pd(fr
->epsfac
);
413 charge
= mdatoms
->chargeA
;
414 krf
= _mm_set1_pd(fr
->ic
->k_rf
);
415 krf2
= _mm_set1_pd(fr
->ic
->k_rf
*2.0);
416 crf
= _mm_set1_pd(fr
->ic
->c_rf
);
417 nvdwtype
= fr
->ntype
;
419 vdwtype
= mdatoms
->typeA
;
421 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
422 rcutoff_scalar
= fr
->rcoulomb
;
423 rcutoff
= _mm_set1_pd(rcutoff_scalar
);
424 rcutoff2
= _mm_mul_pd(rcutoff
,rcutoff
);
426 sh_vdw_invrcut6
= _mm_set1_pd(fr
->ic
->sh_invrc6
);
427 rvdw
= _mm_set1_pd(fr
->rvdw
);
429 /* Avoid stupid compiler warnings */
437 /* Start outer loop over neighborlists */
438 for(iidx
=0; iidx
<nri
; iidx
++)
440 /* Load shift vector for this list */
441 i_shift_offset
= DIM
*shiftidx
[iidx
];
443 /* Load limits for loop over neighbors */
444 j_index_start
= jindex
[iidx
];
445 j_index_end
= jindex
[iidx
+1];
447 /* Get outer coordinate index */
449 i_coord_offset
= DIM
*inr
;
451 /* Load i particle coords and add shift vector */
452 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,&ix0
,&iy0
,&iz0
);
454 fix0
= _mm_setzero_pd();
455 fiy0
= _mm_setzero_pd();
456 fiz0
= _mm_setzero_pd();
458 /* Load parameters for i particles */
459 iq0
= _mm_mul_pd(facel
,_mm_load1_pd(charge
+inr
+0));
460 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
462 /* Start inner kernel loop */
463 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
466 /* Get j neighbor index, and coordinate index */
469 j_coord_offsetA
= DIM
*jnrA
;
470 j_coord_offsetB
= DIM
*jnrB
;
472 /* load j atom coordinates */
473 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
476 /* Calculate displacement vector */
477 dx00
= _mm_sub_pd(ix0
,jx0
);
478 dy00
= _mm_sub_pd(iy0
,jy0
);
479 dz00
= _mm_sub_pd(iz0
,jz0
);
481 /* Calculate squared distance and things based on it */
482 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
484 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
486 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
488 /* Load parameters for j particles */
489 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
490 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
491 vdwjidx0B
= 2*vdwtype
[jnrB
+0];
493 /**************************
494 * CALCULATE INTERACTIONS *
495 **************************/
497 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
500 /* Compute parameters for interactions between i and j atoms */
501 qq00
= _mm_mul_pd(iq0
,jq0
);
502 gmx_mm_load_2pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,
503 vdwparam
+vdwioffset0
+vdwjidx0B
,&c6_00
,&c12_00
);
505 /* REACTION-FIELD ELECTROSTATICS */
506 felec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_mul_pd(rinv00
,rinvsq00
),krf2
));
508 /* LENNARD-JONES DISPERSION/REPULSION */
510 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
511 fvdw
= _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00
,rinvsix
),c6_00
),_mm_mul_pd(rinvsix
,rinvsq00
));
513 cutoff_mask
= _mm_cmplt_pd(rsq00
,rcutoff2
);
515 fscal
= _mm_add_pd(felec
,fvdw
);
517 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
519 /* Calculate temporary vectorial force */
520 tx
= _mm_mul_pd(fscal
,dx00
);
521 ty
= _mm_mul_pd(fscal
,dy00
);
522 tz
= _mm_mul_pd(fscal
,dz00
);
524 /* Update vectorial force */
525 fix0
= _mm_add_pd(fix0
,tx
);
526 fiy0
= _mm_add_pd(fiy0
,ty
);
527 fiz0
= _mm_add_pd(fiz0
,tz
);
529 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,tx
,ty
,tz
);
533 /* Inner loop uses 37 flops */
540 j_coord_offsetA
= DIM
*jnrA
;
542 /* load j atom coordinates */
543 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
546 /* Calculate displacement vector */
547 dx00
= _mm_sub_pd(ix0
,jx0
);
548 dy00
= _mm_sub_pd(iy0
,jy0
);
549 dz00
= _mm_sub_pd(iz0
,jz0
);
551 /* Calculate squared distance and things based on it */
552 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
554 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
556 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
558 /* Load parameters for j particles */
559 jq0
= _mm_load_sd(charge
+jnrA
+0);
560 vdwjidx0A
= 2*vdwtype
[jnrA
+0];
562 /**************************
563 * CALCULATE INTERACTIONS *
564 **************************/
566 if (gmx_mm_any_lt(rsq00
,rcutoff2
))
569 /* Compute parameters for interactions between i and j atoms */
570 qq00
= _mm_mul_pd(iq0
,jq0
);
571 gmx_mm_load_1pair_swizzle_pd(vdwparam
+vdwioffset0
+vdwjidx0A
,&c6_00
,&c12_00
);
573 /* REACTION-FIELD ELECTROSTATICS */
574 felec
= _mm_mul_pd(qq00
,_mm_sub_pd(_mm_mul_pd(rinv00
,rinvsq00
),krf2
));
576 /* LENNARD-JONES DISPERSION/REPULSION */
578 rinvsix
= _mm_mul_pd(_mm_mul_pd(rinvsq00
,rinvsq00
),rinvsq00
);
579 fvdw
= _mm_mul_pd(_mm_sub_pd(_mm_mul_pd(c12_00
,rinvsix
),c6_00
),_mm_mul_pd(rinvsix
,rinvsq00
));
581 cutoff_mask
= _mm_cmplt_pd(rsq00
,rcutoff2
);
583 fscal
= _mm_add_pd(felec
,fvdw
);
585 fscal
= _mm_and_pd(fscal
,cutoff_mask
);
587 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
589 /* Calculate temporary vectorial force */
590 tx
= _mm_mul_pd(fscal
,dx00
);
591 ty
= _mm_mul_pd(fscal
,dy00
);
592 tz
= _mm_mul_pd(fscal
,dz00
);
594 /* Update vectorial force */
595 fix0
= _mm_add_pd(fix0
,tx
);
596 fiy0
= _mm_add_pd(fiy0
,ty
);
597 fiz0
= _mm_add_pd(fiz0
,tz
);
599 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,tx
,ty
,tz
);
603 /* Inner loop uses 37 flops */
606 /* End of innermost loop */
608 gmx_mm_update_iforce_1atom_swizzle_pd(fix0
,fiy0
,fiz0
,
609 f
+i_coord_offset
,fshift
+i_shift_offset
);
611 /* Increment number of inner iterations */
612 inneriter
+= j_index_end
- j_index_start
;
614 /* Outer loop uses 7 flops */
617 /* Increment number of outer iterations */
620 /* Update outer/inner flops */
622 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_F
,outeriter
*7 + inneriter
*37);