2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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 "types/simple.h"
49 #include "gromacs/simd/math_x86_sse2_double.h"
50 #include "kernelutil_x86_sse2_double.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomP1P1_VF_sse2_double
54 * Electrostatics interaction: Ewald
55 * VdW interaction: CubicSplineTable
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecEw_VdwCSTab_GeomP1P1_VF_sse2_double
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
72 * jnr indices corresponding to data put in the four positions in the SIMD register.
74 int i_shift_offset,i_coord_offset,outeriter,inneriter;
75 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
77 int j_coord_offsetA,j_coord_offsetB;
78 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
80 real *shiftvec,*fshift,*x,*f;
81 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
83 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
84 int vdwjidx0A,vdwjidx0B;
85 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
86 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
87 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
90 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
93 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
94 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
96 __m128i ifour = _mm_set1_epi32(4);
97 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
100 __m128d ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
102 __m128d dummy_mask,cutoff_mask;
103 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
104 __m128d one = _mm_set1_pd(1.0);
105 __m128d two = _mm_set1_pd(2.0);
111 jindex = nlist->jindex;
113 shiftidx = nlist->shift;
115 shiftvec = fr->shift_vec[0];
116 fshift = fr->fshift[0];
117 facel = _mm_set1_pd(fr->epsfac);
118 charge = mdatoms->chargeA;
119 nvdwtype = fr->ntype;
121 vdwtype = mdatoms->typeA;
123 vftab = kernel_data->table_vdw->data;
124 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
126 sh_ewald = _mm_set1_pd(fr->ic->sh_ewald);
127 ewtab = fr->ic->tabq_coul_FDV0;
128 ewtabscale = _mm_set1_pd(fr->ic->tabq_scale);
129 ewtabhalfspace = _mm_set1_pd(0.5/fr->ic->tabq_scale);
131 /* Avoid stupid compiler warnings */
139 /* Start outer loop over neighborlists */
140 for(iidx=0; iidx<nri; iidx++)
142 /* Load shift vector for this list */
143 i_shift_offset = DIM*shiftidx[iidx];
145 /* Load limits for loop over neighbors */
146 j_index_start = jindex[iidx];
147 j_index_end = jindex[iidx+1];
149 /* Get outer coordinate index */
151 i_coord_offset = DIM*inr;
153 /* Load i particle coords and add shift vector */
154 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
156 fix0 = _mm_setzero_pd();
157 fiy0 = _mm_setzero_pd();
158 fiz0 = _mm_setzero_pd();
160 /* Load parameters for i particles */
161 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
162 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
164 /* Reset potential sums */
165 velecsum = _mm_setzero_pd();
166 vvdwsum = _mm_setzero_pd();
168 /* Start inner kernel loop */
169 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
172 /* Get j neighbor index, and coordinate index */
175 j_coord_offsetA = DIM*jnrA;
176 j_coord_offsetB = DIM*jnrB;
178 /* load j atom coordinates */
179 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
182 /* Calculate displacement vector */
183 dx00 = _mm_sub_pd(ix0,jx0);
184 dy00 = _mm_sub_pd(iy0,jy0);
185 dz00 = _mm_sub_pd(iz0,jz0);
187 /* Calculate squared distance and things based on it */
188 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
190 rinv00 = gmx_mm_invsqrt_pd(rsq00);
192 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
194 /* Load parameters for j particles */
195 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
196 vdwjidx0A = 2*vdwtype[jnrA+0];
197 vdwjidx0B = 2*vdwtype[jnrB+0];
199 /**************************
200 * CALCULATE INTERACTIONS *
201 **************************/
203 r00 = _mm_mul_pd(rsq00,rinv00);
205 /* Compute parameters for interactions between i and j atoms */
206 qq00 = _mm_mul_pd(iq0,jq0);
207 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
208 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
210 /* Calculate table index by multiplying r with table scale and truncate to integer */
211 rt = _mm_mul_pd(r00,vftabscale);
212 vfitab = _mm_cvttpd_epi32(rt);
213 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
214 vfitab = _mm_slli_epi32(vfitab,3);
216 /* EWALD ELECTROSTATICS */
218 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
219 ewrt = _mm_mul_pd(r00,ewtabscale);
220 ewitab = _mm_cvttpd_epi32(ewrt);
221 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
222 ewitab = _mm_slli_epi32(ewitab,2);
223 ewtabF = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
224 ewtabD = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,1) );
225 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
226 ewtabV = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
227 ewtabFn = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,1) +2);
228 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
229 felec = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
230 velec = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
231 velec = _mm_mul_pd(qq00,_mm_sub_pd(rinv00,velec));
232 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
234 /* CUBIC SPLINE TABLE DISPERSION */
235 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
236 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
237 GMX_MM_TRANSPOSE2_PD(Y,F);
238 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
239 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
240 GMX_MM_TRANSPOSE2_PD(G,H);
241 Heps = _mm_mul_pd(vfeps,H);
242 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
243 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
244 vvdw6 = _mm_mul_pd(c6_00,VV);
245 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
246 fvdw6 = _mm_mul_pd(c6_00,FF);
248 /* CUBIC SPLINE TABLE REPULSION */
249 vfitab = _mm_add_epi32(vfitab,ifour);
250 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
251 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
252 GMX_MM_TRANSPOSE2_PD(Y,F);
253 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
254 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
255 GMX_MM_TRANSPOSE2_PD(G,H);
256 Heps = _mm_mul_pd(vfeps,H);
257 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
258 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
259 vvdw12 = _mm_mul_pd(c12_00,VV);
260 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
261 fvdw12 = _mm_mul_pd(c12_00,FF);
262 vvdw = _mm_add_pd(vvdw12,vvdw6);
263 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
265 /* Update potential sum for this i atom from the interaction with this j atom. */
266 velecsum = _mm_add_pd(velecsum,velec);
267 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
269 fscal = _mm_add_pd(felec,fvdw);
271 /* Calculate temporary vectorial force */
272 tx = _mm_mul_pd(fscal,dx00);
273 ty = _mm_mul_pd(fscal,dy00);
274 tz = _mm_mul_pd(fscal,dz00);
276 /* Update vectorial force */
277 fix0 = _mm_add_pd(fix0,tx);
278 fiy0 = _mm_add_pd(fiy0,ty);
279 fiz0 = _mm_add_pd(fiz0,tz);
281 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
283 /* Inner loop uses 75 flops */
290 j_coord_offsetA = DIM*jnrA;
292 /* load j atom coordinates */
293 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
296 /* Calculate displacement vector */
297 dx00 = _mm_sub_pd(ix0,jx0);
298 dy00 = _mm_sub_pd(iy0,jy0);
299 dz00 = _mm_sub_pd(iz0,jz0);
301 /* Calculate squared distance and things based on it */
302 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
304 rinv00 = gmx_mm_invsqrt_pd(rsq00);
306 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
308 /* Load parameters for j particles */
309 jq0 = _mm_load_sd(charge+jnrA+0);
310 vdwjidx0A = 2*vdwtype[jnrA+0];
312 /**************************
313 * CALCULATE INTERACTIONS *
314 **************************/
316 r00 = _mm_mul_pd(rsq00,rinv00);
318 /* Compute parameters for interactions between i and j atoms */
319 qq00 = _mm_mul_pd(iq0,jq0);
320 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
322 /* Calculate table index by multiplying r with table scale and truncate to integer */
323 rt = _mm_mul_pd(r00,vftabscale);
324 vfitab = _mm_cvttpd_epi32(rt);
325 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
326 vfitab = _mm_slli_epi32(vfitab,3);
328 /* EWALD ELECTROSTATICS */
330 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
331 ewrt = _mm_mul_pd(r00,ewtabscale);
332 ewitab = _mm_cvttpd_epi32(ewrt);
333 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
334 ewitab = _mm_slli_epi32(ewitab,2);
335 ewtabF = _mm_load_pd( ewtab + gmx_mm_extract_epi32(ewitab,0) );
336 ewtabD = _mm_setzero_pd();
337 GMX_MM_TRANSPOSE2_PD(ewtabF,ewtabD);
338 ewtabV = _mm_load_sd( ewtab + gmx_mm_extract_epi32(ewitab,0) +2);
339 ewtabFn = _mm_setzero_pd();
340 GMX_MM_TRANSPOSE2_PD(ewtabV,ewtabFn);
341 felec = _mm_add_pd(ewtabF,_mm_mul_pd(eweps,ewtabD));
342 velec = _mm_sub_pd(ewtabV,_mm_mul_pd(_mm_mul_pd(ewtabhalfspace,eweps),_mm_add_pd(ewtabF,felec)));
343 velec = _mm_mul_pd(qq00,_mm_sub_pd(rinv00,velec));
344 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
346 /* CUBIC SPLINE TABLE DISPERSION */
347 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
348 F = _mm_setzero_pd();
349 GMX_MM_TRANSPOSE2_PD(Y,F);
350 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
351 H = _mm_setzero_pd();
352 GMX_MM_TRANSPOSE2_PD(G,H);
353 Heps = _mm_mul_pd(vfeps,H);
354 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
355 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
356 vvdw6 = _mm_mul_pd(c6_00,VV);
357 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
358 fvdw6 = _mm_mul_pd(c6_00,FF);
360 /* CUBIC SPLINE TABLE REPULSION */
361 vfitab = _mm_add_epi32(vfitab,ifour);
362 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
363 F = _mm_setzero_pd();
364 GMX_MM_TRANSPOSE2_PD(Y,F);
365 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
366 H = _mm_setzero_pd();
367 GMX_MM_TRANSPOSE2_PD(G,H);
368 Heps = _mm_mul_pd(vfeps,H);
369 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
370 VV = _mm_add_pd(Y,_mm_mul_pd(vfeps,Fp));
371 vvdw12 = _mm_mul_pd(c12_00,VV);
372 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
373 fvdw12 = _mm_mul_pd(c12_00,FF);
374 vvdw = _mm_add_pd(vvdw12,vvdw6);
375 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
377 /* Update potential sum for this i atom from the interaction with this j atom. */
378 velec = _mm_unpacklo_pd(velec,_mm_setzero_pd());
379 velecsum = _mm_add_pd(velecsum,velec);
380 vvdw = _mm_unpacklo_pd(vvdw,_mm_setzero_pd());
381 vvdwsum = _mm_add_pd(vvdwsum,vvdw);
383 fscal = _mm_add_pd(felec,fvdw);
385 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
387 /* Calculate temporary vectorial force */
388 tx = _mm_mul_pd(fscal,dx00);
389 ty = _mm_mul_pd(fscal,dy00);
390 tz = _mm_mul_pd(fscal,dz00);
392 /* Update vectorial force */
393 fix0 = _mm_add_pd(fix0,tx);
394 fiy0 = _mm_add_pd(fiy0,ty);
395 fiz0 = _mm_add_pd(fiz0,tz);
397 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
399 /* Inner loop uses 75 flops */
402 /* End of innermost loop */
404 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
405 f+i_coord_offset,fshift+i_shift_offset);
408 /* Update potential energies */
409 gmx_mm_update_1pot_pd(velecsum,kernel_data->energygrp_elec+ggid);
410 gmx_mm_update_1pot_pd(vvdwsum,kernel_data->energygrp_vdw+ggid);
412 /* Increment number of inner iterations */
413 inneriter += j_index_end - j_index_start;
415 /* Outer loop uses 9 flops */
418 /* Increment number of outer iterations */
421 /* Update outer/inner flops */
423 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*75);
426 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomP1P1_F_sse2_double
427 * Electrostatics interaction: Ewald
428 * VdW interaction: CubicSplineTable
429 * Geometry: Particle-Particle
430 * Calculate force/pot: Force
433 nb_kernel_ElecEw_VdwCSTab_GeomP1P1_F_sse2_double
434 (t_nblist * gmx_restrict nlist,
435 rvec * gmx_restrict xx,
436 rvec * gmx_restrict ff,
437 t_forcerec * gmx_restrict fr,
438 t_mdatoms * gmx_restrict mdatoms,
439 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
440 t_nrnb * gmx_restrict nrnb)
442 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
443 * just 0 for non-waters.
444 * Suffixes A,B refer to j loop unrolling done with SSE double precision, e.g. for the two different
445 * jnr indices corresponding to data put in the four positions in the SIMD register.
447 int i_shift_offset,i_coord_offset,outeriter,inneriter;
448 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
450 int j_coord_offsetA,j_coord_offsetB;
451 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
453 real *shiftvec,*fshift,*x,*f;
454 __m128d tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
456 __m128d ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
457 int vdwjidx0A,vdwjidx0B;
458 __m128d jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
459 __m128d dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
460 __m128d velec,felec,velecsum,facel,crf,krf,krf2;
463 __m128d rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
466 __m128d one_sixth = _mm_set1_pd(1.0/6.0);
467 __m128d one_twelfth = _mm_set1_pd(1.0/12.0);
469 __m128i ifour = _mm_set1_epi32(4);
470 __m128d rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
473 __m128d ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
475 __m128d dummy_mask,cutoff_mask;
476 __m128d signbit = gmx_mm_castsi128_pd( _mm_set_epi32(0x80000000,0x00000000,0x80000000,0x00000000) );
477 __m128d one = _mm_set1_pd(1.0);
478 __m128d two = _mm_set1_pd(2.0);
484 jindex = nlist->jindex;
486 shiftidx = nlist->shift;
488 shiftvec = fr->shift_vec[0];
489 fshift = fr->fshift[0];
490 facel = _mm_set1_pd(fr->epsfac);
491 charge = mdatoms->chargeA;
492 nvdwtype = fr->ntype;
494 vdwtype = mdatoms->typeA;
496 vftab = kernel_data->table_vdw->data;
497 vftabscale = _mm_set1_pd(kernel_data->table_vdw->scale);
499 sh_ewald = _mm_set1_pd(fr->ic->sh_ewald);
500 ewtab = fr->ic->tabq_coul_F;
501 ewtabscale = _mm_set1_pd(fr->ic->tabq_scale);
502 ewtabhalfspace = _mm_set1_pd(0.5/fr->ic->tabq_scale);
504 /* Avoid stupid compiler warnings */
512 /* Start outer loop over neighborlists */
513 for(iidx=0; iidx<nri; iidx++)
515 /* Load shift vector for this list */
516 i_shift_offset = DIM*shiftidx[iidx];
518 /* Load limits for loop over neighbors */
519 j_index_start = jindex[iidx];
520 j_index_end = jindex[iidx+1];
522 /* Get outer coordinate index */
524 i_coord_offset = DIM*inr;
526 /* Load i particle coords and add shift vector */
527 gmx_mm_load_shift_and_1rvec_broadcast_pd(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
529 fix0 = _mm_setzero_pd();
530 fiy0 = _mm_setzero_pd();
531 fiz0 = _mm_setzero_pd();
533 /* Load parameters for i particles */
534 iq0 = _mm_mul_pd(facel,_mm_load1_pd(charge+inr+0));
535 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
537 /* Start inner kernel loop */
538 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
541 /* Get j neighbor index, and coordinate index */
544 j_coord_offsetA = DIM*jnrA;
545 j_coord_offsetB = DIM*jnrB;
547 /* load j atom coordinates */
548 gmx_mm_load_1rvec_2ptr_swizzle_pd(x+j_coord_offsetA,x+j_coord_offsetB,
551 /* Calculate displacement vector */
552 dx00 = _mm_sub_pd(ix0,jx0);
553 dy00 = _mm_sub_pd(iy0,jy0);
554 dz00 = _mm_sub_pd(iz0,jz0);
556 /* Calculate squared distance and things based on it */
557 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
559 rinv00 = gmx_mm_invsqrt_pd(rsq00);
561 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
563 /* Load parameters for j particles */
564 jq0 = gmx_mm_load_2real_swizzle_pd(charge+jnrA+0,charge+jnrB+0);
565 vdwjidx0A = 2*vdwtype[jnrA+0];
566 vdwjidx0B = 2*vdwtype[jnrB+0];
568 /**************************
569 * CALCULATE INTERACTIONS *
570 **************************/
572 r00 = _mm_mul_pd(rsq00,rinv00);
574 /* Compute parameters for interactions between i and j atoms */
575 qq00 = _mm_mul_pd(iq0,jq0);
576 gmx_mm_load_2pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,
577 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
579 /* Calculate table index by multiplying r with table scale and truncate to integer */
580 rt = _mm_mul_pd(r00,vftabscale);
581 vfitab = _mm_cvttpd_epi32(rt);
582 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
583 vfitab = _mm_slli_epi32(vfitab,3);
585 /* EWALD ELECTROSTATICS */
587 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
588 ewrt = _mm_mul_pd(r00,ewtabscale);
589 ewitab = _mm_cvttpd_epi32(ewrt);
590 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
591 gmx_mm_load_2pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),ewtab+gmx_mm_extract_epi32(ewitab,1),
593 felec = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
594 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
596 /* CUBIC SPLINE TABLE DISPERSION */
597 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
598 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
599 GMX_MM_TRANSPOSE2_PD(Y,F);
600 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
601 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
602 GMX_MM_TRANSPOSE2_PD(G,H);
603 Heps = _mm_mul_pd(vfeps,H);
604 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
605 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
606 fvdw6 = _mm_mul_pd(c6_00,FF);
608 /* CUBIC SPLINE TABLE REPULSION */
609 vfitab = _mm_add_epi32(vfitab,ifour);
610 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
611 F = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) );
612 GMX_MM_TRANSPOSE2_PD(Y,F);
613 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
614 H = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,1) +2);
615 GMX_MM_TRANSPOSE2_PD(G,H);
616 Heps = _mm_mul_pd(vfeps,H);
617 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
618 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
619 fvdw12 = _mm_mul_pd(c12_00,FF);
620 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
622 fscal = _mm_add_pd(felec,fvdw);
624 /* Calculate temporary vectorial force */
625 tx = _mm_mul_pd(fscal,dx00);
626 ty = _mm_mul_pd(fscal,dy00);
627 tz = _mm_mul_pd(fscal,dz00);
629 /* Update vectorial force */
630 fix0 = _mm_add_pd(fix0,tx);
631 fiy0 = _mm_add_pd(fiy0,ty);
632 fiz0 = _mm_add_pd(fiz0,tz);
634 gmx_mm_decrement_1rvec_2ptr_swizzle_pd(f+j_coord_offsetA,f+j_coord_offsetB,tx,ty,tz);
636 /* Inner loop uses 62 flops */
643 j_coord_offsetA = DIM*jnrA;
645 /* load j atom coordinates */
646 gmx_mm_load_1rvec_1ptr_swizzle_pd(x+j_coord_offsetA,
649 /* Calculate displacement vector */
650 dx00 = _mm_sub_pd(ix0,jx0);
651 dy00 = _mm_sub_pd(iy0,jy0);
652 dz00 = _mm_sub_pd(iz0,jz0);
654 /* Calculate squared distance and things based on it */
655 rsq00 = gmx_mm_calc_rsq_pd(dx00,dy00,dz00);
657 rinv00 = gmx_mm_invsqrt_pd(rsq00);
659 rinvsq00 = _mm_mul_pd(rinv00,rinv00);
661 /* Load parameters for j particles */
662 jq0 = _mm_load_sd(charge+jnrA+0);
663 vdwjidx0A = 2*vdwtype[jnrA+0];
665 /**************************
666 * CALCULATE INTERACTIONS *
667 **************************/
669 r00 = _mm_mul_pd(rsq00,rinv00);
671 /* Compute parameters for interactions between i and j atoms */
672 qq00 = _mm_mul_pd(iq0,jq0);
673 gmx_mm_load_1pair_swizzle_pd(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
675 /* Calculate table index by multiplying r with table scale and truncate to integer */
676 rt = _mm_mul_pd(r00,vftabscale);
677 vfitab = _mm_cvttpd_epi32(rt);
678 vfeps = _mm_sub_pd(rt,_mm_cvtepi32_pd(vfitab));
679 vfitab = _mm_slli_epi32(vfitab,3);
681 /* EWALD ELECTROSTATICS */
683 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
684 ewrt = _mm_mul_pd(r00,ewtabscale);
685 ewitab = _mm_cvttpd_epi32(ewrt);
686 eweps = _mm_sub_pd(ewrt,_mm_cvtepi32_pd(ewitab));
687 gmx_mm_load_1pair_swizzle_pd(ewtab+gmx_mm_extract_epi32(ewitab,0),&ewtabF,&ewtabFn);
688 felec = _mm_add_pd(_mm_mul_pd( _mm_sub_pd(one,eweps),ewtabF),_mm_mul_pd(eweps,ewtabFn));
689 felec = _mm_mul_pd(_mm_mul_pd(qq00,rinv00),_mm_sub_pd(rinvsq00,felec));
691 /* CUBIC SPLINE TABLE DISPERSION */
692 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
693 F = _mm_setzero_pd();
694 GMX_MM_TRANSPOSE2_PD(Y,F);
695 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
696 H = _mm_setzero_pd();
697 GMX_MM_TRANSPOSE2_PD(G,H);
698 Heps = _mm_mul_pd(vfeps,H);
699 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
700 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
701 fvdw6 = _mm_mul_pd(c6_00,FF);
703 /* CUBIC SPLINE TABLE REPULSION */
704 vfitab = _mm_add_epi32(vfitab,ifour);
705 Y = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) );
706 F = _mm_setzero_pd();
707 GMX_MM_TRANSPOSE2_PD(Y,F);
708 G = _mm_load_pd( vftab + gmx_mm_extract_epi32(vfitab,0) +2);
709 H = _mm_setzero_pd();
710 GMX_MM_TRANSPOSE2_PD(G,H);
711 Heps = _mm_mul_pd(vfeps,H);
712 Fp = _mm_add_pd(F,_mm_mul_pd(vfeps,_mm_add_pd(G,Heps)));
713 FF = _mm_add_pd(Fp,_mm_mul_pd(vfeps,_mm_add_pd(G,_mm_add_pd(Heps,Heps))));
714 fvdw12 = _mm_mul_pd(c12_00,FF);
715 fvdw = _mm_xor_pd(signbit,_mm_mul_pd(_mm_add_pd(fvdw6,fvdw12),_mm_mul_pd(vftabscale,rinv00)));
717 fscal = _mm_add_pd(felec,fvdw);
719 fscal = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
721 /* Calculate temporary vectorial force */
722 tx = _mm_mul_pd(fscal,dx00);
723 ty = _mm_mul_pd(fscal,dy00);
724 tz = _mm_mul_pd(fscal,dz00);
726 /* Update vectorial force */
727 fix0 = _mm_add_pd(fix0,tx);
728 fiy0 = _mm_add_pd(fiy0,ty);
729 fiz0 = _mm_add_pd(fiz0,tz);
731 gmx_mm_decrement_1rvec_1ptr_swizzle_pd(f+j_coord_offsetA,tx,ty,tz);
733 /* Inner loop uses 62 flops */
736 /* End of innermost loop */
738 gmx_mm_update_iforce_1atom_swizzle_pd(fix0,fiy0,fiz0,
739 f+i_coord_offset,fshift+i_shift_offset);
741 /* Increment number of inner iterations */
742 inneriter += j_index_end - j_index_start;
744 /* Outer loop uses 7 flops */
747 /* Increment number of outer iterations */
750 /* Update outer/inner flops */
752 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*62);