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_ElecCoul_VdwNone_GeomP1P1_VF_sse2_double
53 * Electrostatics interaction: Coulomb
54 * VdW interaction: None
55 * Geometry: Particle-Particle
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecCoul_VdwNone_GeomP1P1_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
;
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
;
88 __m128d dummy_mask
,cutoff_mask
;
89 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
90 __m128d one
= _mm_set1_pd(1.0);
91 __m128d two
= _mm_set1_pd(2.0);
97 jindex
= nlist
->jindex
;
99 shiftidx
= nlist
->shift
;
101 shiftvec
= fr
->shift_vec
[0];
102 fshift
= fr
->fshift
[0];
103 facel
= _mm_set1_pd(fr
->epsfac
);
104 charge
= mdatoms
->chargeA
;
106 /* Avoid stupid compiler warnings */
114 /* Start outer loop over neighborlists */
115 for(iidx
=0; iidx
<nri
; iidx
++)
117 /* Load shift vector for this list */
118 i_shift_offset
= DIM
*shiftidx
[iidx
];
120 /* Load limits for loop over neighbors */
121 j_index_start
= jindex
[iidx
];
122 j_index_end
= jindex
[iidx
+1];
124 /* Get outer coordinate index */
126 i_coord_offset
= DIM
*inr
;
128 /* Load i particle coords and add shift vector */
129 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,&ix0
,&iy0
,&iz0
);
131 fix0
= _mm_setzero_pd();
132 fiy0
= _mm_setzero_pd();
133 fiz0
= _mm_setzero_pd();
135 /* Load parameters for i particles */
136 iq0
= _mm_mul_pd(facel
,_mm_load1_pd(charge
+inr
+0));
138 /* Reset potential sums */
139 velecsum
= _mm_setzero_pd();
141 /* Start inner kernel loop */
142 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
145 /* Get j neighbor index, and coordinate index */
148 j_coord_offsetA
= DIM
*jnrA
;
149 j_coord_offsetB
= DIM
*jnrB
;
151 /* load j atom coordinates */
152 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
155 /* Calculate displacement vector */
156 dx00
= _mm_sub_pd(ix0
,jx0
);
157 dy00
= _mm_sub_pd(iy0
,jy0
);
158 dz00
= _mm_sub_pd(iz0
,jz0
);
160 /* Calculate squared distance and things based on it */
161 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
163 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
165 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
167 /* Load parameters for j particles */
168 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
170 /**************************
171 * CALCULATE INTERACTIONS *
172 **************************/
174 /* Compute parameters for interactions between i and j atoms */
175 qq00
= _mm_mul_pd(iq0
,jq0
);
177 /* COULOMB ELECTROSTATICS */
178 velec
= _mm_mul_pd(qq00
,rinv00
);
179 felec
= _mm_mul_pd(velec
,rinvsq00
);
181 /* Update potential sum for this i atom from the interaction with this j atom. */
182 velecsum
= _mm_add_pd(velecsum
,velec
);
186 /* Calculate temporary vectorial force */
187 tx
= _mm_mul_pd(fscal
,dx00
);
188 ty
= _mm_mul_pd(fscal
,dy00
);
189 tz
= _mm_mul_pd(fscal
,dz00
);
191 /* Update vectorial force */
192 fix0
= _mm_add_pd(fix0
,tx
);
193 fiy0
= _mm_add_pd(fiy0
,ty
);
194 fiz0
= _mm_add_pd(fiz0
,tz
);
196 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,tx
,ty
,tz
);
198 /* Inner loop uses 28 flops */
205 j_coord_offsetA
= DIM
*jnrA
;
207 /* load j atom coordinates */
208 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
211 /* Calculate displacement vector */
212 dx00
= _mm_sub_pd(ix0
,jx0
);
213 dy00
= _mm_sub_pd(iy0
,jy0
);
214 dz00
= _mm_sub_pd(iz0
,jz0
);
216 /* Calculate squared distance and things based on it */
217 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
219 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
221 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
223 /* Load parameters for j particles */
224 jq0
= _mm_load_sd(charge
+jnrA
+0);
226 /**************************
227 * CALCULATE INTERACTIONS *
228 **************************/
230 /* Compute parameters for interactions between i and j atoms */
231 qq00
= _mm_mul_pd(iq0
,jq0
);
233 /* COULOMB ELECTROSTATICS */
234 velec
= _mm_mul_pd(qq00
,rinv00
);
235 felec
= _mm_mul_pd(velec
,rinvsq00
);
237 /* Update potential sum for this i atom from the interaction with this j atom. */
238 velec
= _mm_unpacklo_pd(velec
,_mm_setzero_pd());
239 velecsum
= _mm_add_pd(velecsum
,velec
);
243 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
245 /* Calculate temporary vectorial force */
246 tx
= _mm_mul_pd(fscal
,dx00
);
247 ty
= _mm_mul_pd(fscal
,dy00
);
248 tz
= _mm_mul_pd(fscal
,dz00
);
250 /* Update vectorial force */
251 fix0
= _mm_add_pd(fix0
,tx
);
252 fiy0
= _mm_add_pd(fiy0
,ty
);
253 fiz0
= _mm_add_pd(fiz0
,tz
);
255 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,tx
,ty
,tz
);
257 /* Inner loop uses 28 flops */
260 /* End of innermost loop */
262 gmx_mm_update_iforce_1atom_swizzle_pd(fix0
,fiy0
,fiz0
,
263 f
+i_coord_offset
,fshift
+i_shift_offset
);
266 /* Update potential energies */
267 gmx_mm_update_1pot_pd(velecsum
,kernel_data
->energygrp_elec
+ggid
);
269 /* Increment number of inner iterations */
270 inneriter
+= j_index_end
- j_index_start
;
272 /* Outer loop uses 8 flops */
275 /* Increment number of outer iterations */
278 /* Update outer/inner flops */
280 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VF
,outeriter
*8 + inneriter
*28);
283 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomP1P1_F_sse2_double
284 * Electrostatics interaction: Coulomb
285 * VdW interaction: None
286 * Geometry: Particle-Particle
287 * Calculate force/pot: Force
290 nb_kernel_ElecCoul_VdwNone_GeomP1P1_F_sse2_double
291 (t_nblist
* gmx_restrict nlist
,
292 rvec
* gmx_restrict xx
,
293 rvec
* gmx_restrict ff
,
294 t_forcerec
* gmx_restrict fr
,
295 t_mdatoms
* gmx_restrict mdatoms
,
296 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
297 t_nrnb
* gmx_restrict nrnb
)
299 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
300 * just 0 for non-waters.
301 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
302 * jnr indices corresponding to data put in the four positions in the SIMD register.
304 int i_shift_offset
,i_coord_offset
,outeriter
,inneriter
;
305 int j_index_start
,j_index_end
,jidx
,nri
,inr
,ggid
,iidx
;
307 int j_coord_offsetA
,j_coord_offsetB
;
308 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
310 real
*shiftvec
,*fshift
,*x
,*f
;
311 __m128d tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
,jidxall
;
313 __m128d ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
314 int vdwjidx0A
,vdwjidx0B
;
315 __m128d jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
316 __m128d dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
;
317 __m128d velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
319 __m128d dummy_mask
,cutoff_mask
;
320 __m128d signbit
= gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
321 __m128d one
= _mm_set1_pd(1.0);
322 __m128d two
= _mm_set1_pd(2.0);
328 jindex
= nlist
->jindex
;
330 shiftidx
= nlist
->shift
;
332 shiftvec
= fr
->shift_vec
[0];
333 fshift
= fr
->fshift
[0];
334 facel
= _mm_set1_pd(fr
->epsfac
);
335 charge
= mdatoms
->chargeA
;
337 /* Avoid stupid compiler warnings */
345 /* Start outer loop over neighborlists */
346 for(iidx
=0; iidx
<nri
; iidx
++)
348 /* Load shift vector for this list */
349 i_shift_offset
= DIM
*shiftidx
[iidx
];
351 /* Load limits for loop over neighbors */
352 j_index_start
= jindex
[iidx
];
353 j_index_end
= jindex
[iidx
+1];
355 /* Get outer coordinate index */
357 i_coord_offset
= DIM
*inr
;
359 /* Load i particle coords and add shift vector */
360 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec
+i_shift_offset
,x
+i_coord_offset
,&ix0
,&iy0
,&iz0
);
362 fix0
= _mm_setzero_pd();
363 fiy0
= _mm_setzero_pd();
364 fiz0
= _mm_setzero_pd();
366 /* Load parameters for i particles */
367 iq0
= _mm_mul_pd(facel
,_mm_load1_pd(charge
+inr
+0));
369 /* Start inner kernel loop */
370 for(jidx
=j_index_start
; jidx
<j_index_end
-1; jidx
+=2)
373 /* Get j neighbor index, and coordinate index */
376 j_coord_offsetA
= DIM
*jnrA
;
377 j_coord_offsetB
= DIM
*jnrB
;
379 /* load j atom coordinates */
380 gmx_mm_load_1rvec_2ptr_swizzle_pd(x
+j_coord_offsetA
,x
+j_coord_offsetB
,
383 /* Calculate displacement vector */
384 dx00
= _mm_sub_pd(ix0
,jx0
);
385 dy00
= _mm_sub_pd(iy0
,jy0
);
386 dz00
= _mm_sub_pd(iz0
,jz0
);
388 /* Calculate squared distance and things based on it */
389 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
391 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
393 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
395 /* Load parameters for j particles */
396 jq0
= gmx_mm_load_2real_swizzle_pd(charge
+jnrA
+0,charge
+jnrB
+0);
398 /**************************
399 * CALCULATE INTERACTIONS *
400 **************************/
402 /* Compute parameters for interactions between i and j atoms */
403 qq00
= _mm_mul_pd(iq0
,jq0
);
405 /* COULOMB ELECTROSTATICS */
406 velec
= _mm_mul_pd(qq00
,rinv00
);
407 felec
= _mm_mul_pd(velec
,rinvsq00
);
411 /* Calculate temporary vectorial force */
412 tx
= _mm_mul_pd(fscal
,dx00
);
413 ty
= _mm_mul_pd(fscal
,dy00
);
414 tz
= _mm_mul_pd(fscal
,dz00
);
416 /* Update vectorial force */
417 fix0
= _mm_add_pd(fix0
,tx
);
418 fiy0
= _mm_add_pd(fiy0
,ty
);
419 fiz0
= _mm_add_pd(fiz0
,tz
);
421 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f
+j_coord_offsetA
,f
+j_coord_offsetB
,tx
,ty
,tz
);
423 /* Inner loop uses 27 flops */
430 j_coord_offsetA
= DIM
*jnrA
;
432 /* load j atom coordinates */
433 gmx_mm_load_1rvec_1ptr_swizzle_pd(x
+j_coord_offsetA
,
436 /* Calculate displacement vector */
437 dx00
= _mm_sub_pd(ix0
,jx0
);
438 dy00
= _mm_sub_pd(iy0
,jy0
);
439 dz00
= _mm_sub_pd(iz0
,jz0
);
441 /* Calculate squared distance and things based on it */
442 rsq00
= gmx_mm_calc_rsq_pd(dx00
,dy00
,dz00
);
444 rinv00
= gmx_mm_invsqrt_pd(rsq00
);
446 rinvsq00
= _mm_mul_pd(rinv00
,rinv00
);
448 /* Load parameters for j particles */
449 jq0
= _mm_load_sd(charge
+jnrA
+0);
451 /**************************
452 * CALCULATE INTERACTIONS *
453 **************************/
455 /* Compute parameters for interactions between i and j atoms */
456 qq00
= _mm_mul_pd(iq0
,jq0
);
458 /* COULOMB ELECTROSTATICS */
459 velec
= _mm_mul_pd(qq00
,rinv00
);
460 felec
= _mm_mul_pd(velec
,rinvsq00
);
464 fscal
= _mm_unpacklo_pd(fscal
,_mm_setzero_pd());
466 /* Calculate temporary vectorial force */
467 tx
= _mm_mul_pd(fscal
,dx00
);
468 ty
= _mm_mul_pd(fscal
,dy00
);
469 tz
= _mm_mul_pd(fscal
,dz00
);
471 /* Update vectorial force */
472 fix0
= _mm_add_pd(fix0
,tx
);
473 fiy0
= _mm_add_pd(fiy0
,ty
);
474 fiz0
= _mm_add_pd(fiz0
,tz
);
476 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f
+j_coord_offsetA
,tx
,ty
,tz
);
478 /* Inner loop uses 27 flops */
481 /* End of innermost loop */
483 gmx_mm_update_iforce_1atom_swizzle_pd(fix0
,fiy0
,fiz0
,
484 f
+i_coord_offset
,fshift
+i_shift_offset
);
486 /* Increment number of inner iterations */
487 inneriter
+= j_index_end
- j_index_start
;
489 /* Outer loop uses 7 flops */
492 /* Increment number of outer iterations */
495 /* Update outer/inner flops */
497 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_F
,outeriter
*7 + inneriter
*27);