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_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
49 #include "gmx_math_x86_sse2_single.h"
50 #include "kernelutil_x86_sse2_single.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwNone_GeomP1P1_VF_sse2_single
54 * Electrostatics interaction: CubicSplineTable
55 * VdW interaction: None
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecCSTab_VdwNone_GeomP1P1_VF_sse2_single
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,C,D refer to j loop unrolling done with SSE, e.g. for the four 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;
76 int jnrA,jnrB,jnrC,jnrD;
77 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
78 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
79 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
81 real *shiftvec,*fshift,*x,*f;
82 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
84 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
86 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
87 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
88 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
90 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
93 __m128i ifour = _mm_set1_epi32(4);
94 __m128 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
96 __m128 dummy_mask,cutoff_mask;
97 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
98 __m128 one = _mm_set1_ps(1.0);
99 __m128 two = _mm_set1_ps(2.0);
105 jindex = nlist->jindex;
107 shiftidx = nlist->shift;
109 shiftvec = fr->shift_vec[0];
110 fshift = fr->fshift[0];
111 facel = _mm_set1_ps(fr->epsfac);
112 charge = mdatoms->chargeA;
114 vftab = kernel_data->table_elec->data;
115 vftabscale = _mm_set1_ps(kernel_data->table_elec->scale);
117 /* Avoid stupid compiler warnings */
118 jnrA = jnrB = jnrC = jnrD = 0;
127 for(iidx=0;iidx<4*DIM;iidx++)
132 /* Start outer loop over neighborlists */
133 for(iidx=0; iidx<nri; iidx++)
135 /* Load shift vector for this list */
136 i_shift_offset = DIM*shiftidx[iidx];
138 /* Load limits for loop over neighbors */
139 j_index_start = jindex[iidx];
140 j_index_end = jindex[iidx+1];
142 /* Get outer coordinate index */
144 i_coord_offset = DIM*inr;
146 /* Load i particle coords and add shift vector */
147 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
149 fix0 = _mm_setzero_ps();
150 fiy0 = _mm_setzero_ps();
151 fiz0 = _mm_setzero_ps();
153 /* Load parameters for i particles */
154 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
156 /* Reset potential sums */
157 velecsum = _mm_setzero_ps();
159 /* Start inner kernel loop */
160 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
163 /* Get j neighbor index, and coordinate index */
168 j_coord_offsetA = DIM*jnrA;
169 j_coord_offsetB = DIM*jnrB;
170 j_coord_offsetC = DIM*jnrC;
171 j_coord_offsetD = DIM*jnrD;
173 /* load j atom coordinates */
174 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
175 x+j_coord_offsetC,x+j_coord_offsetD,
178 /* Calculate displacement vector */
179 dx00 = _mm_sub_ps(ix0,jx0);
180 dy00 = _mm_sub_ps(iy0,jy0);
181 dz00 = _mm_sub_ps(iz0,jz0);
183 /* Calculate squared distance and things based on it */
184 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
186 rinv00 = gmx_mm_invsqrt_ps(rsq00);
188 /* Load parameters for j particles */
189 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
190 charge+jnrC+0,charge+jnrD+0);
192 /**************************
193 * CALCULATE INTERACTIONS *
194 **************************/
196 r00 = _mm_mul_ps(rsq00,rinv00);
198 /* Compute parameters for interactions between i and j atoms */
199 qq00 = _mm_mul_ps(iq0,jq0);
201 /* Calculate table index by multiplying r with table scale and truncate to integer */
202 rt = _mm_mul_ps(r00,vftabscale);
203 vfitab = _mm_cvttps_epi32(rt);
204 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
205 vfitab = _mm_slli_epi32(vfitab,2);
207 /* CUBIC SPLINE TABLE ELECTROSTATICS */
208 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
209 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
210 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
211 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
212 _MM_TRANSPOSE4_PS(Y,F,G,H);
213 Heps = _mm_mul_ps(vfeps,H);
214 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
215 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
216 velec = _mm_mul_ps(qq00,VV);
217 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
218 felec = _mm_xor_ps(signbit,_mm_mul_ps(_mm_mul_ps(qq00,FF),_mm_mul_ps(vftabscale,rinv00)));
220 /* Update potential sum for this i atom from the interaction with this j atom. */
221 velecsum = _mm_add_ps(velecsum,velec);
225 /* Calculate temporary vectorial force */
226 tx = _mm_mul_ps(fscal,dx00);
227 ty = _mm_mul_ps(fscal,dy00);
228 tz = _mm_mul_ps(fscal,dz00);
230 /* Update vectorial force */
231 fix0 = _mm_add_ps(fix0,tx);
232 fiy0 = _mm_add_ps(fiy0,ty);
233 fiz0 = _mm_add_ps(fiz0,tz);
235 fjptrA = f+j_coord_offsetA;
236 fjptrB = f+j_coord_offsetB;
237 fjptrC = f+j_coord_offsetC;
238 fjptrD = f+j_coord_offsetD;
239 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
241 /* Inner loop uses 43 flops */
247 /* Get j neighbor index, and coordinate index */
248 jnrlistA = jjnr[jidx];
249 jnrlistB = jjnr[jidx+1];
250 jnrlistC = jjnr[jidx+2];
251 jnrlistD = jjnr[jidx+3];
252 /* Sign of each element will be negative for non-real atoms.
253 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
254 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
256 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
257 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
258 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
259 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
260 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
261 j_coord_offsetA = DIM*jnrA;
262 j_coord_offsetB = DIM*jnrB;
263 j_coord_offsetC = DIM*jnrC;
264 j_coord_offsetD = DIM*jnrD;
266 /* load j atom coordinates */
267 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
268 x+j_coord_offsetC,x+j_coord_offsetD,
271 /* Calculate displacement vector */
272 dx00 = _mm_sub_ps(ix0,jx0);
273 dy00 = _mm_sub_ps(iy0,jy0);
274 dz00 = _mm_sub_ps(iz0,jz0);
276 /* Calculate squared distance and things based on it */
277 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
279 rinv00 = gmx_mm_invsqrt_ps(rsq00);
281 /* Load parameters for j particles */
282 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
283 charge+jnrC+0,charge+jnrD+0);
285 /**************************
286 * CALCULATE INTERACTIONS *
287 **************************/
289 r00 = _mm_mul_ps(rsq00,rinv00);
290 r00 = _mm_andnot_ps(dummy_mask,r00);
292 /* Compute parameters for interactions between i and j atoms */
293 qq00 = _mm_mul_ps(iq0,jq0);
295 /* Calculate table index by multiplying r with table scale and truncate to integer */
296 rt = _mm_mul_ps(r00,vftabscale);
297 vfitab = _mm_cvttps_epi32(rt);
298 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
299 vfitab = _mm_slli_epi32(vfitab,2);
301 /* CUBIC SPLINE TABLE ELECTROSTATICS */
302 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
303 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
304 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
305 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
306 _MM_TRANSPOSE4_PS(Y,F,G,H);
307 Heps = _mm_mul_ps(vfeps,H);
308 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
309 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
310 velec = _mm_mul_ps(qq00,VV);
311 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
312 felec = _mm_xor_ps(signbit,_mm_mul_ps(_mm_mul_ps(qq00,FF),_mm_mul_ps(vftabscale,rinv00)));
314 /* Update potential sum for this i atom from the interaction with this j atom. */
315 velec = _mm_andnot_ps(dummy_mask,velec);
316 velecsum = _mm_add_ps(velecsum,velec);
320 fscal = _mm_andnot_ps(dummy_mask,fscal);
322 /* Calculate temporary vectorial force */
323 tx = _mm_mul_ps(fscal,dx00);
324 ty = _mm_mul_ps(fscal,dy00);
325 tz = _mm_mul_ps(fscal,dz00);
327 /* Update vectorial force */
328 fix0 = _mm_add_ps(fix0,tx);
329 fiy0 = _mm_add_ps(fiy0,ty);
330 fiz0 = _mm_add_ps(fiz0,tz);
332 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
333 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
334 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
335 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
336 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
338 /* Inner loop uses 44 flops */
341 /* End of innermost loop */
343 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
344 f+i_coord_offset,fshift+i_shift_offset);
347 /* Update potential energies */
348 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
350 /* Increment number of inner iterations */
351 inneriter += j_index_end - j_index_start;
353 /* Outer loop uses 8 flops */
356 /* Increment number of outer iterations */
359 /* Update outer/inner flops */
361 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VF,outeriter*8 + inneriter*44);
364 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwNone_GeomP1P1_F_sse2_single
365 * Electrostatics interaction: CubicSplineTable
366 * VdW interaction: None
367 * Geometry: Particle-Particle
368 * Calculate force/pot: Force
371 nb_kernel_ElecCSTab_VdwNone_GeomP1P1_F_sse2_single
372 (t_nblist * gmx_restrict nlist,
373 rvec * gmx_restrict xx,
374 rvec * gmx_restrict ff,
375 t_forcerec * gmx_restrict fr,
376 t_mdatoms * gmx_restrict mdatoms,
377 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
378 t_nrnb * gmx_restrict nrnb)
380 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
381 * just 0 for non-waters.
382 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
383 * jnr indices corresponding to data put in the four positions in the SIMD register.
385 int i_shift_offset,i_coord_offset,outeriter,inneriter;
386 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
387 int jnrA,jnrB,jnrC,jnrD;
388 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
389 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
390 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
392 real *shiftvec,*fshift,*x,*f;
393 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
395 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
397 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
398 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
399 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
400 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
401 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
404 __m128i ifour = _mm_set1_epi32(4);
405 __m128 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
407 __m128 dummy_mask,cutoff_mask;
408 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
409 __m128 one = _mm_set1_ps(1.0);
410 __m128 two = _mm_set1_ps(2.0);
416 jindex = nlist->jindex;
418 shiftidx = nlist->shift;
420 shiftvec = fr->shift_vec[0];
421 fshift = fr->fshift[0];
422 facel = _mm_set1_ps(fr->epsfac);
423 charge = mdatoms->chargeA;
425 vftab = kernel_data->table_elec->data;
426 vftabscale = _mm_set1_ps(kernel_data->table_elec->scale);
428 /* Avoid stupid compiler warnings */
429 jnrA = jnrB = jnrC = jnrD = 0;
438 for(iidx=0;iidx<4*DIM;iidx++)
443 /* Start outer loop over neighborlists */
444 for(iidx=0; iidx<nri; iidx++)
446 /* Load shift vector for this list */
447 i_shift_offset = DIM*shiftidx[iidx];
449 /* Load limits for loop over neighbors */
450 j_index_start = jindex[iidx];
451 j_index_end = jindex[iidx+1];
453 /* Get outer coordinate index */
455 i_coord_offset = DIM*inr;
457 /* Load i particle coords and add shift vector */
458 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
460 fix0 = _mm_setzero_ps();
461 fiy0 = _mm_setzero_ps();
462 fiz0 = _mm_setzero_ps();
464 /* Load parameters for i particles */
465 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
467 /* Start inner kernel loop */
468 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
471 /* Get j neighbor index, and coordinate index */
476 j_coord_offsetA = DIM*jnrA;
477 j_coord_offsetB = DIM*jnrB;
478 j_coord_offsetC = DIM*jnrC;
479 j_coord_offsetD = DIM*jnrD;
481 /* load j atom coordinates */
482 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
483 x+j_coord_offsetC,x+j_coord_offsetD,
486 /* Calculate displacement vector */
487 dx00 = _mm_sub_ps(ix0,jx0);
488 dy00 = _mm_sub_ps(iy0,jy0);
489 dz00 = _mm_sub_ps(iz0,jz0);
491 /* Calculate squared distance and things based on it */
492 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
494 rinv00 = gmx_mm_invsqrt_ps(rsq00);
496 /* Load parameters for j particles */
497 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
498 charge+jnrC+0,charge+jnrD+0);
500 /**************************
501 * CALCULATE INTERACTIONS *
502 **************************/
504 r00 = _mm_mul_ps(rsq00,rinv00);
506 /* Compute parameters for interactions between i and j atoms */
507 qq00 = _mm_mul_ps(iq0,jq0);
509 /* Calculate table index by multiplying r with table scale and truncate to integer */
510 rt = _mm_mul_ps(r00,vftabscale);
511 vfitab = _mm_cvttps_epi32(rt);
512 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
513 vfitab = _mm_slli_epi32(vfitab,2);
515 /* CUBIC SPLINE TABLE ELECTROSTATICS */
516 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
517 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
518 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
519 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
520 _MM_TRANSPOSE4_PS(Y,F,G,H);
521 Heps = _mm_mul_ps(vfeps,H);
522 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
523 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
524 felec = _mm_xor_ps(signbit,_mm_mul_ps(_mm_mul_ps(qq00,FF),_mm_mul_ps(vftabscale,rinv00)));
528 /* Calculate temporary vectorial force */
529 tx = _mm_mul_ps(fscal,dx00);
530 ty = _mm_mul_ps(fscal,dy00);
531 tz = _mm_mul_ps(fscal,dz00);
533 /* Update vectorial force */
534 fix0 = _mm_add_ps(fix0,tx);
535 fiy0 = _mm_add_ps(fiy0,ty);
536 fiz0 = _mm_add_ps(fiz0,tz);
538 fjptrA = f+j_coord_offsetA;
539 fjptrB = f+j_coord_offsetB;
540 fjptrC = f+j_coord_offsetC;
541 fjptrD = f+j_coord_offsetD;
542 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
544 /* Inner loop uses 39 flops */
550 /* Get j neighbor index, and coordinate index */
551 jnrlistA = jjnr[jidx];
552 jnrlistB = jjnr[jidx+1];
553 jnrlistC = jjnr[jidx+2];
554 jnrlistD = jjnr[jidx+3];
555 /* Sign of each element will be negative for non-real atoms.
556 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
557 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
559 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
560 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
561 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
562 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
563 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
564 j_coord_offsetA = DIM*jnrA;
565 j_coord_offsetB = DIM*jnrB;
566 j_coord_offsetC = DIM*jnrC;
567 j_coord_offsetD = DIM*jnrD;
569 /* load j atom coordinates */
570 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
571 x+j_coord_offsetC,x+j_coord_offsetD,
574 /* Calculate displacement vector */
575 dx00 = _mm_sub_ps(ix0,jx0);
576 dy00 = _mm_sub_ps(iy0,jy0);
577 dz00 = _mm_sub_ps(iz0,jz0);
579 /* Calculate squared distance and things based on it */
580 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
582 rinv00 = gmx_mm_invsqrt_ps(rsq00);
584 /* Load parameters for j particles */
585 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
586 charge+jnrC+0,charge+jnrD+0);
588 /**************************
589 * CALCULATE INTERACTIONS *
590 **************************/
592 r00 = _mm_mul_ps(rsq00,rinv00);
593 r00 = _mm_andnot_ps(dummy_mask,r00);
595 /* Compute parameters for interactions between i and j atoms */
596 qq00 = _mm_mul_ps(iq0,jq0);
598 /* Calculate table index by multiplying r with table scale and truncate to integer */
599 rt = _mm_mul_ps(r00,vftabscale);
600 vfitab = _mm_cvttps_epi32(rt);
601 vfeps = _mm_sub_ps(rt,_mm_cvtepi32_ps(vfitab));
602 vfitab = _mm_slli_epi32(vfitab,2);
604 /* CUBIC SPLINE TABLE ELECTROSTATICS */
605 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0) );
606 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1) );
607 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2) );
608 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3) );
609 _MM_TRANSPOSE4_PS(Y,F,G,H);
610 Heps = _mm_mul_ps(vfeps,H);
611 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
612 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
613 felec = _mm_xor_ps(signbit,_mm_mul_ps(_mm_mul_ps(qq00,FF),_mm_mul_ps(vftabscale,rinv00)));
617 fscal = _mm_andnot_ps(dummy_mask,fscal);
619 /* Calculate temporary vectorial force */
620 tx = _mm_mul_ps(fscal,dx00);
621 ty = _mm_mul_ps(fscal,dy00);
622 tz = _mm_mul_ps(fscal,dz00);
624 /* Update vectorial force */
625 fix0 = _mm_add_ps(fix0,tx);
626 fiy0 = _mm_add_ps(fiy0,ty);
627 fiz0 = _mm_add_ps(fiz0,tz);
629 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
630 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
631 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
632 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
633 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
635 /* Inner loop uses 40 flops */
638 /* End of innermost loop */
640 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
641 f+i_coord_offset,fshift+i_shift_offset);
643 /* Increment number of inner iterations */
644 inneriter += j_index_end - j_index_start;
646 /* Outer loop uses 7 flops */
649 /* Increment number of outer iterations */
652 /* Update outer/inner flops */
654 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_F,outeriter*7 + inneriter*40);