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 sparc64_hpc_ace_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
49 #include "kernelutil_sparc64_hpc_ace_double.h"
52 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_VF_sparc64_hpc_ace_double
53 * Electrostatics interaction: ReactionField
54 * VdW interaction: LennardJones
55 * Geometry: Water4-Particle
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_VF_sparc64_hpc_ace_double
60 (t_nblist * gmx_restrict nlist,
61 rvec * gmx_restrict xx,
62 rvec * gmx_restrict ff,
63 t_forcerec * gmx_restrict fr,
64 t_mdatoms * gmx_restrict mdatoms,
65 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
66 t_nrnb * gmx_restrict nrnb)
68 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
69 * just 0 for non-waters.
70 * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
71 * jnr indices corresponding to data put in the four positions in the SIMD register.
73 int i_shift_offset,i_coord_offset,outeriter,inneriter;
74 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
76 int j_coord_offsetA,j_coord_offsetB;
77 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
79 real *shiftvec,*fshift,*x,*f;
80 _fjsp_v2r8 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
82 _fjsp_v2r8 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
84 _fjsp_v2r8 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
86 _fjsp_v2r8 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
88 _fjsp_v2r8 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
89 int vdwjidx0A,vdwjidx0B;
90 _fjsp_v2r8 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
91 _fjsp_v2r8 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
92 _fjsp_v2r8 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
93 _fjsp_v2r8 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
94 _fjsp_v2r8 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
95 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
98 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
101 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
102 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
103 _fjsp_v2r8 rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
104 real rswitch_scalar,d_scalar;
106 _fjsp_v2r8 dummy_mask,cutoff_mask;
107 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
108 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
109 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
116 jindex = nlist->jindex;
118 shiftidx = nlist->shift;
120 shiftvec = fr->shift_vec[0];
121 fshift = fr->fshift[0];
122 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
123 charge = mdatoms->chargeA;
124 krf = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
125 krf2 = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
126 crf = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
127 nvdwtype = fr->ntype;
129 vdwtype = mdatoms->typeA;
131 /* Setup water-specific parameters */
132 inr = nlist->iinr[0];
133 iq1 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
134 iq2 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
135 iq3 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
136 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
138 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
139 rcutoff_scalar = fr->rcoulomb;
140 rcutoff = gmx_fjsp_set1_v2r8(rcutoff_scalar);
141 rcutoff2 = _fjsp_mul_v2r8(rcutoff,rcutoff);
143 rswitch_scalar = fr->rvdw_switch;
144 rswitch = gmx_fjsp_set1_v2r8(rswitch_scalar);
145 /* Setup switch parameters */
146 d_scalar = rcutoff_scalar-rswitch_scalar;
147 d = gmx_fjsp_set1_v2r8(d_scalar);
148 swV3 = gmx_fjsp_set1_v2r8(-10.0/(d_scalar*d_scalar*d_scalar));
149 swV4 = gmx_fjsp_set1_v2r8( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
150 swV5 = gmx_fjsp_set1_v2r8( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
151 swF2 = gmx_fjsp_set1_v2r8(-30.0/(d_scalar*d_scalar*d_scalar));
152 swF3 = gmx_fjsp_set1_v2r8( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
153 swF4 = gmx_fjsp_set1_v2r8(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
155 /* Avoid stupid compiler warnings */
163 /* Start outer loop over neighborlists */
164 for(iidx=0; iidx<nri; iidx++)
166 /* Load shift vector for this list */
167 i_shift_offset = DIM*shiftidx[iidx];
169 /* Load limits for loop over neighbors */
170 j_index_start = jindex[iidx];
171 j_index_end = jindex[iidx+1];
173 /* Get outer coordinate index */
175 i_coord_offset = DIM*inr;
177 /* Load i particle coords and add shift vector */
178 gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
179 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
181 fix0 = _fjsp_setzero_v2r8();
182 fiy0 = _fjsp_setzero_v2r8();
183 fiz0 = _fjsp_setzero_v2r8();
184 fix1 = _fjsp_setzero_v2r8();
185 fiy1 = _fjsp_setzero_v2r8();
186 fiz1 = _fjsp_setzero_v2r8();
187 fix2 = _fjsp_setzero_v2r8();
188 fiy2 = _fjsp_setzero_v2r8();
189 fiz2 = _fjsp_setzero_v2r8();
190 fix3 = _fjsp_setzero_v2r8();
191 fiy3 = _fjsp_setzero_v2r8();
192 fiz3 = _fjsp_setzero_v2r8();
194 /* Reset potential sums */
195 velecsum = _fjsp_setzero_v2r8();
196 vvdwsum = _fjsp_setzero_v2r8();
198 /* Start inner kernel loop */
199 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
202 /* Get j neighbor index, and coordinate index */
205 j_coord_offsetA = DIM*jnrA;
206 j_coord_offsetB = DIM*jnrB;
208 /* load j atom coordinates */
209 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
212 /* Calculate displacement vector */
213 dx00 = _fjsp_sub_v2r8(ix0,jx0);
214 dy00 = _fjsp_sub_v2r8(iy0,jy0);
215 dz00 = _fjsp_sub_v2r8(iz0,jz0);
216 dx10 = _fjsp_sub_v2r8(ix1,jx0);
217 dy10 = _fjsp_sub_v2r8(iy1,jy0);
218 dz10 = _fjsp_sub_v2r8(iz1,jz0);
219 dx20 = _fjsp_sub_v2r8(ix2,jx0);
220 dy20 = _fjsp_sub_v2r8(iy2,jy0);
221 dz20 = _fjsp_sub_v2r8(iz2,jz0);
222 dx30 = _fjsp_sub_v2r8(ix3,jx0);
223 dy30 = _fjsp_sub_v2r8(iy3,jy0);
224 dz30 = _fjsp_sub_v2r8(iz3,jz0);
226 /* Calculate squared distance and things based on it */
227 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
228 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
229 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
230 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
232 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
233 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
234 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
235 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
237 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
238 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
239 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
240 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
242 /* Load parameters for j particles */
243 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
244 vdwjidx0A = 2*vdwtype[jnrA+0];
245 vdwjidx0B = 2*vdwtype[jnrB+0];
247 fjx0 = _fjsp_setzero_v2r8();
248 fjy0 = _fjsp_setzero_v2r8();
249 fjz0 = _fjsp_setzero_v2r8();
251 /**************************
252 * CALCULATE INTERACTIONS *
253 **************************/
255 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
258 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
260 /* Compute parameters for interactions between i and j atoms */
261 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
262 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
264 /* LENNARD-JONES DISPERSION/REPULSION */
266 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
267 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
268 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
269 vvdw = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
270 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
272 d = _fjsp_sub_v2r8(r00,rswitch);
273 d = _fjsp_max_v2r8(d,_fjsp_setzero_v2r8());
274 d2 = _fjsp_mul_v2r8(d,d);
275 sw = _fjsp_add_v2r8(one,_fjsp_mul_v2r8(d2,_fjsp_mul_v2r8(d,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swV5,swV4),swV3))));
277 dsw = _fjsp_mul_v2r8(d2,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swF4,swF3),swF2));
279 /* Evaluate switch function */
280 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
281 fvdw = _fjsp_msub_v2r8( fvdw,sw , _fjsp_mul_v2r8(rinv00,_fjsp_mul_v2r8(vvdw,dsw)) );
282 vvdw = _fjsp_mul_v2r8(vvdw,sw);
283 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
285 /* Update potential sum for this i atom from the interaction with this j atom. */
286 vvdw = _fjsp_and_v2r8(vvdw,cutoff_mask);
287 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
291 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
293 /* Update vectorial force */
294 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
295 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
296 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
298 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
299 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
300 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
304 /**************************
305 * CALCULATE INTERACTIONS *
306 **************************/
308 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
311 /* Compute parameters for interactions between i and j atoms */
312 qq10 = _fjsp_mul_v2r8(iq1,jq0);
314 /* REACTION-FIELD ELECTROSTATICS */
315 velec = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
316 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
318 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
320 /* Update potential sum for this i atom from the interaction with this j atom. */
321 velec = _fjsp_and_v2r8(velec,cutoff_mask);
322 velecsum = _fjsp_add_v2r8(velecsum,velec);
326 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
328 /* Update vectorial force */
329 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
330 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
331 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
333 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
334 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
335 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
339 /**************************
340 * CALCULATE INTERACTIONS *
341 **************************/
343 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
346 /* Compute parameters for interactions between i and j atoms */
347 qq20 = _fjsp_mul_v2r8(iq2,jq0);
349 /* REACTION-FIELD ELECTROSTATICS */
350 velec = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
351 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
353 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
355 /* Update potential sum for this i atom from the interaction with this j atom. */
356 velec = _fjsp_and_v2r8(velec,cutoff_mask);
357 velecsum = _fjsp_add_v2r8(velecsum,velec);
361 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
363 /* Update vectorial force */
364 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
365 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
366 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
368 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
369 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
370 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
374 /**************************
375 * CALCULATE INTERACTIONS *
376 **************************/
378 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
381 /* Compute parameters for interactions between i and j atoms */
382 qq30 = _fjsp_mul_v2r8(iq3,jq0);
384 /* REACTION-FIELD ELECTROSTATICS */
385 velec = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
386 felec = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
388 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
390 /* Update potential sum for this i atom from the interaction with this j atom. */
391 velec = _fjsp_and_v2r8(velec,cutoff_mask);
392 velecsum = _fjsp_add_v2r8(velecsum,velec);
396 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
398 /* Update vectorial force */
399 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
400 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
401 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
403 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
404 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
405 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
409 gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
411 /* Inner loop uses 182 flops */
418 j_coord_offsetA = DIM*jnrA;
420 /* load j atom coordinates */
421 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
424 /* Calculate displacement vector */
425 dx00 = _fjsp_sub_v2r8(ix0,jx0);
426 dy00 = _fjsp_sub_v2r8(iy0,jy0);
427 dz00 = _fjsp_sub_v2r8(iz0,jz0);
428 dx10 = _fjsp_sub_v2r8(ix1,jx0);
429 dy10 = _fjsp_sub_v2r8(iy1,jy0);
430 dz10 = _fjsp_sub_v2r8(iz1,jz0);
431 dx20 = _fjsp_sub_v2r8(ix2,jx0);
432 dy20 = _fjsp_sub_v2r8(iy2,jy0);
433 dz20 = _fjsp_sub_v2r8(iz2,jz0);
434 dx30 = _fjsp_sub_v2r8(ix3,jx0);
435 dy30 = _fjsp_sub_v2r8(iy3,jy0);
436 dz30 = _fjsp_sub_v2r8(iz3,jz0);
438 /* Calculate squared distance and things based on it */
439 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
440 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
441 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
442 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
444 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
445 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
446 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
447 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
449 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
450 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
451 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
452 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
454 /* Load parameters for j particles */
455 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
456 vdwjidx0A = 2*vdwtype[jnrA+0];
458 fjx0 = _fjsp_setzero_v2r8();
459 fjy0 = _fjsp_setzero_v2r8();
460 fjz0 = _fjsp_setzero_v2r8();
462 /**************************
463 * CALCULATE INTERACTIONS *
464 **************************/
466 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
469 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
471 /* Compute parameters for interactions between i and j atoms */
472 gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
474 /* LENNARD-JONES DISPERSION/REPULSION */
476 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
477 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
478 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
479 vvdw = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
480 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
482 d = _fjsp_sub_v2r8(r00,rswitch);
483 d = _fjsp_max_v2r8(d,_fjsp_setzero_v2r8());
484 d2 = _fjsp_mul_v2r8(d,d);
485 sw = _fjsp_add_v2r8(one,_fjsp_mul_v2r8(d2,_fjsp_mul_v2r8(d,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swV5,swV4),swV3))));
487 dsw = _fjsp_mul_v2r8(d2,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swF4,swF3),swF2));
489 /* Evaluate switch function */
490 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
491 fvdw = _fjsp_msub_v2r8( fvdw,sw , _fjsp_mul_v2r8(rinv00,_fjsp_mul_v2r8(vvdw,dsw)) );
492 vvdw = _fjsp_mul_v2r8(vvdw,sw);
493 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
495 /* Update potential sum for this i atom from the interaction with this j atom. */
496 vvdw = _fjsp_and_v2r8(vvdw,cutoff_mask);
497 vvdw = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
498 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
502 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
504 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
506 /* Update vectorial force */
507 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
508 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
509 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
511 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
512 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
513 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
517 /**************************
518 * CALCULATE INTERACTIONS *
519 **************************/
521 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
524 /* Compute parameters for interactions between i and j atoms */
525 qq10 = _fjsp_mul_v2r8(iq1,jq0);
527 /* REACTION-FIELD ELECTROSTATICS */
528 velec = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
529 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
531 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
533 /* Update potential sum for this i atom from the interaction with this j atom. */
534 velec = _fjsp_and_v2r8(velec,cutoff_mask);
535 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
536 velecsum = _fjsp_add_v2r8(velecsum,velec);
540 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
542 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
544 /* Update vectorial force */
545 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
546 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
547 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
549 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
550 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
551 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
555 /**************************
556 * CALCULATE INTERACTIONS *
557 **************************/
559 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
562 /* Compute parameters for interactions between i and j atoms */
563 qq20 = _fjsp_mul_v2r8(iq2,jq0);
565 /* REACTION-FIELD ELECTROSTATICS */
566 velec = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
567 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
569 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
571 /* Update potential sum for this i atom from the interaction with this j atom. */
572 velec = _fjsp_and_v2r8(velec,cutoff_mask);
573 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
574 velecsum = _fjsp_add_v2r8(velecsum,velec);
578 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
580 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
582 /* Update vectorial force */
583 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
584 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
585 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
587 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
588 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
589 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
593 /**************************
594 * CALCULATE INTERACTIONS *
595 **************************/
597 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
600 /* Compute parameters for interactions between i and j atoms */
601 qq30 = _fjsp_mul_v2r8(iq3,jq0);
603 /* REACTION-FIELD ELECTROSTATICS */
604 velec = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq30,rinv30),crf));
605 felec = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
607 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
609 /* Update potential sum for this i atom from the interaction with this j atom. */
610 velec = _fjsp_and_v2r8(velec,cutoff_mask);
611 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
612 velecsum = _fjsp_add_v2r8(velecsum,velec);
616 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
618 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
620 /* Update vectorial force */
621 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
622 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
623 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
625 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
626 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
627 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
631 gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
633 /* Inner loop uses 182 flops */
636 /* End of innermost loop */
638 gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
639 f+i_coord_offset,fshift+i_shift_offset);
642 /* Update potential energies */
643 gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
644 gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
646 /* Increment number of inner iterations */
647 inneriter += j_index_end - j_index_start;
649 /* Outer loop uses 26 flops */
652 /* Increment number of outer iterations */
655 /* Update outer/inner flops */
657 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*182);
660 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_sparc64_hpc_ace_double
661 * Electrostatics interaction: ReactionField
662 * VdW interaction: LennardJones
663 * Geometry: Water4-Particle
664 * Calculate force/pot: Force
667 nb_kernel_ElecRFCut_VdwLJSw_GeomW4P1_F_sparc64_hpc_ace_double
668 (t_nblist * gmx_restrict nlist,
669 rvec * gmx_restrict xx,
670 rvec * gmx_restrict ff,
671 t_forcerec * gmx_restrict fr,
672 t_mdatoms * gmx_restrict mdatoms,
673 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
674 t_nrnb * gmx_restrict nrnb)
676 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
677 * just 0 for non-waters.
678 * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
679 * jnr indices corresponding to data put in the four positions in the SIMD register.
681 int i_shift_offset,i_coord_offset,outeriter,inneriter;
682 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
684 int j_coord_offsetA,j_coord_offsetB;
685 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
687 real *shiftvec,*fshift,*x,*f;
688 _fjsp_v2r8 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
690 _fjsp_v2r8 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
692 _fjsp_v2r8 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
694 _fjsp_v2r8 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
696 _fjsp_v2r8 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
697 int vdwjidx0A,vdwjidx0B;
698 _fjsp_v2r8 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
699 _fjsp_v2r8 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
700 _fjsp_v2r8 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
701 _fjsp_v2r8 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
702 _fjsp_v2r8 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
703 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
706 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
709 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
710 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
711 _fjsp_v2r8 rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
712 real rswitch_scalar,d_scalar;
714 _fjsp_v2r8 dummy_mask,cutoff_mask;
715 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
716 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
717 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
724 jindex = nlist->jindex;
726 shiftidx = nlist->shift;
728 shiftvec = fr->shift_vec[0];
729 fshift = fr->fshift[0];
730 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
731 charge = mdatoms->chargeA;
732 krf = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
733 krf2 = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
734 crf = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
735 nvdwtype = fr->ntype;
737 vdwtype = mdatoms->typeA;
739 /* Setup water-specific parameters */
740 inr = nlist->iinr[0];
741 iq1 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
742 iq2 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
743 iq3 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
744 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
746 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
747 rcutoff_scalar = fr->rcoulomb;
748 rcutoff = gmx_fjsp_set1_v2r8(rcutoff_scalar);
749 rcutoff2 = _fjsp_mul_v2r8(rcutoff,rcutoff);
751 rswitch_scalar = fr->rvdw_switch;
752 rswitch = gmx_fjsp_set1_v2r8(rswitch_scalar);
753 /* Setup switch parameters */
754 d_scalar = rcutoff_scalar-rswitch_scalar;
755 d = gmx_fjsp_set1_v2r8(d_scalar);
756 swV3 = gmx_fjsp_set1_v2r8(-10.0/(d_scalar*d_scalar*d_scalar));
757 swV4 = gmx_fjsp_set1_v2r8( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
758 swV5 = gmx_fjsp_set1_v2r8( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
759 swF2 = gmx_fjsp_set1_v2r8(-30.0/(d_scalar*d_scalar*d_scalar));
760 swF3 = gmx_fjsp_set1_v2r8( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
761 swF4 = gmx_fjsp_set1_v2r8(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
763 /* Avoid stupid compiler warnings */
771 /* Start outer loop over neighborlists */
772 for(iidx=0; iidx<nri; iidx++)
774 /* Load shift vector for this list */
775 i_shift_offset = DIM*shiftidx[iidx];
777 /* Load limits for loop over neighbors */
778 j_index_start = jindex[iidx];
779 j_index_end = jindex[iidx+1];
781 /* Get outer coordinate index */
783 i_coord_offset = DIM*inr;
785 /* Load i particle coords and add shift vector */
786 gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
787 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
789 fix0 = _fjsp_setzero_v2r8();
790 fiy0 = _fjsp_setzero_v2r8();
791 fiz0 = _fjsp_setzero_v2r8();
792 fix1 = _fjsp_setzero_v2r8();
793 fiy1 = _fjsp_setzero_v2r8();
794 fiz1 = _fjsp_setzero_v2r8();
795 fix2 = _fjsp_setzero_v2r8();
796 fiy2 = _fjsp_setzero_v2r8();
797 fiz2 = _fjsp_setzero_v2r8();
798 fix3 = _fjsp_setzero_v2r8();
799 fiy3 = _fjsp_setzero_v2r8();
800 fiz3 = _fjsp_setzero_v2r8();
802 /* Start inner kernel loop */
803 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
806 /* Get j neighbor index, and coordinate index */
809 j_coord_offsetA = DIM*jnrA;
810 j_coord_offsetB = DIM*jnrB;
812 /* load j atom coordinates */
813 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
816 /* Calculate displacement vector */
817 dx00 = _fjsp_sub_v2r8(ix0,jx0);
818 dy00 = _fjsp_sub_v2r8(iy0,jy0);
819 dz00 = _fjsp_sub_v2r8(iz0,jz0);
820 dx10 = _fjsp_sub_v2r8(ix1,jx0);
821 dy10 = _fjsp_sub_v2r8(iy1,jy0);
822 dz10 = _fjsp_sub_v2r8(iz1,jz0);
823 dx20 = _fjsp_sub_v2r8(ix2,jx0);
824 dy20 = _fjsp_sub_v2r8(iy2,jy0);
825 dz20 = _fjsp_sub_v2r8(iz2,jz0);
826 dx30 = _fjsp_sub_v2r8(ix3,jx0);
827 dy30 = _fjsp_sub_v2r8(iy3,jy0);
828 dz30 = _fjsp_sub_v2r8(iz3,jz0);
830 /* Calculate squared distance and things based on it */
831 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
832 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
833 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
834 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
836 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
837 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
838 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
839 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
841 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
842 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
843 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
844 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
846 /* Load parameters for j particles */
847 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
848 vdwjidx0A = 2*vdwtype[jnrA+0];
849 vdwjidx0B = 2*vdwtype[jnrB+0];
851 fjx0 = _fjsp_setzero_v2r8();
852 fjy0 = _fjsp_setzero_v2r8();
853 fjz0 = _fjsp_setzero_v2r8();
855 /**************************
856 * CALCULATE INTERACTIONS *
857 **************************/
859 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
862 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
864 /* Compute parameters for interactions between i and j atoms */
865 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
866 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
868 /* LENNARD-JONES DISPERSION/REPULSION */
870 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
871 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
872 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
873 vvdw = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
874 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
876 d = _fjsp_sub_v2r8(r00,rswitch);
877 d = _fjsp_max_v2r8(d,_fjsp_setzero_v2r8());
878 d2 = _fjsp_mul_v2r8(d,d);
879 sw = _fjsp_add_v2r8(one,_fjsp_mul_v2r8(d2,_fjsp_mul_v2r8(d,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swV5,swV4),swV3))));
881 dsw = _fjsp_mul_v2r8(d2,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swF4,swF3),swF2));
883 /* Evaluate switch function */
884 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
885 fvdw = _fjsp_msub_v2r8( fvdw,sw , _fjsp_mul_v2r8(rinv00,_fjsp_mul_v2r8(vvdw,dsw)) );
886 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
890 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
892 /* Update vectorial force */
893 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
894 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
895 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
897 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
898 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
899 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
903 /**************************
904 * CALCULATE INTERACTIONS *
905 **************************/
907 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
910 /* Compute parameters for interactions between i and j atoms */
911 qq10 = _fjsp_mul_v2r8(iq1,jq0);
913 /* REACTION-FIELD ELECTROSTATICS */
914 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
916 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
920 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
922 /* Update vectorial force */
923 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
924 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
925 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
927 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
928 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
929 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
933 /**************************
934 * CALCULATE INTERACTIONS *
935 **************************/
937 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
940 /* Compute parameters for interactions between i and j atoms */
941 qq20 = _fjsp_mul_v2r8(iq2,jq0);
943 /* REACTION-FIELD ELECTROSTATICS */
944 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
946 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
950 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
952 /* Update vectorial force */
953 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
954 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
955 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
957 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
958 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
959 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
963 /**************************
964 * CALCULATE INTERACTIONS *
965 **************************/
967 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
970 /* Compute parameters for interactions between i and j atoms */
971 qq30 = _fjsp_mul_v2r8(iq3,jq0);
973 /* REACTION-FIELD ELECTROSTATICS */
974 felec = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
976 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
980 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
982 /* Update vectorial force */
983 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
984 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
985 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
987 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
988 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
989 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
993 gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
995 /* Inner loop uses 161 flops */
1002 j_coord_offsetA = DIM*jnrA;
1004 /* load j atom coordinates */
1005 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
1008 /* Calculate displacement vector */
1009 dx00 = _fjsp_sub_v2r8(ix0,jx0);
1010 dy00 = _fjsp_sub_v2r8(iy0,jy0);
1011 dz00 = _fjsp_sub_v2r8(iz0,jz0);
1012 dx10 = _fjsp_sub_v2r8(ix1,jx0);
1013 dy10 = _fjsp_sub_v2r8(iy1,jy0);
1014 dz10 = _fjsp_sub_v2r8(iz1,jz0);
1015 dx20 = _fjsp_sub_v2r8(ix2,jx0);
1016 dy20 = _fjsp_sub_v2r8(iy2,jy0);
1017 dz20 = _fjsp_sub_v2r8(iz2,jz0);
1018 dx30 = _fjsp_sub_v2r8(ix3,jx0);
1019 dy30 = _fjsp_sub_v2r8(iy3,jy0);
1020 dz30 = _fjsp_sub_v2r8(iz3,jz0);
1022 /* Calculate squared distance and things based on it */
1023 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1024 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
1025 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
1026 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
1028 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
1029 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
1030 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
1031 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
1033 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
1034 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
1035 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
1036 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
1038 /* Load parameters for j particles */
1039 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
1040 vdwjidx0A = 2*vdwtype[jnrA+0];
1042 fjx0 = _fjsp_setzero_v2r8();
1043 fjy0 = _fjsp_setzero_v2r8();
1044 fjz0 = _fjsp_setzero_v2r8();
1046 /**************************
1047 * CALCULATE INTERACTIONS *
1048 **************************/
1050 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
1053 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
1055 /* Compute parameters for interactions between i and j atoms */
1056 gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
1058 /* LENNARD-JONES DISPERSION/REPULSION */
1060 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
1061 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
1062 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
1063 vvdw = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
1064 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
1066 d = _fjsp_sub_v2r8(r00,rswitch);
1067 d = _fjsp_max_v2r8(d,_fjsp_setzero_v2r8());
1068 d2 = _fjsp_mul_v2r8(d,d);
1069 sw = _fjsp_add_v2r8(one,_fjsp_mul_v2r8(d2,_fjsp_mul_v2r8(d,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swV5,swV4),swV3))));
1071 dsw = _fjsp_mul_v2r8(d2,_fjsp_madd_v2r8(d,_fjsp_madd_v2r8(d,swF4,swF3),swF2));
1073 /* Evaluate switch function */
1074 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
1075 fvdw = _fjsp_msub_v2r8( fvdw,sw , _fjsp_mul_v2r8(rinv00,_fjsp_mul_v2r8(vvdw,dsw)) );
1076 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
1080 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1082 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1084 /* Update vectorial force */
1085 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
1086 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1087 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1089 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1090 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1091 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1095 /**************************
1096 * CALCULATE INTERACTIONS *
1097 **************************/
1099 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
1102 /* Compute parameters for interactions between i and j atoms */
1103 qq10 = _fjsp_mul_v2r8(iq1,jq0);
1105 /* REACTION-FIELD ELECTROSTATICS */
1106 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
1108 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
1112 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1114 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1116 /* Update vectorial force */
1117 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
1118 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
1119 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
1121 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
1122 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
1123 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
1127 /**************************
1128 * CALCULATE INTERACTIONS *
1129 **************************/
1131 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
1134 /* Compute parameters for interactions between i and j atoms */
1135 qq20 = _fjsp_mul_v2r8(iq2,jq0);
1137 /* REACTION-FIELD ELECTROSTATICS */
1138 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
1140 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
1144 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1146 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1148 /* Update vectorial force */
1149 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
1150 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1151 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1153 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1154 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1155 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1159 /**************************
1160 * CALCULATE INTERACTIONS *
1161 **************************/
1163 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
1166 /* Compute parameters for interactions between i and j atoms */
1167 qq30 = _fjsp_mul_v2r8(iq3,jq0);
1169 /* REACTION-FIELD ELECTROSTATICS */
1170 felec = _fjsp_mul_v2r8(qq30,_fjsp_msub_v2r8(rinv30,rinvsq30,krf2));
1172 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
1176 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1178 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1180 /* Update vectorial force */
1181 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
1182 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
1183 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
1185 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
1186 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
1187 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
1191 gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1193 /* Inner loop uses 161 flops */
1196 /* End of innermost loop */
1198 gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1199 f+i_coord_offset,fshift+i_shift_offset);
1201 /* Increment number of inner iterations */
1202 inneriter += j_index_end - j_index_start;
1204 /* Outer loop uses 24 flops */
1207 /* Increment number of outer iterations */
1210 /* Update outer/inner flops */
1212 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*161);