2 * Note: this file was generated by the Gromacs avx_128_fma_single kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
33 #include "gmx_math_x86_avx_128_fma_single.h"
34 #include "kernelutil_x86_avx_128_fma_single.h"
37 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomW4P1_VF_avx_128_fma_single
38 * Electrostatics interaction: Coulomb
39 * VdW interaction: None
40 * Geometry: Water4-Particle
41 * Calculate force/pot: PotentialAndForce
44 nb_kernel_ElecCoul_VdwNone_GeomW4P1_VF_avx_128_fma_single
45 (t_nblist * gmx_restrict nlist,
46 rvec * gmx_restrict xx,
47 rvec * gmx_restrict ff,
48 t_forcerec * gmx_restrict fr,
49 t_mdatoms * gmx_restrict mdatoms,
50 nb_kernel_data_t * gmx_restrict kernel_data,
51 t_nrnb * gmx_restrict nrnb)
53 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
54 * just 0 for non-waters.
55 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
56 * jnr indices corresponding to data put in the four positions in the SIMD register.
58 int i_shift_offset,i_coord_offset,outeriter,inneriter;
59 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
60 int jnrA,jnrB,jnrC,jnrD;
61 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
62 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
63 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
65 real *shiftvec,*fshift,*x,*f;
66 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
68 __m128 fscal,rcutoff,rcutoff2,jidxall;
70 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
72 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
74 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
75 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
76 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
77 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
78 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
79 __m128 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
80 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
82 __m128 dummy_mask,cutoff_mask;
83 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
84 __m128 one = _mm_set1_ps(1.0);
85 __m128 two = _mm_set1_ps(2.0);
91 jindex = nlist->jindex;
93 shiftidx = nlist->shift;
95 shiftvec = fr->shift_vec[0];
96 fshift = fr->fshift[0];
97 facel = _mm_set1_ps(fr->epsfac);
98 charge = mdatoms->chargeA;
100 /* Setup water-specific parameters */
101 inr = nlist->iinr[0];
102 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
103 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
104 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
106 /* Avoid stupid compiler warnings */
107 jnrA = jnrB = jnrC = jnrD = 0;
116 for(iidx=0;iidx<4*DIM;iidx++)
121 /* Start outer loop over neighborlists */
122 for(iidx=0; iidx<nri; iidx++)
124 /* Load shift vector for this list */
125 i_shift_offset = DIM*shiftidx[iidx];
127 /* Load limits for loop over neighbors */
128 j_index_start = jindex[iidx];
129 j_index_end = jindex[iidx+1];
131 /* Get outer coordinate index */
133 i_coord_offset = DIM*inr;
135 /* Load i particle coords and add shift vector */
136 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
137 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
139 fix1 = _mm_setzero_ps();
140 fiy1 = _mm_setzero_ps();
141 fiz1 = _mm_setzero_ps();
142 fix2 = _mm_setzero_ps();
143 fiy2 = _mm_setzero_ps();
144 fiz2 = _mm_setzero_ps();
145 fix3 = _mm_setzero_ps();
146 fiy3 = _mm_setzero_ps();
147 fiz3 = _mm_setzero_ps();
149 /* Reset potential sums */
150 velecsum = _mm_setzero_ps();
152 /* Start inner kernel loop */
153 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
156 /* Get j neighbor index, and coordinate index */
161 j_coord_offsetA = DIM*jnrA;
162 j_coord_offsetB = DIM*jnrB;
163 j_coord_offsetC = DIM*jnrC;
164 j_coord_offsetD = DIM*jnrD;
166 /* load j atom coordinates */
167 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
168 x+j_coord_offsetC,x+j_coord_offsetD,
171 /* Calculate displacement vector */
172 dx10 = _mm_sub_ps(ix1,jx0);
173 dy10 = _mm_sub_ps(iy1,jy0);
174 dz10 = _mm_sub_ps(iz1,jz0);
175 dx20 = _mm_sub_ps(ix2,jx0);
176 dy20 = _mm_sub_ps(iy2,jy0);
177 dz20 = _mm_sub_ps(iz2,jz0);
178 dx30 = _mm_sub_ps(ix3,jx0);
179 dy30 = _mm_sub_ps(iy3,jy0);
180 dz30 = _mm_sub_ps(iz3,jz0);
182 /* Calculate squared distance and things based on it */
183 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
184 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
185 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
187 rinv10 = gmx_mm_invsqrt_ps(rsq10);
188 rinv20 = gmx_mm_invsqrt_ps(rsq20);
189 rinv30 = gmx_mm_invsqrt_ps(rsq30);
191 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
192 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
193 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
195 /* Load parameters for j particles */
196 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
197 charge+jnrC+0,charge+jnrD+0);
199 fjx0 = _mm_setzero_ps();
200 fjy0 = _mm_setzero_ps();
201 fjz0 = _mm_setzero_ps();
203 /**************************
204 * CALCULATE INTERACTIONS *
205 **************************/
207 /* Compute parameters for interactions between i and j atoms */
208 qq10 = _mm_mul_ps(iq1,jq0);
210 /* COULOMB ELECTROSTATICS */
211 velec = _mm_mul_ps(qq10,rinv10);
212 felec = _mm_mul_ps(velec,rinvsq10);
214 /* Update potential sum for this i atom from the interaction with this j atom. */
215 velecsum = _mm_add_ps(velecsum,velec);
219 /* Update vectorial force */
220 fix1 = _mm_macc_ps(dx10,fscal,fix1);
221 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
222 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
224 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
225 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
226 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
228 /**************************
229 * CALCULATE INTERACTIONS *
230 **************************/
232 /* Compute parameters for interactions between i and j atoms */
233 qq20 = _mm_mul_ps(iq2,jq0);
235 /* COULOMB ELECTROSTATICS */
236 velec = _mm_mul_ps(qq20,rinv20);
237 felec = _mm_mul_ps(velec,rinvsq20);
239 /* Update potential sum for this i atom from the interaction with this j atom. */
240 velecsum = _mm_add_ps(velecsum,velec);
244 /* Update vectorial force */
245 fix2 = _mm_macc_ps(dx20,fscal,fix2);
246 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
247 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
249 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
250 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
251 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
253 /**************************
254 * CALCULATE INTERACTIONS *
255 **************************/
257 /* Compute parameters for interactions between i and j atoms */
258 qq30 = _mm_mul_ps(iq3,jq0);
260 /* COULOMB ELECTROSTATICS */
261 velec = _mm_mul_ps(qq30,rinv30);
262 felec = _mm_mul_ps(velec,rinvsq30);
264 /* Update potential sum for this i atom from the interaction with this j atom. */
265 velecsum = _mm_add_ps(velecsum,velec);
269 /* Update vectorial force */
270 fix3 = _mm_macc_ps(dx30,fscal,fix3);
271 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
272 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
274 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
275 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
276 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
278 fjptrA = f+j_coord_offsetA;
279 fjptrB = f+j_coord_offsetB;
280 fjptrC = f+j_coord_offsetC;
281 fjptrD = f+j_coord_offsetD;
283 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
285 /* Inner loop uses 93 flops */
291 /* Get j neighbor index, and coordinate index */
292 jnrlistA = jjnr[jidx];
293 jnrlistB = jjnr[jidx+1];
294 jnrlistC = jjnr[jidx+2];
295 jnrlistD = jjnr[jidx+3];
296 /* Sign of each element will be negative for non-real atoms.
297 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
298 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
300 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
301 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
302 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
303 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
304 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
305 j_coord_offsetA = DIM*jnrA;
306 j_coord_offsetB = DIM*jnrB;
307 j_coord_offsetC = DIM*jnrC;
308 j_coord_offsetD = DIM*jnrD;
310 /* load j atom coordinates */
311 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
312 x+j_coord_offsetC,x+j_coord_offsetD,
315 /* Calculate displacement vector */
316 dx10 = _mm_sub_ps(ix1,jx0);
317 dy10 = _mm_sub_ps(iy1,jy0);
318 dz10 = _mm_sub_ps(iz1,jz0);
319 dx20 = _mm_sub_ps(ix2,jx0);
320 dy20 = _mm_sub_ps(iy2,jy0);
321 dz20 = _mm_sub_ps(iz2,jz0);
322 dx30 = _mm_sub_ps(ix3,jx0);
323 dy30 = _mm_sub_ps(iy3,jy0);
324 dz30 = _mm_sub_ps(iz3,jz0);
326 /* Calculate squared distance and things based on it */
327 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
328 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
329 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
331 rinv10 = gmx_mm_invsqrt_ps(rsq10);
332 rinv20 = gmx_mm_invsqrt_ps(rsq20);
333 rinv30 = gmx_mm_invsqrt_ps(rsq30);
335 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
336 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
337 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
339 /* Load parameters for j particles */
340 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
341 charge+jnrC+0,charge+jnrD+0);
343 fjx0 = _mm_setzero_ps();
344 fjy0 = _mm_setzero_ps();
345 fjz0 = _mm_setzero_ps();
347 /**************************
348 * CALCULATE INTERACTIONS *
349 **************************/
351 /* Compute parameters for interactions between i and j atoms */
352 qq10 = _mm_mul_ps(iq1,jq0);
354 /* COULOMB ELECTROSTATICS */
355 velec = _mm_mul_ps(qq10,rinv10);
356 felec = _mm_mul_ps(velec,rinvsq10);
358 /* Update potential sum for this i atom from the interaction with this j atom. */
359 velec = _mm_andnot_ps(dummy_mask,velec);
360 velecsum = _mm_add_ps(velecsum,velec);
364 fscal = _mm_andnot_ps(dummy_mask,fscal);
366 /* Update vectorial force */
367 fix1 = _mm_macc_ps(dx10,fscal,fix1);
368 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
369 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
371 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
372 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
373 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
375 /**************************
376 * CALCULATE INTERACTIONS *
377 **************************/
379 /* Compute parameters for interactions between i and j atoms */
380 qq20 = _mm_mul_ps(iq2,jq0);
382 /* COULOMB ELECTROSTATICS */
383 velec = _mm_mul_ps(qq20,rinv20);
384 felec = _mm_mul_ps(velec,rinvsq20);
386 /* Update potential sum for this i atom from the interaction with this j atom. */
387 velec = _mm_andnot_ps(dummy_mask,velec);
388 velecsum = _mm_add_ps(velecsum,velec);
392 fscal = _mm_andnot_ps(dummy_mask,fscal);
394 /* Update vectorial force */
395 fix2 = _mm_macc_ps(dx20,fscal,fix2);
396 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
397 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
399 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
400 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
401 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
403 /**************************
404 * CALCULATE INTERACTIONS *
405 **************************/
407 /* Compute parameters for interactions between i and j atoms */
408 qq30 = _mm_mul_ps(iq3,jq0);
410 /* COULOMB ELECTROSTATICS */
411 velec = _mm_mul_ps(qq30,rinv30);
412 felec = _mm_mul_ps(velec,rinvsq30);
414 /* Update potential sum for this i atom from the interaction with this j atom. */
415 velec = _mm_andnot_ps(dummy_mask,velec);
416 velecsum = _mm_add_ps(velecsum,velec);
420 fscal = _mm_andnot_ps(dummy_mask,fscal);
422 /* Update vectorial force */
423 fix3 = _mm_macc_ps(dx30,fscal,fix3);
424 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
425 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
427 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
428 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
429 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
431 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
432 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
433 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
434 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
436 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
438 /* Inner loop uses 93 flops */
441 /* End of innermost loop */
443 gmx_mm_update_iforce_3atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
444 f+i_coord_offset+DIM,fshift+i_shift_offset);
447 /* Update potential energies */
448 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
450 /* Increment number of inner iterations */
451 inneriter += j_index_end - j_index_start;
453 /* Outer loop uses 19 flops */
456 /* Increment number of outer iterations */
459 /* Update outer/inner flops */
461 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_VF,outeriter*19 + inneriter*93);
464 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomW4P1_F_avx_128_fma_single
465 * Electrostatics interaction: Coulomb
466 * VdW interaction: None
467 * Geometry: Water4-Particle
468 * Calculate force/pot: Force
471 nb_kernel_ElecCoul_VdwNone_GeomW4P1_F_avx_128_fma_single
472 (t_nblist * gmx_restrict nlist,
473 rvec * gmx_restrict xx,
474 rvec * gmx_restrict ff,
475 t_forcerec * gmx_restrict fr,
476 t_mdatoms * gmx_restrict mdatoms,
477 nb_kernel_data_t * gmx_restrict kernel_data,
478 t_nrnb * gmx_restrict nrnb)
480 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
481 * just 0 for non-waters.
482 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
483 * jnr indices corresponding to data put in the four positions in the SIMD register.
485 int i_shift_offset,i_coord_offset,outeriter,inneriter;
486 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
487 int jnrA,jnrB,jnrC,jnrD;
488 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
489 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
490 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
492 real *shiftvec,*fshift,*x,*f;
493 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
495 __m128 fscal,rcutoff,rcutoff2,jidxall;
497 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
499 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
501 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
502 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
503 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
504 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
505 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
506 __m128 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
507 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
509 __m128 dummy_mask,cutoff_mask;
510 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
511 __m128 one = _mm_set1_ps(1.0);
512 __m128 two = _mm_set1_ps(2.0);
518 jindex = nlist->jindex;
520 shiftidx = nlist->shift;
522 shiftvec = fr->shift_vec[0];
523 fshift = fr->fshift[0];
524 facel = _mm_set1_ps(fr->epsfac);
525 charge = mdatoms->chargeA;
527 /* Setup water-specific parameters */
528 inr = nlist->iinr[0];
529 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
530 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
531 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
533 /* Avoid stupid compiler warnings */
534 jnrA = jnrB = jnrC = jnrD = 0;
543 for(iidx=0;iidx<4*DIM;iidx++)
548 /* Start outer loop over neighborlists */
549 for(iidx=0; iidx<nri; iidx++)
551 /* Load shift vector for this list */
552 i_shift_offset = DIM*shiftidx[iidx];
554 /* Load limits for loop over neighbors */
555 j_index_start = jindex[iidx];
556 j_index_end = jindex[iidx+1];
558 /* Get outer coordinate index */
560 i_coord_offset = DIM*inr;
562 /* Load i particle coords and add shift vector */
563 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset+DIM,
564 &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
566 fix1 = _mm_setzero_ps();
567 fiy1 = _mm_setzero_ps();
568 fiz1 = _mm_setzero_ps();
569 fix2 = _mm_setzero_ps();
570 fiy2 = _mm_setzero_ps();
571 fiz2 = _mm_setzero_ps();
572 fix3 = _mm_setzero_ps();
573 fiy3 = _mm_setzero_ps();
574 fiz3 = _mm_setzero_ps();
576 /* Start inner kernel loop */
577 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
580 /* Get j neighbor index, and coordinate index */
585 j_coord_offsetA = DIM*jnrA;
586 j_coord_offsetB = DIM*jnrB;
587 j_coord_offsetC = DIM*jnrC;
588 j_coord_offsetD = DIM*jnrD;
590 /* load j atom coordinates */
591 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
592 x+j_coord_offsetC,x+j_coord_offsetD,
595 /* Calculate displacement vector */
596 dx10 = _mm_sub_ps(ix1,jx0);
597 dy10 = _mm_sub_ps(iy1,jy0);
598 dz10 = _mm_sub_ps(iz1,jz0);
599 dx20 = _mm_sub_ps(ix2,jx0);
600 dy20 = _mm_sub_ps(iy2,jy0);
601 dz20 = _mm_sub_ps(iz2,jz0);
602 dx30 = _mm_sub_ps(ix3,jx0);
603 dy30 = _mm_sub_ps(iy3,jy0);
604 dz30 = _mm_sub_ps(iz3,jz0);
606 /* Calculate squared distance and things based on it */
607 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
608 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
609 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
611 rinv10 = gmx_mm_invsqrt_ps(rsq10);
612 rinv20 = gmx_mm_invsqrt_ps(rsq20);
613 rinv30 = gmx_mm_invsqrt_ps(rsq30);
615 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
616 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
617 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
619 /* Load parameters for j particles */
620 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
621 charge+jnrC+0,charge+jnrD+0);
623 fjx0 = _mm_setzero_ps();
624 fjy0 = _mm_setzero_ps();
625 fjz0 = _mm_setzero_ps();
627 /**************************
628 * CALCULATE INTERACTIONS *
629 **************************/
631 /* Compute parameters for interactions between i and j atoms */
632 qq10 = _mm_mul_ps(iq1,jq0);
634 /* COULOMB ELECTROSTATICS */
635 velec = _mm_mul_ps(qq10,rinv10);
636 felec = _mm_mul_ps(velec,rinvsq10);
640 /* Update vectorial force */
641 fix1 = _mm_macc_ps(dx10,fscal,fix1);
642 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
643 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
645 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
646 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
647 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
649 /**************************
650 * CALCULATE INTERACTIONS *
651 **************************/
653 /* Compute parameters for interactions between i and j atoms */
654 qq20 = _mm_mul_ps(iq2,jq0);
656 /* COULOMB ELECTROSTATICS */
657 velec = _mm_mul_ps(qq20,rinv20);
658 felec = _mm_mul_ps(velec,rinvsq20);
662 /* Update vectorial force */
663 fix2 = _mm_macc_ps(dx20,fscal,fix2);
664 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
665 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
667 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
668 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
669 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
671 /**************************
672 * CALCULATE INTERACTIONS *
673 **************************/
675 /* Compute parameters for interactions between i and j atoms */
676 qq30 = _mm_mul_ps(iq3,jq0);
678 /* COULOMB ELECTROSTATICS */
679 velec = _mm_mul_ps(qq30,rinv30);
680 felec = _mm_mul_ps(velec,rinvsq30);
684 /* Update vectorial force */
685 fix3 = _mm_macc_ps(dx30,fscal,fix3);
686 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
687 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
689 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
690 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
691 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
693 fjptrA = f+j_coord_offsetA;
694 fjptrB = f+j_coord_offsetB;
695 fjptrC = f+j_coord_offsetC;
696 fjptrD = f+j_coord_offsetD;
698 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
700 /* Inner loop uses 90 flops */
706 /* Get j neighbor index, and coordinate index */
707 jnrlistA = jjnr[jidx];
708 jnrlistB = jjnr[jidx+1];
709 jnrlistC = jjnr[jidx+2];
710 jnrlistD = jjnr[jidx+3];
711 /* Sign of each element will be negative for non-real atoms.
712 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
713 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
715 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
716 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
717 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
718 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
719 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
720 j_coord_offsetA = DIM*jnrA;
721 j_coord_offsetB = DIM*jnrB;
722 j_coord_offsetC = DIM*jnrC;
723 j_coord_offsetD = DIM*jnrD;
725 /* load j atom coordinates */
726 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
727 x+j_coord_offsetC,x+j_coord_offsetD,
730 /* Calculate displacement vector */
731 dx10 = _mm_sub_ps(ix1,jx0);
732 dy10 = _mm_sub_ps(iy1,jy0);
733 dz10 = _mm_sub_ps(iz1,jz0);
734 dx20 = _mm_sub_ps(ix2,jx0);
735 dy20 = _mm_sub_ps(iy2,jy0);
736 dz20 = _mm_sub_ps(iz2,jz0);
737 dx30 = _mm_sub_ps(ix3,jx0);
738 dy30 = _mm_sub_ps(iy3,jy0);
739 dz30 = _mm_sub_ps(iz3,jz0);
741 /* Calculate squared distance and things based on it */
742 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
743 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
744 rsq30 = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
746 rinv10 = gmx_mm_invsqrt_ps(rsq10);
747 rinv20 = gmx_mm_invsqrt_ps(rsq20);
748 rinv30 = gmx_mm_invsqrt_ps(rsq30);
750 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
751 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
752 rinvsq30 = _mm_mul_ps(rinv30,rinv30);
754 /* Load parameters for j particles */
755 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
756 charge+jnrC+0,charge+jnrD+0);
758 fjx0 = _mm_setzero_ps();
759 fjy0 = _mm_setzero_ps();
760 fjz0 = _mm_setzero_ps();
762 /**************************
763 * CALCULATE INTERACTIONS *
764 **************************/
766 /* Compute parameters for interactions between i and j atoms */
767 qq10 = _mm_mul_ps(iq1,jq0);
769 /* COULOMB ELECTROSTATICS */
770 velec = _mm_mul_ps(qq10,rinv10);
771 felec = _mm_mul_ps(velec,rinvsq10);
775 fscal = _mm_andnot_ps(dummy_mask,fscal);
777 /* Update vectorial force */
778 fix1 = _mm_macc_ps(dx10,fscal,fix1);
779 fiy1 = _mm_macc_ps(dy10,fscal,fiy1);
780 fiz1 = _mm_macc_ps(dz10,fscal,fiz1);
782 fjx0 = _mm_macc_ps(dx10,fscal,fjx0);
783 fjy0 = _mm_macc_ps(dy10,fscal,fjy0);
784 fjz0 = _mm_macc_ps(dz10,fscal,fjz0);
786 /**************************
787 * CALCULATE INTERACTIONS *
788 **************************/
790 /* Compute parameters for interactions between i and j atoms */
791 qq20 = _mm_mul_ps(iq2,jq0);
793 /* COULOMB ELECTROSTATICS */
794 velec = _mm_mul_ps(qq20,rinv20);
795 felec = _mm_mul_ps(velec,rinvsq20);
799 fscal = _mm_andnot_ps(dummy_mask,fscal);
801 /* Update vectorial force */
802 fix2 = _mm_macc_ps(dx20,fscal,fix2);
803 fiy2 = _mm_macc_ps(dy20,fscal,fiy2);
804 fiz2 = _mm_macc_ps(dz20,fscal,fiz2);
806 fjx0 = _mm_macc_ps(dx20,fscal,fjx0);
807 fjy0 = _mm_macc_ps(dy20,fscal,fjy0);
808 fjz0 = _mm_macc_ps(dz20,fscal,fjz0);
810 /**************************
811 * CALCULATE INTERACTIONS *
812 **************************/
814 /* Compute parameters for interactions between i and j atoms */
815 qq30 = _mm_mul_ps(iq3,jq0);
817 /* COULOMB ELECTROSTATICS */
818 velec = _mm_mul_ps(qq30,rinv30);
819 felec = _mm_mul_ps(velec,rinvsq30);
823 fscal = _mm_andnot_ps(dummy_mask,fscal);
825 /* Update vectorial force */
826 fix3 = _mm_macc_ps(dx30,fscal,fix3);
827 fiy3 = _mm_macc_ps(dy30,fscal,fiy3);
828 fiz3 = _mm_macc_ps(dz30,fscal,fiz3);
830 fjx0 = _mm_macc_ps(dx30,fscal,fjx0);
831 fjy0 = _mm_macc_ps(dy30,fscal,fjy0);
832 fjz0 = _mm_macc_ps(dz30,fscal,fjz0);
834 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
835 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
836 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
837 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
839 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
841 /* Inner loop uses 90 flops */
844 /* End of innermost loop */
846 gmx_mm_update_iforce_3atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
847 f+i_coord_offset+DIM,fshift+i_shift_offset);
849 /* Increment number of inner iterations */
850 inneriter += j_index_end - j_index_start;
852 /* Outer loop uses 18 flops */
855 /* Increment number of outer iterations */
858 /* Update outer/inner flops */
860 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4_F,outeriter*18 + inneriter*90);