2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017,2018, 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 "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_sse2_single.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4W4_VF_sse2_single
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: None
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_VdwNone_GeomW4W4_VF_sse2_single
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,C,D refer to j loop unrolling done with SSE, e.g. for the four 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;
73 int jnrA,jnrB,jnrC,jnrD;
74 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
75 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
81 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
83 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
85 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
87 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
88 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
89 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
90 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
91 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
92 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D;
93 __m128 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
94 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
95 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
96 __m128 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
97 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
98 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
99 __m128 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
100 __m128 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
101 __m128 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
102 __m128 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
103 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
105 __m128 dummy_mask,cutoff_mask;
106 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
107 __m128 one = _mm_set1_ps(1.0);
108 __m128 two = _mm_set1_ps(2.0);
114 jindex = nlist->jindex;
116 shiftidx = nlist->shift;
118 shiftvec = fr->shift_vec[0];
119 fshift = fr->fshift[0];
120 facel = _mm_set1_ps(fr->ic->epsfac);
121 charge = mdatoms->chargeA;
122 krf = _mm_set1_ps(fr->ic->k_rf);
123 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
124 crf = _mm_set1_ps(fr->ic->c_rf);
126 /* Setup water-specific parameters */
127 inr = nlist->iinr[0];
128 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
129 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
130 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
132 jq1 = _mm_set1_ps(charge[inr+1]);
133 jq2 = _mm_set1_ps(charge[inr+2]);
134 jq3 = _mm_set1_ps(charge[inr+3]);
135 qq11 = _mm_mul_ps(iq1,jq1);
136 qq12 = _mm_mul_ps(iq1,jq2);
137 qq13 = _mm_mul_ps(iq1,jq3);
138 qq21 = _mm_mul_ps(iq2,jq1);
139 qq22 = _mm_mul_ps(iq2,jq2);
140 qq23 = _mm_mul_ps(iq2,jq3);
141 qq31 = _mm_mul_ps(iq3,jq1);
142 qq32 = _mm_mul_ps(iq3,jq2);
143 qq33 = _mm_mul_ps(iq3,jq3);
145 /* Avoid stupid compiler warnings */
146 jnrA = jnrB = jnrC = jnrD = 0;
155 for(iidx=0;iidx<4*DIM;iidx++)
160 /* Start outer loop over neighborlists */
161 for(iidx=0; iidx<nri; iidx++)
163 /* Load shift vector for this list */
164 i_shift_offset = DIM*shiftidx[iidx];
166 /* Load limits for loop over neighbors */
167 j_index_start = jindex[iidx];
168 j_index_end = jindex[iidx+1];
170 /* Get outer coordinate index */
172 i_coord_offset = DIM*inr;
174 /* Load i particle coords and add shift vector */
175 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
176 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
178 fix1 = _mm_setzero_ps();
179 fiy1 = _mm_setzero_ps();
180 fiz1 = _mm_setzero_ps();
181 fix2 = _mm_setzero_ps();
182 fiy2 = _mm_setzero_ps();
183 fiz2 = _mm_setzero_ps();
184 fix3 = _mm_setzero_ps();
185 fiy3 = _mm_setzero_ps();
186 fiz3 = _mm_setzero_ps();
188 /* Reset potential sums */
189 velecsum = _mm_setzero_ps();
191 /* Start inner kernel loop */
192 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
195 /* Get j neighbor index, and coordinate index */
200 j_coord_offsetA = DIM*jnrA;
201 j_coord_offsetB = DIM*jnrB;
202 j_coord_offsetC = DIM*jnrC;
203 j_coord_offsetD = DIM*jnrD;
205 /* load j atom coordinates */
206 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
207 x+j_coord_offsetC+DIM,x+j_coord_offsetD+DIM,
208 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
210 /* Calculate displacement vector */
211 dx11 = _mm_sub_ps(ix1,jx1);
212 dy11 = _mm_sub_ps(iy1,jy1);
213 dz11 = _mm_sub_ps(iz1,jz1);
214 dx12 = _mm_sub_ps(ix1,jx2);
215 dy12 = _mm_sub_ps(iy1,jy2);
216 dz12 = _mm_sub_ps(iz1,jz2);
217 dx13 = _mm_sub_ps(ix1,jx3);
218 dy13 = _mm_sub_ps(iy1,jy3);
219 dz13 = _mm_sub_ps(iz1,jz3);
220 dx21 = _mm_sub_ps(ix2,jx1);
221 dy21 = _mm_sub_ps(iy2,jy1);
222 dz21 = _mm_sub_ps(iz2,jz1);
223 dx22 = _mm_sub_ps(ix2,jx2);
224 dy22 = _mm_sub_ps(iy2,jy2);
225 dz22 = _mm_sub_ps(iz2,jz2);
226 dx23 = _mm_sub_ps(ix2,jx3);
227 dy23 = _mm_sub_ps(iy2,jy3);
228 dz23 = _mm_sub_ps(iz2,jz3);
229 dx31 = _mm_sub_ps(ix3,jx1);
230 dy31 = _mm_sub_ps(iy3,jy1);
231 dz31 = _mm_sub_ps(iz3,jz1);
232 dx32 = _mm_sub_ps(ix3,jx2);
233 dy32 = _mm_sub_ps(iy3,jy2);
234 dz32 = _mm_sub_ps(iz3,jz2);
235 dx33 = _mm_sub_ps(ix3,jx3);
236 dy33 = _mm_sub_ps(iy3,jy3);
237 dz33 = _mm_sub_ps(iz3,jz3);
239 /* Calculate squared distance and things based on it */
240 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
241 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
242 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
243 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
244 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
245 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
246 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
247 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
248 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
250 rinv11 = sse2_invsqrt_f(rsq11);
251 rinv12 = sse2_invsqrt_f(rsq12);
252 rinv13 = sse2_invsqrt_f(rsq13);
253 rinv21 = sse2_invsqrt_f(rsq21);
254 rinv22 = sse2_invsqrt_f(rsq22);
255 rinv23 = sse2_invsqrt_f(rsq23);
256 rinv31 = sse2_invsqrt_f(rsq31);
257 rinv32 = sse2_invsqrt_f(rsq32);
258 rinv33 = sse2_invsqrt_f(rsq33);
260 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
261 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
262 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
263 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
264 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
265 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
266 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
267 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
268 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
270 fjx1 = _mm_setzero_ps();
271 fjy1 = _mm_setzero_ps();
272 fjz1 = _mm_setzero_ps();
273 fjx2 = _mm_setzero_ps();
274 fjy2 = _mm_setzero_ps();
275 fjz2 = _mm_setzero_ps();
276 fjx3 = _mm_setzero_ps();
277 fjy3 = _mm_setzero_ps();
278 fjz3 = _mm_setzero_ps();
280 /**************************
281 * CALCULATE INTERACTIONS *
282 **************************/
284 /* REACTION-FIELD ELECTROSTATICS */
285 velec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_add_ps(rinv11,_mm_mul_ps(krf,rsq11)),crf));
286 felec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
288 /* Update potential sum for this i atom from the interaction with this j atom. */
289 velecsum = _mm_add_ps(velecsum,velec);
293 /* Calculate temporary vectorial force */
294 tx = _mm_mul_ps(fscal,dx11);
295 ty = _mm_mul_ps(fscal,dy11);
296 tz = _mm_mul_ps(fscal,dz11);
298 /* Update vectorial force */
299 fix1 = _mm_add_ps(fix1,tx);
300 fiy1 = _mm_add_ps(fiy1,ty);
301 fiz1 = _mm_add_ps(fiz1,tz);
303 fjx1 = _mm_add_ps(fjx1,tx);
304 fjy1 = _mm_add_ps(fjy1,ty);
305 fjz1 = _mm_add_ps(fjz1,tz);
307 /**************************
308 * CALCULATE INTERACTIONS *
309 **************************/
311 /* REACTION-FIELD ELECTROSTATICS */
312 velec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_add_ps(rinv12,_mm_mul_ps(krf,rsq12)),crf));
313 felec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
315 /* Update potential sum for this i atom from the interaction with this j atom. */
316 velecsum = _mm_add_ps(velecsum,velec);
320 /* Calculate temporary vectorial force */
321 tx = _mm_mul_ps(fscal,dx12);
322 ty = _mm_mul_ps(fscal,dy12);
323 tz = _mm_mul_ps(fscal,dz12);
325 /* Update vectorial force */
326 fix1 = _mm_add_ps(fix1,tx);
327 fiy1 = _mm_add_ps(fiy1,ty);
328 fiz1 = _mm_add_ps(fiz1,tz);
330 fjx2 = _mm_add_ps(fjx2,tx);
331 fjy2 = _mm_add_ps(fjy2,ty);
332 fjz2 = _mm_add_ps(fjz2,tz);
334 /**************************
335 * CALCULATE INTERACTIONS *
336 **************************/
338 /* REACTION-FIELD ELECTROSTATICS */
339 velec = _mm_mul_ps(qq13,_mm_sub_ps(_mm_add_ps(rinv13,_mm_mul_ps(krf,rsq13)),crf));
340 felec = _mm_mul_ps(qq13,_mm_sub_ps(_mm_mul_ps(rinv13,rinvsq13),krf2));
342 /* Update potential sum for this i atom from the interaction with this j atom. */
343 velecsum = _mm_add_ps(velecsum,velec);
347 /* Calculate temporary vectorial force */
348 tx = _mm_mul_ps(fscal,dx13);
349 ty = _mm_mul_ps(fscal,dy13);
350 tz = _mm_mul_ps(fscal,dz13);
352 /* Update vectorial force */
353 fix1 = _mm_add_ps(fix1,tx);
354 fiy1 = _mm_add_ps(fiy1,ty);
355 fiz1 = _mm_add_ps(fiz1,tz);
357 fjx3 = _mm_add_ps(fjx3,tx);
358 fjy3 = _mm_add_ps(fjy3,ty);
359 fjz3 = _mm_add_ps(fjz3,tz);
361 /**************************
362 * CALCULATE INTERACTIONS *
363 **************************/
365 /* REACTION-FIELD ELECTROSTATICS */
366 velec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_add_ps(rinv21,_mm_mul_ps(krf,rsq21)),crf));
367 felec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
369 /* Update potential sum for this i atom from the interaction with this j atom. */
370 velecsum = _mm_add_ps(velecsum,velec);
374 /* Calculate temporary vectorial force */
375 tx = _mm_mul_ps(fscal,dx21);
376 ty = _mm_mul_ps(fscal,dy21);
377 tz = _mm_mul_ps(fscal,dz21);
379 /* Update vectorial force */
380 fix2 = _mm_add_ps(fix2,tx);
381 fiy2 = _mm_add_ps(fiy2,ty);
382 fiz2 = _mm_add_ps(fiz2,tz);
384 fjx1 = _mm_add_ps(fjx1,tx);
385 fjy1 = _mm_add_ps(fjy1,ty);
386 fjz1 = _mm_add_ps(fjz1,tz);
388 /**************************
389 * CALCULATE INTERACTIONS *
390 **************************/
392 /* REACTION-FIELD ELECTROSTATICS */
393 velec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_add_ps(rinv22,_mm_mul_ps(krf,rsq22)),crf));
394 felec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
396 /* Update potential sum for this i atom from the interaction with this j atom. */
397 velecsum = _mm_add_ps(velecsum,velec);
401 /* Calculate temporary vectorial force */
402 tx = _mm_mul_ps(fscal,dx22);
403 ty = _mm_mul_ps(fscal,dy22);
404 tz = _mm_mul_ps(fscal,dz22);
406 /* Update vectorial force */
407 fix2 = _mm_add_ps(fix2,tx);
408 fiy2 = _mm_add_ps(fiy2,ty);
409 fiz2 = _mm_add_ps(fiz2,tz);
411 fjx2 = _mm_add_ps(fjx2,tx);
412 fjy2 = _mm_add_ps(fjy2,ty);
413 fjz2 = _mm_add_ps(fjz2,tz);
415 /**************************
416 * CALCULATE INTERACTIONS *
417 **************************/
419 /* REACTION-FIELD ELECTROSTATICS */
420 velec = _mm_mul_ps(qq23,_mm_sub_ps(_mm_add_ps(rinv23,_mm_mul_ps(krf,rsq23)),crf));
421 felec = _mm_mul_ps(qq23,_mm_sub_ps(_mm_mul_ps(rinv23,rinvsq23),krf2));
423 /* Update potential sum for this i atom from the interaction with this j atom. */
424 velecsum = _mm_add_ps(velecsum,velec);
428 /* Calculate temporary vectorial force */
429 tx = _mm_mul_ps(fscal,dx23);
430 ty = _mm_mul_ps(fscal,dy23);
431 tz = _mm_mul_ps(fscal,dz23);
433 /* Update vectorial force */
434 fix2 = _mm_add_ps(fix2,tx);
435 fiy2 = _mm_add_ps(fiy2,ty);
436 fiz2 = _mm_add_ps(fiz2,tz);
438 fjx3 = _mm_add_ps(fjx3,tx);
439 fjy3 = _mm_add_ps(fjy3,ty);
440 fjz3 = _mm_add_ps(fjz3,tz);
442 /**************************
443 * CALCULATE INTERACTIONS *
444 **************************/
446 /* REACTION-FIELD ELECTROSTATICS */
447 velec = _mm_mul_ps(qq31,_mm_sub_ps(_mm_add_ps(rinv31,_mm_mul_ps(krf,rsq31)),crf));
448 felec = _mm_mul_ps(qq31,_mm_sub_ps(_mm_mul_ps(rinv31,rinvsq31),krf2));
450 /* Update potential sum for this i atom from the interaction with this j atom. */
451 velecsum = _mm_add_ps(velecsum,velec);
455 /* Calculate temporary vectorial force */
456 tx = _mm_mul_ps(fscal,dx31);
457 ty = _mm_mul_ps(fscal,dy31);
458 tz = _mm_mul_ps(fscal,dz31);
460 /* Update vectorial force */
461 fix3 = _mm_add_ps(fix3,tx);
462 fiy3 = _mm_add_ps(fiy3,ty);
463 fiz3 = _mm_add_ps(fiz3,tz);
465 fjx1 = _mm_add_ps(fjx1,tx);
466 fjy1 = _mm_add_ps(fjy1,ty);
467 fjz1 = _mm_add_ps(fjz1,tz);
469 /**************************
470 * CALCULATE INTERACTIONS *
471 **************************/
473 /* REACTION-FIELD ELECTROSTATICS */
474 velec = _mm_mul_ps(qq32,_mm_sub_ps(_mm_add_ps(rinv32,_mm_mul_ps(krf,rsq32)),crf));
475 felec = _mm_mul_ps(qq32,_mm_sub_ps(_mm_mul_ps(rinv32,rinvsq32),krf2));
477 /* Update potential sum for this i atom from the interaction with this j atom. */
478 velecsum = _mm_add_ps(velecsum,velec);
482 /* Calculate temporary vectorial force */
483 tx = _mm_mul_ps(fscal,dx32);
484 ty = _mm_mul_ps(fscal,dy32);
485 tz = _mm_mul_ps(fscal,dz32);
487 /* Update vectorial force */
488 fix3 = _mm_add_ps(fix3,tx);
489 fiy3 = _mm_add_ps(fiy3,ty);
490 fiz3 = _mm_add_ps(fiz3,tz);
492 fjx2 = _mm_add_ps(fjx2,tx);
493 fjy2 = _mm_add_ps(fjy2,ty);
494 fjz2 = _mm_add_ps(fjz2,tz);
496 /**************************
497 * CALCULATE INTERACTIONS *
498 **************************/
500 /* REACTION-FIELD ELECTROSTATICS */
501 velec = _mm_mul_ps(qq33,_mm_sub_ps(_mm_add_ps(rinv33,_mm_mul_ps(krf,rsq33)),crf));
502 felec = _mm_mul_ps(qq33,_mm_sub_ps(_mm_mul_ps(rinv33,rinvsq33),krf2));
504 /* Update potential sum for this i atom from the interaction with this j atom. */
505 velecsum = _mm_add_ps(velecsum,velec);
509 /* Calculate temporary vectorial force */
510 tx = _mm_mul_ps(fscal,dx33);
511 ty = _mm_mul_ps(fscal,dy33);
512 tz = _mm_mul_ps(fscal,dz33);
514 /* Update vectorial force */
515 fix3 = _mm_add_ps(fix3,tx);
516 fiy3 = _mm_add_ps(fiy3,ty);
517 fiz3 = _mm_add_ps(fiz3,tz);
519 fjx3 = _mm_add_ps(fjx3,tx);
520 fjy3 = _mm_add_ps(fjy3,ty);
521 fjz3 = _mm_add_ps(fjz3,tz);
523 fjptrA = f+j_coord_offsetA;
524 fjptrB = f+j_coord_offsetB;
525 fjptrC = f+j_coord_offsetC;
526 fjptrD = f+j_coord_offsetD;
528 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA+DIM,fjptrB+DIM,fjptrC+DIM,fjptrD+DIM,
529 fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
531 /* Inner loop uses 288 flops */
537 /* Get j neighbor index, and coordinate index */
538 jnrlistA = jjnr[jidx];
539 jnrlistB = jjnr[jidx+1];
540 jnrlistC = jjnr[jidx+2];
541 jnrlistD = jjnr[jidx+3];
542 /* Sign of each element will be negative for non-real atoms.
543 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
544 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
546 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
547 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
548 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
549 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
550 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
551 j_coord_offsetA = DIM*jnrA;
552 j_coord_offsetB = DIM*jnrB;
553 j_coord_offsetC = DIM*jnrC;
554 j_coord_offsetD = DIM*jnrD;
556 /* load j atom coordinates */
557 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
558 x+j_coord_offsetC+DIM,x+j_coord_offsetD+DIM,
559 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
561 /* Calculate displacement vector */
562 dx11 = _mm_sub_ps(ix1,jx1);
563 dy11 = _mm_sub_ps(iy1,jy1);
564 dz11 = _mm_sub_ps(iz1,jz1);
565 dx12 = _mm_sub_ps(ix1,jx2);
566 dy12 = _mm_sub_ps(iy1,jy2);
567 dz12 = _mm_sub_ps(iz1,jz2);
568 dx13 = _mm_sub_ps(ix1,jx3);
569 dy13 = _mm_sub_ps(iy1,jy3);
570 dz13 = _mm_sub_ps(iz1,jz3);
571 dx21 = _mm_sub_ps(ix2,jx1);
572 dy21 = _mm_sub_ps(iy2,jy1);
573 dz21 = _mm_sub_ps(iz2,jz1);
574 dx22 = _mm_sub_ps(ix2,jx2);
575 dy22 = _mm_sub_ps(iy2,jy2);
576 dz22 = _mm_sub_ps(iz2,jz2);
577 dx23 = _mm_sub_ps(ix2,jx3);
578 dy23 = _mm_sub_ps(iy2,jy3);
579 dz23 = _mm_sub_ps(iz2,jz3);
580 dx31 = _mm_sub_ps(ix3,jx1);
581 dy31 = _mm_sub_ps(iy3,jy1);
582 dz31 = _mm_sub_ps(iz3,jz1);
583 dx32 = _mm_sub_ps(ix3,jx2);
584 dy32 = _mm_sub_ps(iy3,jy2);
585 dz32 = _mm_sub_ps(iz3,jz2);
586 dx33 = _mm_sub_ps(ix3,jx3);
587 dy33 = _mm_sub_ps(iy3,jy3);
588 dz33 = _mm_sub_ps(iz3,jz3);
590 /* Calculate squared distance and things based on it */
591 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
592 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
593 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
594 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
595 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
596 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
597 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
598 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
599 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
601 rinv11 = sse2_invsqrt_f(rsq11);
602 rinv12 = sse2_invsqrt_f(rsq12);
603 rinv13 = sse2_invsqrt_f(rsq13);
604 rinv21 = sse2_invsqrt_f(rsq21);
605 rinv22 = sse2_invsqrt_f(rsq22);
606 rinv23 = sse2_invsqrt_f(rsq23);
607 rinv31 = sse2_invsqrt_f(rsq31);
608 rinv32 = sse2_invsqrt_f(rsq32);
609 rinv33 = sse2_invsqrt_f(rsq33);
611 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
612 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
613 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
614 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
615 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
616 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
617 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
618 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
619 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
621 fjx1 = _mm_setzero_ps();
622 fjy1 = _mm_setzero_ps();
623 fjz1 = _mm_setzero_ps();
624 fjx2 = _mm_setzero_ps();
625 fjy2 = _mm_setzero_ps();
626 fjz2 = _mm_setzero_ps();
627 fjx3 = _mm_setzero_ps();
628 fjy3 = _mm_setzero_ps();
629 fjz3 = _mm_setzero_ps();
631 /**************************
632 * CALCULATE INTERACTIONS *
633 **************************/
635 /* REACTION-FIELD ELECTROSTATICS */
636 velec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_add_ps(rinv11,_mm_mul_ps(krf,rsq11)),crf));
637 felec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
639 /* Update potential sum for this i atom from the interaction with this j atom. */
640 velec = _mm_andnot_ps(dummy_mask,velec);
641 velecsum = _mm_add_ps(velecsum,velec);
645 fscal = _mm_andnot_ps(dummy_mask,fscal);
647 /* Calculate temporary vectorial force */
648 tx = _mm_mul_ps(fscal,dx11);
649 ty = _mm_mul_ps(fscal,dy11);
650 tz = _mm_mul_ps(fscal,dz11);
652 /* Update vectorial force */
653 fix1 = _mm_add_ps(fix1,tx);
654 fiy1 = _mm_add_ps(fiy1,ty);
655 fiz1 = _mm_add_ps(fiz1,tz);
657 fjx1 = _mm_add_ps(fjx1,tx);
658 fjy1 = _mm_add_ps(fjy1,ty);
659 fjz1 = _mm_add_ps(fjz1,tz);
661 /**************************
662 * CALCULATE INTERACTIONS *
663 **************************/
665 /* REACTION-FIELD ELECTROSTATICS */
666 velec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_add_ps(rinv12,_mm_mul_ps(krf,rsq12)),crf));
667 felec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
669 /* Update potential sum for this i atom from the interaction with this j atom. */
670 velec = _mm_andnot_ps(dummy_mask,velec);
671 velecsum = _mm_add_ps(velecsum,velec);
675 fscal = _mm_andnot_ps(dummy_mask,fscal);
677 /* Calculate temporary vectorial force */
678 tx = _mm_mul_ps(fscal,dx12);
679 ty = _mm_mul_ps(fscal,dy12);
680 tz = _mm_mul_ps(fscal,dz12);
682 /* Update vectorial force */
683 fix1 = _mm_add_ps(fix1,tx);
684 fiy1 = _mm_add_ps(fiy1,ty);
685 fiz1 = _mm_add_ps(fiz1,tz);
687 fjx2 = _mm_add_ps(fjx2,tx);
688 fjy2 = _mm_add_ps(fjy2,ty);
689 fjz2 = _mm_add_ps(fjz2,tz);
691 /**************************
692 * CALCULATE INTERACTIONS *
693 **************************/
695 /* REACTION-FIELD ELECTROSTATICS */
696 velec = _mm_mul_ps(qq13,_mm_sub_ps(_mm_add_ps(rinv13,_mm_mul_ps(krf,rsq13)),crf));
697 felec = _mm_mul_ps(qq13,_mm_sub_ps(_mm_mul_ps(rinv13,rinvsq13),krf2));
699 /* Update potential sum for this i atom from the interaction with this j atom. */
700 velec = _mm_andnot_ps(dummy_mask,velec);
701 velecsum = _mm_add_ps(velecsum,velec);
705 fscal = _mm_andnot_ps(dummy_mask,fscal);
707 /* Calculate temporary vectorial force */
708 tx = _mm_mul_ps(fscal,dx13);
709 ty = _mm_mul_ps(fscal,dy13);
710 tz = _mm_mul_ps(fscal,dz13);
712 /* Update vectorial force */
713 fix1 = _mm_add_ps(fix1,tx);
714 fiy1 = _mm_add_ps(fiy1,ty);
715 fiz1 = _mm_add_ps(fiz1,tz);
717 fjx3 = _mm_add_ps(fjx3,tx);
718 fjy3 = _mm_add_ps(fjy3,ty);
719 fjz3 = _mm_add_ps(fjz3,tz);
721 /**************************
722 * CALCULATE INTERACTIONS *
723 **************************/
725 /* REACTION-FIELD ELECTROSTATICS */
726 velec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_add_ps(rinv21,_mm_mul_ps(krf,rsq21)),crf));
727 felec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
729 /* Update potential sum for this i atom from the interaction with this j atom. */
730 velec = _mm_andnot_ps(dummy_mask,velec);
731 velecsum = _mm_add_ps(velecsum,velec);
735 fscal = _mm_andnot_ps(dummy_mask,fscal);
737 /* Calculate temporary vectorial force */
738 tx = _mm_mul_ps(fscal,dx21);
739 ty = _mm_mul_ps(fscal,dy21);
740 tz = _mm_mul_ps(fscal,dz21);
742 /* Update vectorial force */
743 fix2 = _mm_add_ps(fix2,tx);
744 fiy2 = _mm_add_ps(fiy2,ty);
745 fiz2 = _mm_add_ps(fiz2,tz);
747 fjx1 = _mm_add_ps(fjx1,tx);
748 fjy1 = _mm_add_ps(fjy1,ty);
749 fjz1 = _mm_add_ps(fjz1,tz);
751 /**************************
752 * CALCULATE INTERACTIONS *
753 **************************/
755 /* REACTION-FIELD ELECTROSTATICS */
756 velec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_add_ps(rinv22,_mm_mul_ps(krf,rsq22)),crf));
757 felec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
759 /* Update potential sum for this i atom from the interaction with this j atom. */
760 velec = _mm_andnot_ps(dummy_mask,velec);
761 velecsum = _mm_add_ps(velecsum,velec);
765 fscal = _mm_andnot_ps(dummy_mask,fscal);
767 /* Calculate temporary vectorial force */
768 tx = _mm_mul_ps(fscal,dx22);
769 ty = _mm_mul_ps(fscal,dy22);
770 tz = _mm_mul_ps(fscal,dz22);
772 /* Update vectorial force */
773 fix2 = _mm_add_ps(fix2,tx);
774 fiy2 = _mm_add_ps(fiy2,ty);
775 fiz2 = _mm_add_ps(fiz2,tz);
777 fjx2 = _mm_add_ps(fjx2,tx);
778 fjy2 = _mm_add_ps(fjy2,ty);
779 fjz2 = _mm_add_ps(fjz2,tz);
781 /**************************
782 * CALCULATE INTERACTIONS *
783 **************************/
785 /* REACTION-FIELD ELECTROSTATICS */
786 velec = _mm_mul_ps(qq23,_mm_sub_ps(_mm_add_ps(rinv23,_mm_mul_ps(krf,rsq23)),crf));
787 felec = _mm_mul_ps(qq23,_mm_sub_ps(_mm_mul_ps(rinv23,rinvsq23),krf2));
789 /* Update potential sum for this i atom from the interaction with this j atom. */
790 velec = _mm_andnot_ps(dummy_mask,velec);
791 velecsum = _mm_add_ps(velecsum,velec);
795 fscal = _mm_andnot_ps(dummy_mask,fscal);
797 /* Calculate temporary vectorial force */
798 tx = _mm_mul_ps(fscal,dx23);
799 ty = _mm_mul_ps(fscal,dy23);
800 tz = _mm_mul_ps(fscal,dz23);
802 /* Update vectorial force */
803 fix2 = _mm_add_ps(fix2,tx);
804 fiy2 = _mm_add_ps(fiy2,ty);
805 fiz2 = _mm_add_ps(fiz2,tz);
807 fjx3 = _mm_add_ps(fjx3,tx);
808 fjy3 = _mm_add_ps(fjy3,ty);
809 fjz3 = _mm_add_ps(fjz3,tz);
811 /**************************
812 * CALCULATE INTERACTIONS *
813 **************************/
815 /* REACTION-FIELD ELECTROSTATICS */
816 velec = _mm_mul_ps(qq31,_mm_sub_ps(_mm_add_ps(rinv31,_mm_mul_ps(krf,rsq31)),crf));
817 felec = _mm_mul_ps(qq31,_mm_sub_ps(_mm_mul_ps(rinv31,rinvsq31),krf2));
819 /* Update potential sum for this i atom from the interaction with this j atom. */
820 velec = _mm_andnot_ps(dummy_mask,velec);
821 velecsum = _mm_add_ps(velecsum,velec);
825 fscal = _mm_andnot_ps(dummy_mask,fscal);
827 /* Calculate temporary vectorial force */
828 tx = _mm_mul_ps(fscal,dx31);
829 ty = _mm_mul_ps(fscal,dy31);
830 tz = _mm_mul_ps(fscal,dz31);
832 /* Update vectorial force */
833 fix3 = _mm_add_ps(fix3,tx);
834 fiy3 = _mm_add_ps(fiy3,ty);
835 fiz3 = _mm_add_ps(fiz3,tz);
837 fjx1 = _mm_add_ps(fjx1,tx);
838 fjy1 = _mm_add_ps(fjy1,ty);
839 fjz1 = _mm_add_ps(fjz1,tz);
841 /**************************
842 * CALCULATE INTERACTIONS *
843 **************************/
845 /* REACTION-FIELD ELECTROSTATICS */
846 velec = _mm_mul_ps(qq32,_mm_sub_ps(_mm_add_ps(rinv32,_mm_mul_ps(krf,rsq32)),crf));
847 felec = _mm_mul_ps(qq32,_mm_sub_ps(_mm_mul_ps(rinv32,rinvsq32),krf2));
849 /* Update potential sum for this i atom from the interaction with this j atom. */
850 velec = _mm_andnot_ps(dummy_mask,velec);
851 velecsum = _mm_add_ps(velecsum,velec);
855 fscal = _mm_andnot_ps(dummy_mask,fscal);
857 /* Calculate temporary vectorial force */
858 tx = _mm_mul_ps(fscal,dx32);
859 ty = _mm_mul_ps(fscal,dy32);
860 tz = _mm_mul_ps(fscal,dz32);
862 /* Update vectorial force */
863 fix3 = _mm_add_ps(fix3,tx);
864 fiy3 = _mm_add_ps(fiy3,ty);
865 fiz3 = _mm_add_ps(fiz3,tz);
867 fjx2 = _mm_add_ps(fjx2,tx);
868 fjy2 = _mm_add_ps(fjy2,ty);
869 fjz2 = _mm_add_ps(fjz2,tz);
871 /**************************
872 * CALCULATE INTERACTIONS *
873 **************************/
875 /* REACTION-FIELD ELECTROSTATICS */
876 velec = _mm_mul_ps(qq33,_mm_sub_ps(_mm_add_ps(rinv33,_mm_mul_ps(krf,rsq33)),crf));
877 felec = _mm_mul_ps(qq33,_mm_sub_ps(_mm_mul_ps(rinv33,rinvsq33),krf2));
879 /* Update potential sum for this i atom from the interaction with this j atom. */
880 velec = _mm_andnot_ps(dummy_mask,velec);
881 velecsum = _mm_add_ps(velecsum,velec);
885 fscal = _mm_andnot_ps(dummy_mask,fscal);
887 /* Calculate temporary vectorial force */
888 tx = _mm_mul_ps(fscal,dx33);
889 ty = _mm_mul_ps(fscal,dy33);
890 tz = _mm_mul_ps(fscal,dz33);
892 /* Update vectorial force */
893 fix3 = _mm_add_ps(fix3,tx);
894 fiy3 = _mm_add_ps(fiy3,ty);
895 fiz3 = _mm_add_ps(fiz3,tz);
897 fjx3 = _mm_add_ps(fjx3,tx);
898 fjy3 = _mm_add_ps(fjy3,ty);
899 fjz3 = _mm_add_ps(fjz3,tz);
901 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
902 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
903 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
904 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
906 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA+DIM,fjptrB+DIM,fjptrC+DIM,fjptrD+DIM,
907 fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
909 /* Inner loop uses 288 flops */
912 /* End of innermost loop */
914 gmx_mm_update_iforce_3atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
915 f+i_coord_offset+DIM,fshift+i_shift_offset);
918 /* Update potential energies */
919 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
921 /* Increment number of inner iterations */
922 inneriter += j_index_end - j_index_start;
924 /* Outer loop uses 19 flops */
927 /* Increment number of outer iterations */
930 /* Update outer/inner flops */
932 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*19 + inneriter*288);
935 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwNone_GeomW4W4_F_sse2_single
936 * Electrostatics interaction: ReactionField
937 * VdW interaction: None
938 * Geometry: Water4-Water4
939 * Calculate force/pot: Force
942 nb_kernel_ElecRF_VdwNone_GeomW4W4_F_sse2_single
943 (t_nblist * gmx_restrict nlist,
944 rvec * gmx_restrict xx,
945 rvec * gmx_restrict ff,
946 struct t_forcerec * gmx_restrict fr,
947 t_mdatoms * gmx_restrict mdatoms,
948 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
949 t_nrnb * gmx_restrict nrnb)
951 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
952 * just 0 for non-waters.
953 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
954 * jnr indices corresponding to data put in the four positions in the SIMD register.
956 int i_shift_offset,i_coord_offset,outeriter,inneriter;
957 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
958 int jnrA,jnrB,jnrC,jnrD;
959 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
960 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
961 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
963 real *shiftvec,*fshift,*x,*f;
964 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
966 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
968 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
970 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
972 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
973 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
974 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
975 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
976 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
977 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D;
978 __m128 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
979 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
980 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
981 __m128 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
982 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
983 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
984 __m128 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
985 __m128 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
986 __m128 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
987 __m128 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
988 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
990 __m128 dummy_mask,cutoff_mask;
991 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
992 __m128 one = _mm_set1_ps(1.0);
993 __m128 two = _mm_set1_ps(2.0);
999 jindex = nlist->jindex;
1001 shiftidx = nlist->shift;
1003 shiftvec = fr->shift_vec[0];
1004 fshift = fr->fshift[0];
1005 facel = _mm_set1_ps(fr->ic->epsfac);
1006 charge = mdatoms->chargeA;
1007 krf = _mm_set1_ps(fr->ic->k_rf);
1008 krf2 = _mm_set1_ps(fr->ic->k_rf*2.0);
1009 crf = _mm_set1_ps(fr->ic->c_rf);
1011 /* Setup water-specific parameters */
1012 inr = nlist->iinr[0];
1013 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
1014 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
1015 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
1017 jq1 = _mm_set1_ps(charge[inr+1]);
1018 jq2 = _mm_set1_ps(charge[inr+2]);
1019 jq3 = _mm_set1_ps(charge[inr+3]);
1020 qq11 = _mm_mul_ps(iq1,jq1);
1021 qq12 = _mm_mul_ps(iq1,jq2);
1022 qq13 = _mm_mul_ps(iq1,jq3);
1023 qq21 = _mm_mul_ps(iq2,jq1);
1024 qq22 = _mm_mul_ps(iq2,jq2);
1025 qq23 = _mm_mul_ps(iq2,jq3);
1026 qq31 = _mm_mul_ps(iq3,jq1);
1027 qq32 = _mm_mul_ps(iq3,jq2);
1028 qq33 = _mm_mul_ps(iq3,jq3);
1030 /* Avoid stupid compiler warnings */
1031 jnrA = jnrB = jnrC = jnrD = 0;
1032 j_coord_offsetA = 0;
1033 j_coord_offsetB = 0;
1034 j_coord_offsetC = 0;
1035 j_coord_offsetD = 0;
1040 for(iidx=0;iidx<4*DIM;iidx++)
1042 scratch[iidx] = 0.0;
1045 /* Start outer loop over neighborlists */
1046 for(iidx=0; iidx<nri; iidx++)
1048 /* Load shift vector for this list */
1049 i_shift_offset = DIM*shiftidx[iidx];
1051 /* Load limits for loop over neighbors */
1052 j_index_start = jindex[iidx];
1053 j_index_end = jindex[iidx+1];
1055 /* Get outer coordinate index */
1057 i_coord_offset = DIM*inr;
1059 /* Load i particle coords and add shift vector */
1060 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
1061 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1063 fix1 = _mm_setzero_ps();
1064 fiy1 = _mm_setzero_ps();
1065 fiz1 = _mm_setzero_ps();
1066 fix2 = _mm_setzero_ps();
1067 fiy2 = _mm_setzero_ps();
1068 fiz2 = _mm_setzero_ps();
1069 fix3 = _mm_setzero_ps();
1070 fiy3 = _mm_setzero_ps();
1071 fiz3 = _mm_setzero_ps();
1073 /* Start inner kernel loop */
1074 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
1077 /* Get j neighbor index, and coordinate index */
1079 jnrB = jjnr[jidx+1];
1080 jnrC = jjnr[jidx+2];
1081 jnrD = jjnr[jidx+3];
1082 j_coord_offsetA = DIM*jnrA;
1083 j_coord_offsetB = DIM*jnrB;
1084 j_coord_offsetC = DIM*jnrC;
1085 j_coord_offsetD = DIM*jnrD;
1087 /* load j atom coordinates */
1088 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
1089 x+j_coord_offsetC+DIM,x+j_coord_offsetD+DIM,
1090 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
1092 /* Calculate displacement vector */
1093 dx11 = _mm_sub_ps(ix1,jx1);
1094 dy11 = _mm_sub_ps(iy1,jy1);
1095 dz11 = _mm_sub_ps(iz1,jz1);
1096 dx12 = _mm_sub_ps(ix1,jx2);
1097 dy12 = _mm_sub_ps(iy1,jy2);
1098 dz12 = _mm_sub_ps(iz1,jz2);
1099 dx13 = _mm_sub_ps(ix1,jx3);
1100 dy13 = _mm_sub_ps(iy1,jy3);
1101 dz13 = _mm_sub_ps(iz1,jz3);
1102 dx21 = _mm_sub_ps(ix2,jx1);
1103 dy21 = _mm_sub_ps(iy2,jy1);
1104 dz21 = _mm_sub_ps(iz2,jz1);
1105 dx22 = _mm_sub_ps(ix2,jx2);
1106 dy22 = _mm_sub_ps(iy2,jy2);
1107 dz22 = _mm_sub_ps(iz2,jz2);
1108 dx23 = _mm_sub_ps(ix2,jx3);
1109 dy23 = _mm_sub_ps(iy2,jy3);
1110 dz23 = _mm_sub_ps(iz2,jz3);
1111 dx31 = _mm_sub_ps(ix3,jx1);
1112 dy31 = _mm_sub_ps(iy3,jy1);
1113 dz31 = _mm_sub_ps(iz3,jz1);
1114 dx32 = _mm_sub_ps(ix3,jx2);
1115 dy32 = _mm_sub_ps(iy3,jy2);
1116 dz32 = _mm_sub_ps(iz3,jz2);
1117 dx33 = _mm_sub_ps(ix3,jx3);
1118 dy33 = _mm_sub_ps(iy3,jy3);
1119 dz33 = _mm_sub_ps(iz3,jz3);
1121 /* Calculate squared distance and things based on it */
1122 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1123 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1124 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
1125 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1126 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1127 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
1128 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
1129 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
1130 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
1132 rinv11 = sse2_invsqrt_f(rsq11);
1133 rinv12 = sse2_invsqrt_f(rsq12);
1134 rinv13 = sse2_invsqrt_f(rsq13);
1135 rinv21 = sse2_invsqrt_f(rsq21);
1136 rinv22 = sse2_invsqrt_f(rsq22);
1137 rinv23 = sse2_invsqrt_f(rsq23);
1138 rinv31 = sse2_invsqrt_f(rsq31);
1139 rinv32 = sse2_invsqrt_f(rsq32);
1140 rinv33 = sse2_invsqrt_f(rsq33);
1142 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1143 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1144 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
1145 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1146 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1147 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
1148 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
1149 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
1150 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
1152 fjx1 = _mm_setzero_ps();
1153 fjy1 = _mm_setzero_ps();
1154 fjz1 = _mm_setzero_ps();
1155 fjx2 = _mm_setzero_ps();
1156 fjy2 = _mm_setzero_ps();
1157 fjz2 = _mm_setzero_ps();
1158 fjx3 = _mm_setzero_ps();
1159 fjy3 = _mm_setzero_ps();
1160 fjz3 = _mm_setzero_ps();
1162 /**************************
1163 * CALCULATE INTERACTIONS *
1164 **************************/
1166 /* REACTION-FIELD ELECTROSTATICS */
1167 felec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
1171 /* Calculate temporary vectorial force */
1172 tx = _mm_mul_ps(fscal,dx11);
1173 ty = _mm_mul_ps(fscal,dy11);
1174 tz = _mm_mul_ps(fscal,dz11);
1176 /* Update vectorial force */
1177 fix1 = _mm_add_ps(fix1,tx);
1178 fiy1 = _mm_add_ps(fiy1,ty);
1179 fiz1 = _mm_add_ps(fiz1,tz);
1181 fjx1 = _mm_add_ps(fjx1,tx);
1182 fjy1 = _mm_add_ps(fjy1,ty);
1183 fjz1 = _mm_add_ps(fjz1,tz);
1185 /**************************
1186 * CALCULATE INTERACTIONS *
1187 **************************/
1189 /* REACTION-FIELD ELECTROSTATICS */
1190 felec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
1194 /* Calculate temporary vectorial force */
1195 tx = _mm_mul_ps(fscal,dx12);
1196 ty = _mm_mul_ps(fscal,dy12);
1197 tz = _mm_mul_ps(fscal,dz12);
1199 /* Update vectorial force */
1200 fix1 = _mm_add_ps(fix1,tx);
1201 fiy1 = _mm_add_ps(fiy1,ty);
1202 fiz1 = _mm_add_ps(fiz1,tz);
1204 fjx2 = _mm_add_ps(fjx2,tx);
1205 fjy2 = _mm_add_ps(fjy2,ty);
1206 fjz2 = _mm_add_ps(fjz2,tz);
1208 /**************************
1209 * CALCULATE INTERACTIONS *
1210 **************************/
1212 /* REACTION-FIELD ELECTROSTATICS */
1213 felec = _mm_mul_ps(qq13,_mm_sub_ps(_mm_mul_ps(rinv13,rinvsq13),krf2));
1217 /* Calculate temporary vectorial force */
1218 tx = _mm_mul_ps(fscal,dx13);
1219 ty = _mm_mul_ps(fscal,dy13);
1220 tz = _mm_mul_ps(fscal,dz13);
1222 /* Update vectorial force */
1223 fix1 = _mm_add_ps(fix1,tx);
1224 fiy1 = _mm_add_ps(fiy1,ty);
1225 fiz1 = _mm_add_ps(fiz1,tz);
1227 fjx3 = _mm_add_ps(fjx3,tx);
1228 fjy3 = _mm_add_ps(fjy3,ty);
1229 fjz3 = _mm_add_ps(fjz3,tz);
1231 /**************************
1232 * CALCULATE INTERACTIONS *
1233 **************************/
1235 /* REACTION-FIELD ELECTROSTATICS */
1236 felec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
1240 /* Calculate temporary vectorial force */
1241 tx = _mm_mul_ps(fscal,dx21);
1242 ty = _mm_mul_ps(fscal,dy21);
1243 tz = _mm_mul_ps(fscal,dz21);
1245 /* Update vectorial force */
1246 fix2 = _mm_add_ps(fix2,tx);
1247 fiy2 = _mm_add_ps(fiy2,ty);
1248 fiz2 = _mm_add_ps(fiz2,tz);
1250 fjx1 = _mm_add_ps(fjx1,tx);
1251 fjy1 = _mm_add_ps(fjy1,ty);
1252 fjz1 = _mm_add_ps(fjz1,tz);
1254 /**************************
1255 * CALCULATE INTERACTIONS *
1256 **************************/
1258 /* REACTION-FIELD ELECTROSTATICS */
1259 felec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
1263 /* Calculate temporary vectorial force */
1264 tx = _mm_mul_ps(fscal,dx22);
1265 ty = _mm_mul_ps(fscal,dy22);
1266 tz = _mm_mul_ps(fscal,dz22);
1268 /* Update vectorial force */
1269 fix2 = _mm_add_ps(fix2,tx);
1270 fiy2 = _mm_add_ps(fiy2,ty);
1271 fiz2 = _mm_add_ps(fiz2,tz);
1273 fjx2 = _mm_add_ps(fjx2,tx);
1274 fjy2 = _mm_add_ps(fjy2,ty);
1275 fjz2 = _mm_add_ps(fjz2,tz);
1277 /**************************
1278 * CALCULATE INTERACTIONS *
1279 **************************/
1281 /* REACTION-FIELD ELECTROSTATICS */
1282 felec = _mm_mul_ps(qq23,_mm_sub_ps(_mm_mul_ps(rinv23,rinvsq23),krf2));
1286 /* Calculate temporary vectorial force */
1287 tx = _mm_mul_ps(fscal,dx23);
1288 ty = _mm_mul_ps(fscal,dy23);
1289 tz = _mm_mul_ps(fscal,dz23);
1291 /* Update vectorial force */
1292 fix2 = _mm_add_ps(fix2,tx);
1293 fiy2 = _mm_add_ps(fiy2,ty);
1294 fiz2 = _mm_add_ps(fiz2,tz);
1296 fjx3 = _mm_add_ps(fjx3,tx);
1297 fjy3 = _mm_add_ps(fjy3,ty);
1298 fjz3 = _mm_add_ps(fjz3,tz);
1300 /**************************
1301 * CALCULATE INTERACTIONS *
1302 **************************/
1304 /* REACTION-FIELD ELECTROSTATICS */
1305 felec = _mm_mul_ps(qq31,_mm_sub_ps(_mm_mul_ps(rinv31,rinvsq31),krf2));
1309 /* Calculate temporary vectorial force */
1310 tx = _mm_mul_ps(fscal,dx31);
1311 ty = _mm_mul_ps(fscal,dy31);
1312 tz = _mm_mul_ps(fscal,dz31);
1314 /* Update vectorial force */
1315 fix3 = _mm_add_ps(fix3,tx);
1316 fiy3 = _mm_add_ps(fiy3,ty);
1317 fiz3 = _mm_add_ps(fiz3,tz);
1319 fjx1 = _mm_add_ps(fjx1,tx);
1320 fjy1 = _mm_add_ps(fjy1,ty);
1321 fjz1 = _mm_add_ps(fjz1,tz);
1323 /**************************
1324 * CALCULATE INTERACTIONS *
1325 **************************/
1327 /* REACTION-FIELD ELECTROSTATICS */
1328 felec = _mm_mul_ps(qq32,_mm_sub_ps(_mm_mul_ps(rinv32,rinvsq32),krf2));
1332 /* Calculate temporary vectorial force */
1333 tx = _mm_mul_ps(fscal,dx32);
1334 ty = _mm_mul_ps(fscal,dy32);
1335 tz = _mm_mul_ps(fscal,dz32);
1337 /* Update vectorial force */
1338 fix3 = _mm_add_ps(fix3,tx);
1339 fiy3 = _mm_add_ps(fiy3,ty);
1340 fiz3 = _mm_add_ps(fiz3,tz);
1342 fjx2 = _mm_add_ps(fjx2,tx);
1343 fjy2 = _mm_add_ps(fjy2,ty);
1344 fjz2 = _mm_add_ps(fjz2,tz);
1346 /**************************
1347 * CALCULATE INTERACTIONS *
1348 **************************/
1350 /* REACTION-FIELD ELECTROSTATICS */
1351 felec = _mm_mul_ps(qq33,_mm_sub_ps(_mm_mul_ps(rinv33,rinvsq33),krf2));
1355 /* Calculate temporary vectorial force */
1356 tx = _mm_mul_ps(fscal,dx33);
1357 ty = _mm_mul_ps(fscal,dy33);
1358 tz = _mm_mul_ps(fscal,dz33);
1360 /* Update vectorial force */
1361 fix3 = _mm_add_ps(fix3,tx);
1362 fiy3 = _mm_add_ps(fiy3,ty);
1363 fiz3 = _mm_add_ps(fiz3,tz);
1365 fjx3 = _mm_add_ps(fjx3,tx);
1366 fjy3 = _mm_add_ps(fjy3,ty);
1367 fjz3 = _mm_add_ps(fjz3,tz);
1369 fjptrA = f+j_coord_offsetA;
1370 fjptrB = f+j_coord_offsetB;
1371 fjptrC = f+j_coord_offsetC;
1372 fjptrD = f+j_coord_offsetD;
1374 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA+DIM,fjptrB+DIM,fjptrC+DIM,fjptrD+DIM,
1375 fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1377 /* Inner loop uses 243 flops */
1380 if(jidx<j_index_end)
1383 /* Get j neighbor index, and coordinate index */
1384 jnrlistA = jjnr[jidx];
1385 jnrlistB = jjnr[jidx+1];
1386 jnrlistC = jjnr[jidx+2];
1387 jnrlistD = jjnr[jidx+3];
1388 /* Sign of each element will be negative for non-real atoms.
1389 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1390 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1392 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1393 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1394 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1395 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1396 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1397 j_coord_offsetA = DIM*jnrA;
1398 j_coord_offsetB = DIM*jnrB;
1399 j_coord_offsetC = DIM*jnrC;
1400 j_coord_offsetD = DIM*jnrD;
1402 /* load j atom coordinates */
1403 gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA+DIM,x+j_coord_offsetB+DIM,
1404 x+j_coord_offsetC+DIM,x+j_coord_offsetD+DIM,
1405 &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
1407 /* Calculate displacement vector */
1408 dx11 = _mm_sub_ps(ix1,jx1);
1409 dy11 = _mm_sub_ps(iy1,jy1);
1410 dz11 = _mm_sub_ps(iz1,jz1);
1411 dx12 = _mm_sub_ps(ix1,jx2);
1412 dy12 = _mm_sub_ps(iy1,jy2);
1413 dz12 = _mm_sub_ps(iz1,jz2);
1414 dx13 = _mm_sub_ps(ix1,jx3);
1415 dy13 = _mm_sub_ps(iy1,jy3);
1416 dz13 = _mm_sub_ps(iz1,jz3);
1417 dx21 = _mm_sub_ps(ix2,jx1);
1418 dy21 = _mm_sub_ps(iy2,jy1);
1419 dz21 = _mm_sub_ps(iz2,jz1);
1420 dx22 = _mm_sub_ps(ix2,jx2);
1421 dy22 = _mm_sub_ps(iy2,jy2);
1422 dz22 = _mm_sub_ps(iz2,jz2);
1423 dx23 = _mm_sub_ps(ix2,jx3);
1424 dy23 = _mm_sub_ps(iy2,jy3);
1425 dz23 = _mm_sub_ps(iz2,jz3);
1426 dx31 = _mm_sub_ps(ix3,jx1);
1427 dy31 = _mm_sub_ps(iy3,jy1);
1428 dz31 = _mm_sub_ps(iz3,jz1);
1429 dx32 = _mm_sub_ps(ix3,jx2);
1430 dy32 = _mm_sub_ps(iy3,jy2);
1431 dz32 = _mm_sub_ps(iz3,jz2);
1432 dx33 = _mm_sub_ps(ix3,jx3);
1433 dy33 = _mm_sub_ps(iy3,jy3);
1434 dz33 = _mm_sub_ps(iz3,jz3);
1436 /* Calculate squared distance and things based on it */
1437 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1438 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1439 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
1440 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1441 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1442 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
1443 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
1444 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
1445 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
1447 rinv11 = sse2_invsqrt_f(rsq11);
1448 rinv12 = sse2_invsqrt_f(rsq12);
1449 rinv13 = sse2_invsqrt_f(rsq13);
1450 rinv21 = sse2_invsqrt_f(rsq21);
1451 rinv22 = sse2_invsqrt_f(rsq22);
1452 rinv23 = sse2_invsqrt_f(rsq23);
1453 rinv31 = sse2_invsqrt_f(rsq31);
1454 rinv32 = sse2_invsqrt_f(rsq32);
1455 rinv33 = sse2_invsqrt_f(rsq33);
1457 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1458 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1459 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
1460 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1461 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1462 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
1463 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
1464 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
1465 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
1467 fjx1 = _mm_setzero_ps();
1468 fjy1 = _mm_setzero_ps();
1469 fjz1 = _mm_setzero_ps();
1470 fjx2 = _mm_setzero_ps();
1471 fjy2 = _mm_setzero_ps();
1472 fjz2 = _mm_setzero_ps();
1473 fjx3 = _mm_setzero_ps();
1474 fjy3 = _mm_setzero_ps();
1475 fjz3 = _mm_setzero_ps();
1477 /**************************
1478 * CALCULATE INTERACTIONS *
1479 **************************/
1481 /* REACTION-FIELD ELECTROSTATICS */
1482 felec = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
1486 fscal = _mm_andnot_ps(dummy_mask,fscal);
1488 /* Calculate temporary vectorial force */
1489 tx = _mm_mul_ps(fscal,dx11);
1490 ty = _mm_mul_ps(fscal,dy11);
1491 tz = _mm_mul_ps(fscal,dz11);
1493 /* Update vectorial force */
1494 fix1 = _mm_add_ps(fix1,tx);
1495 fiy1 = _mm_add_ps(fiy1,ty);
1496 fiz1 = _mm_add_ps(fiz1,tz);
1498 fjx1 = _mm_add_ps(fjx1,tx);
1499 fjy1 = _mm_add_ps(fjy1,ty);
1500 fjz1 = _mm_add_ps(fjz1,tz);
1502 /**************************
1503 * CALCULATE INTERACTIONS *
1504 **************************/
1506 /* REACTION-FIELD ELECTROSTATICS */
1507 felec = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
1511 fscal = _mm_andnot_ps(dummy_mask,fscal);
1513 /* Calculate temporary vectorial force */
1514 tx = _mm_mul_ps(fscal,dx12);
1515 ty = _mm_mul_ps(fscal,dy12);
1516 tz = _mm_mul_ps(fscal,dz12);
1518 /* Update vectorial force */
1519 fix1 = _mm_add_ps(fix1,tx);
1520 fiy1 = _mm_add_ps(fiy1,ty);
1521 fiz1 = _mm_add_ps(fiz1,tz);
1523 fjx2 = _mm_add_ps(fjx2,tx);
1524 fjy2 = _mm_add_ps(fjy2,ty);
1525 fjz2 = _mm_add_ps(fjz2,tz);
1527 /**************************
1528 * CALCULATE INTERACTIONS *
1529 **************************/
1531 /* REACTION-FIELD ELECTROSTATICS */
1532 felec = _mm_mul_ps(qq13,_mm_sub_ps(_mm_mul_ps(rinv13,rinvsq13),krf2));
1536 fscal = _mm_andnot_ps(dummy_mask,fscal);
1538 /* Calculate temporary vectorial force */
1539 tx = _mm_mul_ps(fscal,dx13);
1540 ty = _mm_mul_ps(fscal,dy13);
1541 tz = _mm_mul_ps(fscal,dz13);
1543 /* Update vectorial force */
1544 fix1 = _mm_add_ps(fix1,tx);
1545 fiy1 = _mm_add_ps(fiy1,ty);
1546 fiz1 = _mm_add_ps(fiz1,tz);
1548 fjx3 = _mm_add_ps(fjx3,tx);
1549 fjy3 = _mm_add_ps(fjy3,ty);
1550 fjz3 = _mm_add_ps(fjz3,tz);
1552 /**************************
1553 * CALCULATE INTERACTIONS *
1554 **************************/
1556 /* REACTION-FIELD ELECTROSTATICS */
1557 felec = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
1561 fscal = _mm_andnot_ps(dummy_mask,fscal);
1563 /* Calculate temporary vectorial force */
1564 tx = _mm_mul_ps(fscal,dx21);
1565 ty = _mm_mul_ps(fscal,dy21);
1566 tz = _mm_mul_ps(fscal,dz21);
1568 /* Update vectorial force */
1569 fix2 = _mm_add_ps(fix2,tx);
1570 fiy2 = _mm_add_ps(fiy2,ty);
1571 fiz2 = _mm_add_ps(fiz2,tz);
1573 fjx1 = _mm_add_ps(fjx1,tx);
1574 fjy1 = _mm_add_ps(fjy1,ty);
1575 fjz1 = _mm_add_ps(fjz1,tz);
1577 /**************************
1578 * CALCULATE INTERACTIONS *
1579 **************************/
1581 /* REACTION-FIELD ELECTROSTATICS */
1582 felec = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
1586 fscal = _mm_andnot_ps(dummy_mask,fscal);
1588 /* Calculate temporary vectorial force */
1589 tx = _mm_mul_ps(fscal,dx22);
1590 ty = _mm_mul_ps(fscal,dy22);
1591 tz = _mm_mul_ps(fscal,dz22);
1593 /* Update vectorial force */
1594 fix2 = _mm_add_ps(fix2,tx);
1595 fiy2 = _mm_add_ps(fiy2,ty);
1596 fiz2 = _mm_add_ps(fiz2,tz);
1598 fjx2 = _mm_add_ps(fjx2,tx);
1599 fjy2 = _mm_add_ps(fjy2,ty);
1600 fjz2 = _mm_add_ps(fjz2,tz);
1602 /**************************
1603 * CALCULATE INTERACTIONS *
1604 **************************/
1606 /* REACTION-FIELD ELECTROSTATICS */
1607 felec = _mm_mul_ps(qq23,_mm_sub_ps(_mm_mul_ps(rinv23,rinvsq23),krf2));
1611 fscal = _mm_andnot_ps(dummy_mask,fscal);
1613 /* Calculate temporary vectorial force */
1614 tx = _mm_mul_ps(fscal,dx23);
1615 ty = _mm_mul_ps(fscal,dy23);
1616 tz = _mm_mul_ps(fscal,dz23);
1618 /* Update vectorial force */
1619 fix2 = _mm_add_ps(fix2,tx);
1620 fiy2 = _mm_add_ps(fiy2,ty);
1621 fiz2 = _mm_add_ps(fiz2,tz);
1623 fjx3 = _mm_add_ps(fjx3,tx);
1624 fjy3 = _mm_add_ps(fjy3,ty);
1625 fjz3 = _mm_add_ps(fjz3,tz);
1627 /**************************
1628 * CALCULATE INTERACTIONS *
1629 **************************/
1631 /* REACTION-FIELD ELECTROSTATICS */
1632 felec = _mm_mul_ps(qq31,_mm_sub_ps(_mm_mul_ps(rinv31,rinvsq31),krf2));
1636 fscal = _mm_andnot_ps(dummy_mask,fscal);
1638 /* Calculate temporary vectorial force */
1639 tx = _mm_mul_ps(fscal,dx31);
1640 ty = _mm_mul_ps(fscal,dy31);
1641 tz = _mm_mul_ps(fscal,dz31);
1643 /* Update vectorial force */
1644 fix3 = _mm_add_ps(fix3,tx);
1645 fiy3 = _mm_add_ps(fiy3,ty);
1646 fiz3 = _mm_add_ps(fiz3,tz);
1648 fjx1 = _mm_add_ps(fjx1,tx);
1649 fjy1 = _mm_add_ps(fjy1,ty);
1650 fjz1 = _mm_add_ps(fjz1,tz);
1652 /**************************
1653 * CALCULATE INTERACTIONS *
1654 **************************/
1656 /* REACTION-FIELD ELECTROSTATICS */
1657 felec = _mm_mul_ps(qq32,_mm_sub_ps(_mm_mul_ps(rinv32,rinvsq32),krf2));
1661 fscal = _mm_andnot_ps(dummy_mask,fscal);
1663 /* Calculate temporary vectorial force */
1664 tx = _mm_mul_ps(fscal,dx32);
1665 ty = _mm_mul_ps(fscal,dy32);
1666 tz = _mm_mul_ps(fscal,dz32);
1668 /* Update vectorial force */
1669 fix3 = _mm_add_ps(fix3,tx);
1670 fiy3 = _mm_add_ps(fiy3,ty);
1671 fiz3 = _mm_add_ps(fiz3,tz);
1673 fjx2 = _mm_add_ps(fjx2,tx);
1674 fjy2 = _mm_add_ps(fjy2,ty);
1675 fjz2 = _mm_add_ps(fjz2,tz);
1677 /**************************
1678 * CALCULATE INTERACTIONS *
1679 **************************/
1681 /* REACTION-FIELD ELECTROSTATICS */
1682 felec = _mm_mul_ps(qq33,_mm_sub_ps(_mm_mul_ps(rinv33,rinvsq33),krf2));
1686 fscal = _mm_andnot_ps(dummy_mask,fscal);
1688 /* Calculate temporary vectorial force */
1689 tx = _mm_mul_ps(fscal,dx33);
1690 ty = _mm_mul_ps(fscal,dy33);
1691 tz = _mm_mul_ps(fscal,dz33);
1693 /* Update vectorial force */
1694 fix3 = _mm_add_ps(fix3,tx);
1695 fiy3 = _mm_add_ps(fiy3,ty);
1696 fiz3 = _mm_add_ps(fiz3,tz);
1698 fjx3 = _mm_add_ps(fjx3,tx);
1699 fjy3 = _mm_add_ps(fjy3,ty);
1700 fjz3 = _mm_add_ps(fjz3,tz);
1702 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1703 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1704 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1705 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1707 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA+DIM,fjptrB+DIM,fjptrC+DIM,fjptrD+DIM,
1708 fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1710 /* Inner loop uses 243 flops */
1713 /* End of innermost loop */
1715 gmx_mm_update_iforce_3atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1716 f+i_coord_offset+DIM,fshift+i_shift_offset);
1718 /* Increment number of inner iterations */
1719 inneriter += j_index_end - j_index_start;
1721 /* Outer loop uses 18 flops */
1724 /* Increment number of outer iterations */
1727 /* Update outer/inner flops */
1729 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*18 + inneriter*243);