2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017, 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/gmxlib/nrnb.h"
47 #include "kernelutil_x86_sse4_1_double.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomP1P1_VF_sse4_1_double
51 * Electrostatics interaction: Coulomb
52 * VdW interaction: None
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCoul_VdwNone_GeomP1P1_VF_sse4_1_double
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 struct t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67 * just 0 for non-waters.
68 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
69 * jnr indices corresponding to data put in the four positions in the SIMD register.
71 int i_shift_offset,i_coord_offset,outeriter,inneriter;
72 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74 int j_coord_offsetA,j_coord_offsetB;
75 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
77 real *shiftvec,*fshift,*x,*f;
78 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
80 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
81 int vdwjidx0A,vdwjidx0B;
82 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
84 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
86 __m128d dummy_mask,cutoff_mask;
87 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
88 __m128d one = _mm_set1_pd(1.0);
89 __m128d two = _mm_set1_pd(2.0);
95 jindex = nlist->jindex;
97 shiftidx = nlist->shift;
99 shiftvec = fr->shift_vec[0];
100 fshift = fr->fshift[0];
101 facel = _mm_set1_pd(fr->ic->epsfac);
102 charge = mdatoms->chargeA;
104 /* Avoid stupid compiler warnings */
112 /* Start outer loop over neighborlists */
113 for(iidx=0; iidx<nri; iidx++)
115 /* Load shift vector for this list */
116 i_shift_offset = DIM*shiftidx[iidx];
118 /* Load limits for loop over neighbors */
119 j_index_start = jindex[iidx];
120 j_index_end = jindex[iidx+1];
122 /* Get outer coordinate index */
124 i_coord_offset = DIM*inr;
126 /* Load i particle coords and add shift vector */
127 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
129 fix0 = _mm_setzero_pd();
130 fiy0 = _mm_setzero_pd();
131 fiz0 = _mm_setzero_pd();
133 /* Load parameters for i particles */
134 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
136 /* Reset potential sums */
137 velecsum = _mm_setzero_pd();
139 /* Start inner kernel loop */
140 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
143 /* Get j neighbor index, and coordinate index */
146 j_coord_offsetA = DIM*jnrA;
147 j_coord_offsetB = DIM*jnrB;
149 /* load j atom coordinates */
150 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
153 /* Calculate displacement vector */
154 dx00 = _mm_sub_pd(ix0,jx0);
155 dy00 = _mm_sub_pd(iy0,jy0);
156 dz00 = _mm_sub_pd(iz0,jz0);
158 /* Calculate squared distance and things based on it */
159 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
161 rinv00 = sse41_invsqrt_d(rsq00);
163 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
165 /* Load parameters for j particles */
166 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
168 /**************************
169 * CALCULATE INTERACTIONS *
170 **************************/
172 /* Compute parameters for interactions between i and j atoms */
173 qq00 = _mm_mul_pd(iq0,jq0);
175 /* COULOMB ELECTROSTATICS */
176 velec = _mm_mul_pd(qq00,rinv00);
177 felec = _mm_mul_pd(velec,rinvsq00);
179 /* Update potential sum for this i atom from the interaction with this j atom. */
180 velecsum = _mm_add_pd(velecsum,velec);
184 /* Calculate temporary vectorial force */
185 tx = _mm_mul_pd(fscal,dx00);
186 ty = _mm_mul_pd(fscal,dy00);
187 tz = _mm_mul_pd(fscal,dz00);
189 /* Update vectorial force */
190 fix0 = _mm_add_pd(fix0,tx);
191 fiy0 = _mm_add_pd(fiy0,ty);
192 fiz0 = _mm_add_pd(fiz0,tz);
194 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
196 /* Inner loop uses 28 flops */
203 j_coord_offsetA = DIM*jnrA;
205 /* load j atom coordinates */
206 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
209 /* Calculate displacement vector */
210 dx00 = _mm_sub_pd(ix0,jx0);
211 dy00 = _mm_sub_pd(iy0,jy0);
212 dz00 = _mm_sub_pd(iz0,jz0);
214 /* Calculate squared distance and things based on it */
215 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
217 rinv00 = sse41_invsqrt_d(rsq00);
219 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
221 /* Load parameters for j particles */
222 jq0 = _mm_load_sd(charge+jnrA+0);
224 /**************************
225 * CALCULATE INTERACTIONS *
226 **************************/
228 /* Compute parameters for interactions between i and j atoms */
229 qq00 = _mm_mul_pd(iq0,jq0);
231 /* COULOMB ELECTROSTATICS */
232 velec = _mm_mul_pd(qq00,rinv00);
233 felec = _mm_mul_pd(velec,rinvsq00);
235 /* Update potential sum for this i atom from the interaction with this j atom. */
236 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
237 velecsum = _mm_add_pd(velecsum,velec);
241 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
243 /* Calculate temporary vectorial force */
244 tx = _mm_mul_pd(fscal,dx00);
245 ty = _mm_mul_pd(fscal,dy00);
246 tz = _mm_mul_pd(fscal,dz00);
248 /* Update vectorial force */
249 fix0 = _mm_add_pd(fix0,tx);
250 fiy0 = _mm_add_pd(fiy0,ty);
251 fiz0 = _mm_add_pd(fiz0,tz);
253 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
255 /* Inner loop uses 28 flops */
258 /* End of innermost loop */
260 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
261 f+i_coord_offset,fshift+i_shift_offset);
264 /* Update potential energies */
265 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
267 /* Increment number of inner iterations */
268 inneriter += j_index_end - j_index_start;
270 /* Outer loop uses 8 flops */
273 /* Increment number of outer iterations */
276 /* Update outer/inner flops */
278 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*8 + inneriter*28);
281 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomP1P1_F_sse4_1_double
282 * Electrostatics interaction: Coulomb
283 * VdW interaction: None
284 * Geometry: Particle-Particle
285 * Calculate force/pot: Force
288 nb_kernel_ElecCoul_VdwNone_GeomP1P1_F_sse4_1_double
289 (t_nblist * gmx_restrict nlist,
290 rvec * gmx_restrict xx,
291 rvec * gmx_restrict ff,
292 struct t_forcerec * gmx_restrict fr,
293 t_mdatoms * gmx_restrict mdatoms,
294 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
295 t_nrnb * gmx_restrict nrnb)
297 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
298 * just 0 for non-waters.
299 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
300 * jnr indices corresponding to data put in the four positions in the SIMD register.
302 int i_shift_offset,i_coord_offset,outeriter,inneriter;
303 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
305 int j_coord_offsetA,j_coord_offsetB;
306 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
308 real *shiftvec,*fshift,*x,*f;
309 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
311 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
312 int vdwjidx0A,vdwjidx0B;
313 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
314 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
315 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
317 __m128d dummy_mask,cutoff_mask;
318 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
319 __m128d one = _mm_set1_pd(1.0);
320 __m128d two = _mm_set1_pd(2.0);
326 jindex = nlist->jindex;
328 shiftidx = nlist->shift;
330 shiftvec = fr->shift_vec[0];
331 fshift = fr->fshift[0];
332 facel = _mm_set1_pd(fr->ic->epsfac);
333 charge = mdatoms->chargeA;
335 /* Avoid stupid compiler warnings */
343 /* Start outer loop over neighborlists */
344 for(iidx=0; iidx<nri; iidx++)
346 /* Load shift vector for this list */
347 i_shift_offset = DIM*shiftidx[iidx];
349 /* Load limits for loop over neighbors */
350 j_index_start = jindex[iidx];
351 j_index_end = jindex[iidx+1];
353 /* Get outer coordinate index */
355 i_coord_offset = DIM*inr;
357 /* Load i particle coords and add shift vector */
358 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
360 fix0 = _mm_setzero_pd();
361 fiy0 = _mm_setzero_pd();
362 fiz0 = _mm_setzero_pd();
364 /* Load parameters for i particles */
365 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
367 /* Start inner kernel loop */
368 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
371 /* Get j neighbor index, and coordinate index */
374 j_coord_offsetA = DIM*jnrA;
375 j_coord_offsetB = DIM*jnrB;
377 /* load j atom coordinates */
378 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
381 /* Calculate displacement vector */
382 dx00 = _mm_sub_pd(ix0,jx0);
383 dy00 = _mm_sub_pd(iy0,jy0);
384 dz00 = _mm_sub_pd(iz0,jz0);
386 /* Calculate squared distance and things based on it */
387 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
389 rinv00 = sse41_invsqrt_d(rsq00);
391 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
393 /* Load parameters for j particles */
394 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
396 /**************************
397 * CALCULATE INTERACTIONS *
398 **************************/
400 /* Compute parameters for interactions between i and j atoms */
401 qq00 = _mm_mul_pd(iq0,jq0);
403 /* COULOMB ELECTROSTATICS */
404 velec = _mm_mul_pd(qq00,rinv00);
405 felec = _mm_mul_pd(velec,rinvsq00);
409 /* Calculate temporary vectorial force */
410 tx = _mm_mul_pd(fscal,dx00);
411 ty = _mm_mul_pd(fscal,dy00);
412 tz = _mm_mul_pd(fscal,dz00);
414 /* Update vectorial force */
415 fix0 = _mm_add_pd(fix0,tx);
416 fiy0 = _mm_add_pd(fiy0,ty);
417 fiz0 = _mm_add_pd(fiz0,tz);
419 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
421 /* Inner loop uses 27 flops */
428 j_coord_offsetA = DIM*jnrA;
430 /* load j atom coordinates */
431 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
434 /* Calculate displacement vector */
435 dx00 = _mm_sub_pd(ix0,jx0);
436 dy00 = _mm_sub_pd(iy0,jy0);
437 dz00 = _mm_sub_pd(iz0,jz0);
439 /* Calculate squared distance and things based on it */
440 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
442 rinv00 = sse41_invsqrt_d(rsq00);
444 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
446 /* Load parameters for j particles */
447 jq0 = _mm_load_sd(charge+jnrA+0);
449 /**************************
450 * CALCULATE INTERACTIONS *
451 **************************/
453 /* Compute parameters for interactions between i and j atoms */
454 qq00 = _mm_mul_pd(iq0,jq0);
456 /* COULOMB ELECTROSTATICS */
457 velec = _mm_mul_pd(qq00,rinv00);
458 felec = _mm_mul_pd(velec,rinvsq00);
462 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
464 /* Calculate temporary vectorial force */
465 tx = _mm_mul_pd(fscal,dx00);
466 ty = _mm_mul_pd(fscal,dy00);
467 tz = _mm_mul_pd(fscal,dz00);
469 /* Update vectorial force */
470 fix0 = _mm_add_pd(fix0,tx);
471 fiy0 = _mm_add_pd(fiy0,ty);
472 fiz0 = _mm_add_pd(fiz0,tz);
474 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
476 /* Inner loop uses 27 flops */
479 /* End of innermost loop */
481 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
482 f+i_coord_offset,fshift+i_shift_offset);
484 /* Increment number of inner iterations */
485 inneriter += j_index_end - j_index_start;
487 /* Outer loop uses 7 flops */
490 /* Increment number of outer iterations */
493 /* Update outer/inner flops */
495 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*27);