2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, 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 avx_128_fma_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "gromacs/math/vec.h"
49 #include "gromacs/simd/math_x86_avx_128_fma_single.h"
50 #include "kernelutil_x86_avx_128_fma_single.h"
53 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomW3P1_VF_avx_128_fma_single
54 * Electrostatics interaction: Coulomb
55 * VdW interaction: None
56 * Geometry: Water3-Particle
57 * Calculate force/pot: PotentialAndForce
60 nb_kernel_ElecCoul_VdwNone_GeomW3P1_VF_avx_128_fma_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 AVX_128, 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 fscal,rcutoff,rcutoff2,jidxall;
86 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
88 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
90 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
91 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
92 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
93 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
94 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
95 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
96 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
98 __m128 dummy_mask,cutoff_mask;
99 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
100 __m128 one = _mm_set1_ps(1.0);
101 __m128 two = _mm_set1_ps(2.0);
107 jindex = nlist->jindex;
109 shiftidx = nlist->shift;
111 shiftvec = fr->shift_vec[0];
112 fshift = fr->fshift[0];
113 facel = _mm_set1_ps(fr->epsfac);
114 charge = mdatoms->chargeA;
116 /* Setup water-specific parameters */
117 inr = nlist->iinr[0];
118 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
119 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
120 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
122 /* Avoid stupid compiler warnings */
123 jnrA = jnrB = jnrC = jnrD = 0;
132 for(iidx=0;iidx<4*DIM;iidx++)
137 /* Start outer loop over neighborlists */
138 for(iidx=0; iidx<nri; iidx++)
140 /* Load shift vector for this list */
141 i_shift_offset = DIM*shiftidx[iidx];
143 /* Load limits for loop over neighbors */
144 j_index_start = jindex[iidx];
145 j_index_end = jindex[iidx+1];
147 /* Get outer coordinate index */
149 i_coord_offset = DIM*inr;
151 /* Load i particle coords and add shift vector */
152 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
153 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
155 fix0 = _mm_setzero_ps();
156 fiy0 = _mm_setzero_ps();
157 fiz0 = _mm_setzero_ps();
158 fix1 = _mm_setzero_ps();
159 fiy1 = _mm_setzero_ps();
160 fiz1 = _mm_setzero_ps();
161 fix2 = _mm_setzero_ps();
162 fiy2 = _mm_setzero_ps();
163 fiz2 = _mm_setzero_ps();
165 /* Reset potential sums */
166 velecsum = _mm_setzero_ps();
168 /* Start inner kernel loop */
169 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
172 /* Get j neighbor index, and coordinate index */
177 j_coord_offsetA = DIM*jnrA;
178 j_coord_offsetB = DIM*jnrB;
179 j_coord_offsetC = DIM*jnrC;
180 j_coord_offsetD = DIM*jnrD;
182 /* load j atom coordinates */
183 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
184 x+j_coord_offsetC,x+j_coord_offsetD,
187 /* Calculate displacement vector */
188 dx00 = _mm_sub_ps(ix0,jx0);
189 dy00 = _mm_sub_ps(iy0,jy0);
190 dz00 = _mm_sub_ps(iz0,jz0);
191 dx10 = _mm_sub_ps(ix1,jx0);
192 dy10 = _mm_sub_ps(iy1,jy0);
193 dz10 = _mm_sub_ps(iz1,jz0);
194 dx20 = _mm_sub_ps(ix2,jx0);
195 dy20 = _mm_sub_ps(iy2,jy0);
196 dz20 = _mm_sub_ps(iz2,jz0);
198 /* Calculate squared distance and things based on it */
199 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
200 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
201 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
203 rinv00 = gmx_mm_invsqrt_ps(rsq00);
204 rinv10 = gmx_mm_invsqrt_ps(rsq10);
205 rinv20 = gmx_mm_invsqrt_ps(rsq20);
207 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
208 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
209 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
211 /* Load parameters for j particles */
212 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
213 charge+jnrC+0,charge+jnrD+0);
215 fjx0 = _mm_setzero_ps();
216 fjy0 = _mm_setzero_ps();
217 fjz0 = _mm_setzero_ps();
219 /**************************
220 * CALCULATE INTERACTIONS *
221 **************************/
223 /* Compute parameters for interactions between i and j atoms */
224 qq00 = _mm_mul_ps(iq0,jq0);
226 /* COULOMB ELECTROSTATICS */
227 velec = _mm_mul_ps(qq00,rinv00);
228 felec = _mm_mul_ps(velec,rinvsq00);
230 /* Update potential sum for this i atom from the interaction with this j atom. */
231 velecsum = _mm_add_ps(velecsum,velec);
235 /* Update vectorial force */
236 fix0 = _mm_macc_ps(dx00,fscal,fix0);
237 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
238 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
240 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
241 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
242 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
244 /**************************
245 * CALCULATE INTERACTIONS *
246 **************************/
248 /* Compute parameters for interactions between i and j atoms */
249 qq10 = _mm_mul_ps(iq1,jq0);
251 /* COULOMB ELECTROSTATICS */
252 velec = _mm_mul_ps(qq10,rinv10);
253 felec = _mm_mul_ps(velec,rinvsq10);
255 /* Update potential sum for this i atom from the interaction with this j atom. */
256 velecsum = _mm_add_ps(velecsum,velec);
260 /* Update vectorial force */
261 fix1 = _mm_macc_ps(dx10,fscal,fix1);
262 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
263 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
265 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
266 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
267 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
269 /**************************
270 * CALCULATE INTERACTIONS *
271 **************************/
273 /* Compute parameters for interactions between i and j atoms */
274 qq20 = _mm_mul_ps(iq2,jq0);
276 /* COULOMB ELECTROSTATICS */
277 velec = _mm_mul_ps(qq20,rinv20);
278 felec = _mm_mul_ps(velec,rinvsq20);
280 /* Update potential sum for this i atom from the interaction with this j atom. */
281 velecsum = _mm_add_ps(velecsum,velec);
285 /* Update vectorial force */
286 fix2 = _mm_macc_ps(dx20,fscal,fix2);
287 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
288 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
290 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
291 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
292 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
294 fjptrA = f+j_coord_offsetA;
295 fjptrB = f+j_coord_offsetB;
296 fjptrC = f+j_coord_offsetC;
297 fjptrD = f+j_coord_offsetD;
299 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
301 /* Inner loop uses 93 flops */
307 /* Get j neighbor index, and coordinate index */
308 jnrlistA = jjnr[jidx];
309 jnrlistB = jjnr[jidx+1];
310 jnrlistC = jjnr[jidx+2];
311 jnrlistD = jjnr[jidx+3];
312 /* Sign of each element will be negative for non-real atoms.
313 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
314 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
316 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
317 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
318 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
319 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
320 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
321 j_coord_offsetA = DIM*jnrA;
322 j_coord_offsetB = DIM*jnrB;
323 j_coord_offsetC = DIM*jnrC;
324 j_coord_offsetD = DIM*jnrD;
326 /* load j atom coordinates */
327 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
328 x+j_coord_offsetC,x+j_coord_offsetD,
331 /* Calculate displacement vector */
332 dx00 = _mm_sub_ps(ix0,jx0);
333 dy00 = _mm_sub_ps(iy0,jy0);
334 dz00 = _mm_sub_ps(iz0,jz0);
335 dx10 = _mm_sub_ps(ix1,jx0);
336 dy10 = _mm_sub_ps(iy1,jy0);
337 dz10 = _mm_sub_ps(iz1,jz0);
338 dx20 = _mm_sub_ps(ix2,jx0);
339 dy20 = _mm_sub_ps(iy2,jy0);
340 dz20 = _mm_sub_ps(iz2,jz0);
342 /* Calculate squared distance and things based on it */
343 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
344 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
345 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
347 rinv00 = gmx_mm_invsqrt_ps(rsq00);
348 rinv10 = gmx_mm_invsqrt_ps(rsq10);
349 rinv20 = gmx_mm_invsqrt_ps(rsq20);
351 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
352 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
353 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
355 /* Load parameters for j particles */
356 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
357 charge+jnrC+0,charge+jnrD+0);
359 fjx0 = _mm_setzero_ps();
360 fjy0 = _mm_setzero_ps();
361 fjz0 = _mm_setzero_ps();
363 /**************************
364 * CALCULATE INTERACTIONS *
365 **************************/
367 /* Compute parameters for interactions between i and j atoms */
368 qq00 = _mm_mul_ps(iq0,jq0);
370 /* COULOMB ELECTROSTATICS */
371 velec = _mm_mul_ps(qq00,rinv00);
372 felec = _mm_mul_ps(velec,rinvsq00);
374 /* Update potential sum for this i atom from the interaction with this j atom. */
375 velec = _mm_andnot_ps(dummy_mask,velec);
376 velecsum = _mm_add_ps(velecsum,velec);
380 fscal = _mm_andnot_ps(dummy_mask,fscal);
382 /* Update vectorial force */
383 fix0 = _mm_macc_ps(dx00,fscal,fix0);
384 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
385 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
387 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
388 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
389 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
391 /**************************
392 * CALCULATE INTERACTIONS *
393 **************************/
395 /* Compute parameters for interactions between i and j atoms */
396 qq10 = _mm_mul_ps(iq1,jq0);
398 /* COULOMB ELECTROSTATICS */
399 velec = _mm_mul_ps(qq10,rinv10);
400 felec = _mm_mul_ps(velec,rinvsq10);
402 /* Update potential sum for this i atom from the interaction with this j atom. */
403 velec = _mm_andnot_ps(dummy_mask,velec);
404 velecsum = _mm_add_ps(velecsum,velec);
408 fscal = _mm_andnot_ps(dummy_mask,fscal);
410 /* Update vectorial force */
411 fix1 = _mm_macc_ps(dx10,fscal,fix1);
412 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
413 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
415 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
416 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
417 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
419 /**************************
420 * CALCULATE INTERACTIONS *
421 **************************/
423 /* Compute parameters for interactions between i and j atoms */
424 qq20 = _mm_mul_ps(iq2,jq0);
426 /* COULOMB ELECTROSTATICS */
427 velec = _mm_mul_ps(qq20,rinv20);
428 felec = _mm_mul_ps(velec,rinvsq20);
430 /* Update potential sum for this i atom from the interaction with this j atom. */
431 velec = _mm_andnot_ps(dummy_mask,velec);
432 velecsum = _mm_add_ps(velecsum,velec);
436 fscal = _mm_andnot_ps(dummy_mask,fscal);
438 /* Update vectorial force */
439 fix2 = _mm_macc_ps(dx20,fscal,fix2);
440 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
441 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
443 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
444 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
445 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
447 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
448 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
449 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
450 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
452 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
454 /* Inner loop uses 93 flops */
457 /* End of innermost loop */
459 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
460 f+i_coord_offset,fshift+i_shift_offset);
463 /* Update potential energies */
464 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
466 /* Increment number of inner iterations */
467 inneriter += j_index_end - j_index_start;
469 /* Outer loop uses 19 flops */
472 /* Increment number of outer iterations */
475 /* Update outer/inner flops */
477 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*19 + inneriter*93);
480 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomW3P1_F_avx_128_fma_single
481 * Electrostatics interaction: Coulomb
482 * VdW interaction: None
483 * Geometry: Water3-Particle
484 * Calculate force/pot: Force
487 nb_kernel_ElecCoul_VdwNone_GeomW3P1_F_avx_128_fma_single
488 (t_nblist * gmx_restrict nlist,
489 rvec * gmx_restrict xx,
490 rvec * gmx_restrict ff,
491 t_forcerec * gmx_restrict fr,
492 t_mdatoms * gmx_restrict mdatoms,
493 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
494 t_nrnb * gmx_restrict nrnb)
496 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
497 * just 0 for non-waters.
498 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
499 * jnr indices corresponding to data put in the four positions in the SIMD register.
501 int i_shift_offset,i_coord_offset,outeriter,inneriter;
502 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
503 int jnrA,jnrB,jnrC,jnrD;
504 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
505 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
506 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
508 real *shiftvec,*fshift,*x,*f;
509 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
511 __m128 fscal,rcutoff,rcutoff2,jidxall;
513 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
515 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
517 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
518 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
519 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
520 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
521 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
522 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
523 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
525 __m128 dummy_mask,cutoff_mask;
526 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
527 __m128 one = _mm_set1_ps(1.0);
528 __m128 two = _mm_set1_ps(2.0);
534 jindex = nlist->jindex;
536 shiftidx = nlist->shift;
538 shiftvec = fr->shift_vec[0];
539 fshift = fr->fshift[0];
540 facel = _mm_set1_ps(fr->epsfac);
541 charge = mdatoms->chargeA;
543 /* Setup water-specific parameters */
544 inr = nlist->iinr[0];
545 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
546 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
547 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
549 /* Avoid stupid compiler warnings */
550 jnrA = jnrB = jnrC = jnrD = 0;
559 for(iidx=0;iidx<4*DIM;iidx++)
564 /* Start outer loop over neighborlists */
565 for(iidx=0; iidx<nri; iidx++)
567 /* Load shift vector for this list */
568 i_shift_offset = DIM*shiftidx[iidx];
570 /* Load limits for loop over neighbors */
571 j_index_start = jindex[iidx];
572 j_index_end = jindex[iidx+1];
574 /* Get outer coordinate index */
576 i_coord_offset = DIM*inr;
578 /* Load i particle coords and add shift vector */
579 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
580 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
582 fix0 = _mm_setzero_ps();
583 fiy0 = _mm_setzero_ps();
584 fiz0 = _mm_setzero_ps();
585 fix1 = _mm_setzero_ps();
586 fiy1 = _mm_setzero_ps();
587 fiz1 = _mm_setzero_ps();
588 fix2 = _mm_setzero_ps();
589 fiy2 = _mm_setzero_ps();
590 fiz2 = _mm_setzero_ps();
592 /* Start inner kernel loop */
593 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
596 /* Get j neighbor index, and coordinate index */
601 j_coord_offsetA = DIM*jnrA;
602 j_coord_offsetB = DIM*jnrB;
603 j_coord_offsetC = DIM*jnrC;
604 j_coord_offsetD = DIM*jnrD;
606 /* load j atom coordinates */
607 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
608 x+j_coord_offsetC,x+j_coord_offsetD,
611 /* Calculate displacement vector */
612 dx00 = _mm_sub_ps(ix0,jx0);
613 dy00 = _mm_sub_ps(iy0,jy0);
614 dz00 = _mm_sub_ps(iz0,jz0);
615 dx10 = _mm_sub_ps(ix1,jx0);
616 dy10 = _mm_sub_ps(iy1,jy0);
617 dz10 = _mm_sub_ps(iz1,jz0);
618 dx20 = _mm_sub_ps(ix2,jx0);
619 dy20 = _mm_sub_ps(iy2,jy0);
620 dz20 = _mm_sub_ps(iz2,jz0);
622 /* Calculate squared distance and things based on it */
623 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
624 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
625 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
627 rinv00 = gmx_mm_invsqrt_ps(rsq00);
628 rinv10 = gmx_mm_invsqrt_ps(rsq10);
629 rinv20 = gmx_mm_invsqrt_ps(rsq20);
631 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
632 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
633 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
635 /* Load parameters for j particles */
636 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
637 charge+jnrC+0,charge+jnrD+0);
639 fjx0 = _mm_setzero_ps();
640 fjy0 = _mm_setzero_ps();
641 fjz0 = _mm_setzero_ps();
643 /**************************
644 * CALCULATE INTERACTIONS *
645 **************************/
647 /* Compute parameters for interactions between i and j atoms */
648 qq00 = _mm_mul_ps(iq0,jq0);
650 /* COULOMB ELECTROSTATICS */
651 velec = _mm_mul_ps(qq00,rinv00);
652 felec = _mm_mul_ps(velec,rinvsq00);
656 /* Update vectorial force */
657 fix0 = _mm_macc_ps(dx00,fscal,fix0);
658 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
659 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
661 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
662 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
663 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
665 /**************************
666 * CALCULATE INTERACTIONS *
667 **************************/
669 /* Compute parameters for interactions between i and j atoms */
670 qq10 = _mm_mul_ps(iq1,jq0);
672 /* COULOMB ELECTROSTATICS */
673 velec = _mm_mul_ps(qq10,rinv10);
674 felec = _mm_mul_ps(velec,rinvsq10);
678 /* Update vectorial force */
679 fix1 = _mm_macc_ps(dx10,fscal,fix1);
680 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
681 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
683 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
684 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
685 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
687 /**************************
688 * CALCULATE INTERACTIONS *
689 **************************/
691 /* Compute parameters for interactions between i and j atoms */
692 qq20 = _mm_mul_ps(iq2,jq0);
694 /* COULOMB ELECTROSTATICS */
695 velec = _mm_mul_ps(qq20,rinv20);
696 felec = _mm_mul_ps(velec,rinvsq20);
700 /* Update vectorial force */
701 fix2 = _mm_macc_ps(dx20,fscal,fix2);
702 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
703 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
705 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
706 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
707 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
709 fjptrA = f+j_coord_offsetA;
710 fjptrB = f+j_coord_offsetB;
711 fjptrC = f+j_coord_offsetC;
712 fjptrD = f+j_coord_offsetD;
714 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
716 /* Inner loop uses 90 flops */
722 /* Get j neighbor index, and coordinate index */
723 jnrlistA = jjnr[jidx];
724 jnrlistB = jjnr[jidx+1];
725 jnrlistC = jjnr[jidx+2];
726 jnrlistD = jjnr[jidx+3];
727 /* Sign of each element will be negative for non-real atoms.
728 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
729 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
731 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
732 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
733 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
734 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
735 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
736 j_coord_offsetA = DIM*jnrA;
737 j_coord_offsetB = DIM*jnrB;
738 j_coord_offsetC = DIM*jnrC;
739 j_coord_offsetD = DIM*jnrD;
741 /* load j atom coordinates */
742 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
743 x+j_coord_offsetC,x+j_coord_offsetD,
746 /* Calculate displacement vector */
747 dx00 = _mm_sub_ps(ix0,jx0);
748 dy00 = _mm_sub_ps(iy0,jy0);
749 dz00 = _mm_sub_ps(iz0,jz0);
750 dx10 = _mm_sub_ps(ix1,jx0);
751 dy10 = _mm_sub_ps(iy1,jy0);
752 dz10 = _mm_sub_ps(iz1,jz0);
753 dx20 = _mm_sub_ps(ix2,jx0);
754 dy20 = _mm_sub_ps(iy2,jy0);
755 dz20 = _mm_sub_ps(iz2,jz0);
757 /* Calculate squared distance and things based on it */
758 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
759 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
760 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
762 rinv00 = gmx_mm_invsqrt_ps(rsq00);
763 rinv10 = gmx_mm_invsqrt_ps(rsq10);
764 rinv20 = gmx_mm_invsqrt_ps(rsq20);
766 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
767 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
768 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
770 /* Load parameters for j particles */
771 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
772 charge+jnrC+0,charge+jnrD+0);
774 fjx0 = _mm_setzero_ps();
775 fjy0 = _mm_setzero_ps();
776 fjz0 = _mm_setzero_ps();
778 /**************************
779 * CALCULATE INTERACTIONS *
780 **************************/
782 /* Compute parameters for interactions between i and j atoms */
783 qq00 = _mm_mul_ps(iq0,jq0);
785 /* COULOMB ELECTROSTATICS */
786 velec = _mm_mul_ps(qq00,rinv00);
787 felec = _mm_mul_ps(velec,rinvsq00);
791 fscal = _mm_andnot_ps(dummy_mask,fscal);
793 /* Update vectorial force */
794 fix0 = _mm_macc_ps(dx00,fscal,fix0);
795 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
796 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
798 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
799 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
800 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
802 /**************************
803 * CALCULATE INTERACTIONS *
804 **************************/
806 /* Compute parameters for interactions between i and j atoms */
807 qq10 = _mm_mul_ps(iq1,jq0);
809 /* COULOMB ELECTROSTATICS */
810 velec = _mm_mul_ps(qq10,rinv10);
811 felec = _mm_mul_ps(velec,rinvsq10);
815 fscal = _mm_andnot_ps(dummy_mask,fscal);
817 /* Update vectorial force */
818 fix1 = _mm_macc_ps(dx10,fscal,fix1);
819 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
820 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
822 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
823 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
824 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
826 /**************************
827 * CALCULATE INTERACTIONS *
828 **************************/
830 /* Compute parameters for interactions between i and j atoms */
831 qq20 = _mm_mul_ps(iq2,jq0);
833 /* COULOMB ELECTROSTATICS */
834 velec = _mm_mul_ps(qq20,rinv20);
835 felec = _mm_mul_ps(velec,rinvsq20);
839 fscal = _mm_andnot_ps(dummy_mask,fscal);
841 /* Update vectorial force */
842 fix2 = _mm_macc_ps(dx20,fscal,fix2);
843 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
844 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
846 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
847 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
848 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
850 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
851 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
852 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
853 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
855 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
857 /* Inner loop uses 90 flops */
860 /* End of innermost loop */
862 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
863 f+i_coord_offset,fshift+i_shift_offset);
865 /* Increment number of inner iterations */
866 inneriter += j_index_end - j_index_start;
868 /* Outer loop uses 18 flops */
871 /* Increment number of outer iterations */
874 /* Update outer/inner flops */
876 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*18 + inneriter*90);