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 "types/simple.h"
46 #include "gromacs/legacyheaders/vec.h"
49 #include "kernelutil_sparc64_hpc_ace_double.h"
52 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_VF_sparc64_hpc_ace_double
53 * Electrostatics interaction: ReactionField
54 * VdW interaction: LennardJones
55 * Geometry: Water3-Particle
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_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;
87 int vdwjidx0A,vdwjidx0B;
88 _fjsp_v2r8 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89 _fjsp_v2r8 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
90 _fjsp_v2r8 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
91 _fjsp_v2r8 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
92 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
95 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
98 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
99 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
101 _fjsp_v2r8 dummy_mask,cutoff_mask;
102 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
103 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
104 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
111 jindex = nlist->jindex;
113 shiftidx = nlist->shift;
115 shiftvec = fr->shift_vec[0];
116 fshift = fr->fshift[0];
117 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
118 charge = mdatoms->chargeA;
119 krf = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
120 krf2 = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
121 crf = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
122 nvdwtype = fr->ntype;
124 vdwtype = mdatoms->typeA;
126 /* Setup water-specific parameters */
127 inr = nlist->iinr[0];
128 iq0 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+0]));
129 iq1 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
130 iq2 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
131 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
133 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
134 rcutoff_scalar = fr->rcoulomb;
135 rcutoff = gmx_fjsp_set1_v2r8(rcutoff_scalar);
136 rcutoff2 = _fjsp_mul_v2r8(rcutoff,rcutoff);
138 sh_vdw_invrcut6 = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
139 rvdw = gmx_fjsp_set1_v2r8(fr->rvdw);
141 /* Avoid stupid compiler warnings */
149 /* Start outer loop over neighborlists */
150 for(iidx=0; iidx<nri; iidx++)
152 /* Load shift vector for this list */
153 i_shift_offset = DIM*shiftidx[iidx];
155 /* Load limits for loop over neighbors */
156 j_index_start = jindex[iidx];
157 j_index_end = jindex[iidx+1];
159 /* Get outer coordinate index */
161 i_coord_offset = DIM*inr;
163 /* Load i particle coords and add shift vector */
164 gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
165 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
167 fix0 = _fjsp_setzero_v2r8();
168 fiy0 = _fjsp_setzero_v2r8();
169 fiz0 = _fjsp_setzero_v2r8();
170 fix1 = _fjsp_setzero_v2r8();
171 fiy1 = _fjsp_setzero_v2r8();
172 fiz1 = _fjsp_setzero_v2r8();
173 fix2 = _fjsp_setzero_v2r8();
174 fiy2 = _fjsp_setzero_v2r8();
175 fiz2 = _fjsp_setzero_v2r8();
177 /* Reset potential sums */
178 velecsum = _fjsp_setzero_v2r8();
179 vvdwsum = _fjsp_setzero_v2r8();
181 /* Start inner kernel loop */
182 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
185 /* Get j neighbor index, and coordinate index */
188 j_coord_offsetA = DIM*jnrA;
189 j_coord_offsetB = DIM*jnrB;
191 /* load j atom coordinates */
192 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
195 /* Calculate displacement vector */
196 dx00 = _fjsp_sub_v2r8(ix0,jx0);
197 dy00 = _fjsp_sub_v2r8(iy0,jy0);
198 dz00 = _fjsp_sub_v2r8(iz0,jz0);
199 dx10 = _fjsp_sub_v2r8(ix1,jx0);
200 dy10 = _fjsp_sub_v2r8(iy1,jy0);
201 dz10 = _fjsp_sub_v2r8(iz1,jz0);
202 dx20 = _fjsp_sub_v2r8(ix2,jx0);
203 dy20 = _fjsp_sub_v2r8(iy2,jy0);
204 dz20 = _fjsp_sub_v2r8(iz2,jz0);
206 /* Calculate squared distance and things based on it */
207 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
208 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
209 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
211 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
212 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
213 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
215 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
216 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
217 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
219 /* Load parameters for j particles */
220 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
221 vdwjidx0A = 2*vdwtype[jnrA+0];
222 vdwjidx0B = 2*vdwtype[jnrB+0];
224 fjx0 = _fjsp_setzero_v2r8();
225 fjy0 = _fjsp_setzero_v2r8();
226 fjz0 = _fjsp_setzero_v2r8();
228 /**************************
229 * CALCULATE INTERACTIONS *
230 **************************/
232 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
235 /* Compute parameters for interactions between i and j atoms */
236 qq00 = _fjsp_mul_v2r8(iq0,jq0);
237 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
238 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
240 /* REACTION-FIELD ELECTROSTATICS */
241 velec = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
242 felec = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
244 /* LENNARD-JONES DISPERSION/REPULSION */
246 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
247 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
248 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
249 vvdw = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
250 _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
251 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
253 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
255 /* Update potential sum for this i atom from the interaction with this j atom. */
256 velec = _fjsp_and_v2r8(velec,cutoff_mask);
257 velecsum = _fjsp_add_v2r8(velecsum,velec);
258 vvdw = _fjsp_and_v2r8(vvdw,cutoff_mask);
259 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
261 fscal = _fjsp_add_v2r8(felec,fvdw);
263 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
265 /* Update vectorial force */
266 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
267 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
268 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
270 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
271 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
272 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
276 /**************************
277 * CALCULATE INTERACTIONS *
278 **************************/
280 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
283 /* Compute parameters for interactions between i and j atoms */
284 qq10 = _fjsp_mul_v2r8(iq1,jq0);
286 /* REACTION-FIELD ELECTROSTATICS */
287 velec = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
288 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
290 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
292 /* Update potential sum for this i atom from the interaction with this j atom. */
293 velec = _fjsp_and_v2r8(velec,cutoff_mask);
294 velecsum = _fjsp_add_v2r8(velecsum,velec);
298 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
300 /* Update vectorial force */
301 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
302 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
303 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
305 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
306 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
307 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
311 /**************************
312 * CALCULATE INTERACTIONS *
313 **************************/
315 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
318 /* Compute parameters for interactions between i and j atoms */
319 qq20 = _fjsp_mul_v2r8(iq2,jq0);
321 /* REACTION-FIELD ELECTROSTATICS */
322 velec = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
323 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
325 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
327 /* Update potential sum for this i atom from the interaction with this j atom. */
328 velec = _fjsp_and_v2r8(velec,cutoff_mask);
329 velecsum = _fjsp_add_v2r8(velecsum,velec);
333 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
335 /* Update vectorial force */
336 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
337 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
338 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
340 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
341 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
342 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
346 gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
348 /* Inner loop uses 138 flops */
355 j_coord_offsetA = DIM*jnrA;
357 /* load j atom coordinates */
358 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
361 /* Calculate displacement vector */
362 dx00 = _fjsp_sub_v2r8(ix0,jx0);
363 dy00 = _fjsp_sub_v2r8(iy0,jy0);
364 dz00 = _fjsp_sub_v2r8(iz0,jz0);
365 dx10 = _fjsp_sub_v2r8(ix1,jx0);
366 dy10 = _fjsp_sub_v2r8(iy1,jy0);
367 dz10 = _fjsp_sub_v2r8(iz1,jz0);
368 dx20 = _fjsp_sub_v2r8(ix2,jx0);
369 dy20 = _fjsp_sub_v2r8(iy2,jy0);
370 dz20 = _fjsp_sub_v2r8(iz2,jz0);
372 /* Calculate squared distance and things based on it */
373 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
374 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
375 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
377 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
378 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
379 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
381 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
382 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
383 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
385 /* Load parameters for j particles */
386 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
387 vdwjidx0A = 2*vdwtype[jnrA+0];
389 fjx0 = _fjsp_setzero_v2r8();
390 fjy0 = _fjsp_setzero_v2r8();
391 fjz0 = _fjsp_setzero_v2r8();
393 /**************************
394 * CALCULATE INTERACTIONS *
395 **************************/
397 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
400 /* Compute parameters for interactions between i and j atoms */
401 qq00 = _fjsp_mul_v2r8(iq0,jq0);
402 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
403 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
405 /* REACTION-FIELD ELECTROSTATICS */
406 velec = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
407 felec = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
409 /* LENNARD-JONES DISPERSION/REPULSION */
411 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
412 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
413 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
414 vvdw = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
415 _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
416 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
418 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
420 /* Update potential sum for this i atom from the interaction with this j atom. */
421 velec = _fjsp_and_v2r8(velec,cutoff_mask);
422 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
423 velecsum = _fjsp_add_v2r8(velecsum,velec);
424 vvdw = _fjsp_and_v2r8(vvdw,cutoff_mask);
425 vvdw = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
426 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
428 fscal = _fjsp_add_v2r8(felec,fvdw);
430 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
432 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
434 /* Update vectorial force */
435 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
436 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
437 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
439 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
440 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
441 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
445 /**************************
446 * CALCULATE INTERACTIONS *
447 **************************/
449 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
452 /* Compute parameters for interactions between i and j atoms */
453 qq10 = _fjsp_mul_v2r8(iq1,jq0);
455 /* REACTION-FIELD ELECTROSTATICS */
456 velec = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
457 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
459 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
461 /* Update potential sum for this i atom from the interaction with this j atom. */
462 velec = _fjsp_and_v2r8(velec,cutoff_mask);
463 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
464 velecsum = _fjsp_add_v2r8(velecsum,velec);
468 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
470 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
472 /* Update vectorial force */
473 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
474 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
475 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
477 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
478 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
479 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
483 /**************************
484 * CALCULATE INTERACTIONS *
485 **************************/
487 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
490 /* Compute parameters for interactions between i and j atoms */
491 qq20 = _fjsp_mul_v2r8(iq2,jq0);
493 /* REACTION-FIELD ELECTROSTATICS */
494 velec = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
495 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
497 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
499 /* Update potential sum for this i atom from the interaction with this j atom. */
500 velec = _fjsp_and_v2r8(velec,cutoff_mask);
501 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
502 velecsum = _fjsp_add_v2r8(velecsum,velec);
506 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
508 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
510 /* Update vectorial force */
511 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
512 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
513 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
515 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
516 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
517 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
521 gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
523 /* Inner loop uses 138 flops */
526 /* End of innermost loop */
528 gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
529 f+i_coord_offset,fshift+i_shift_offset);
532 /* Update potential energies */
533 gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
534 gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
536 /* Increment number of inner iterations */
537 inneriter += j_index_end - j_index_start;
539 /* Outer loop uses 20 flops */
542 /* Increment number of outer iterations */
545 /* Update outer/inner flops */
547 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*138);
550 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_F_sparc64_hpc_ace_double
551 * Electrostatics interaction: ReactionField
552 * VdW interaction: LennardJones
553 * Geometry: Water3-Particle
554 * Calculate force/pot: Force
557 nb_kernel_ElecRFCut_VdwLJSh_GeomW3P1_F_sparc64_hpc_ace_double
558 (t_nblist * gmx_restrict nlist,
559 rvec * gmx_restrict xx,
560 rvec * gmx_restrict ff,
561 t_forcerec * gmx_restrict fr,
562 t_mdatoms * gmx_restrict mdatoms,
563 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
564 t_nrnb * gmx_restrict nrnb)
566 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
567 * just 0 for non-waters.
568 * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
569 * jnr indices corresponding to data put in the four positions in the SIMD register.
571 int i_shift_offset,i_coord_offset,outeriter,inneriter;
572 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
574 int j_coord_offsetA,j_coord_offsetB;
575 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
577 real *shiftvec,*fshift,*x,*f;
578 _fjsp_v2r8 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
580 _fjsp_v2r8 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
582 _fjsp_v2r8 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
584 _fjsp_v2r8 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
585 int vdwjidx0A,vdwjidx0B;
586 _fjsp_v2r8 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
587 _fjsp_v2r8 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
588 _fjsp_v2r8 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
589 _fjsp_v2r8 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
590 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
593 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
596 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
597 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
599 _fjsp_v2r8 dummy_mask,cutoff_mask;
600 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
601 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
602 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
609 jindex = nlist->jindex;
611 shiftidx = nlist->shift;
613 shiftvec = fr->shift_vec[0];
614 fshift = fr->fshift[0];
615 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
616 charge = mdatoms->chargeA;
617 krf = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
618 krf2 = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
619 crf = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
620 nvdwtype = fr->ntype;
622 vdwtype = mdatoms->typeA;
624 /* Setup water-specific parameters */
625 inr = nlist->iinr[0];
626 iq0 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+0]));
627 iq1 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
628 iq2 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
629 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
631 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
632 rcutoff_scalar = fr->rcoulomb;
633 rcutoff = gmx_fjsp_set1_v2r8(rcutoff_scalar);
634 rcutoff2 = _fjsp_mul_v2r8(rcutoff,rcutoff);
636 sh_vdw_invrcut6 = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
637 rvdw = gmx_fjsp_set1_v2r8(fr->rvdw);
639 /* Avoid stupid compiler warnings */
647 /* Start outer loop over neighborlists */
648 for(iidx=0; iidx<nri; iidx++)
650 /* Load shift vector for this list */
651 i_shift_offset = DIM*shiftidx[iidx];
653 /* Load limits for loop over neighbors */
654 j_index_start = jindex[iidx];
655 j_index_end = jindex[iidx+1];
657 /* Get outer coordinate index */
659 i_coord_offset = DIM*inr;
661 /* Load i particle coords and add shift vector */
662 gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
663 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
665 fix0 = _fjsp_setzero_v2r8();
666 fiy0 = _fjsp_setzero_v2r8();
667 fiz0 = _fjsp_setzero_v2r8();
668 fix1 = _fjsp_setzero_v2r8();
669 fiy1 = _fjsp_setzero_v2r8();
670 fiz1 = _fjsp_setzero_v2r8();
671 fix2 = _fjsp_setzero_v2r8();
672 fiy2 = _fjsp_setzero_v2r8();
673 fiz2 = _fjsp_setzero_v2r8();
675 /* Start inner kernel loop */
676 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
679 /* Get j neighbor index, and coordinate index */
682 j_coord_offsetA = DIM*jnrA;
683 j_coord_offsetB = DIM*jnrB;
685 /* load j atom coordinates */
686 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
689 /* Calculate displacement vector */
690 dx00 = _fjsp_sub_v2r8(ix0,jx0);
691 dy00 = _fjsp_sub_v2r8(iy0,jy0);
692 dz00 = _fjsp_sub_v2r8(iz0,jz0);
693 dx10 = _fjsp_sub_v2r8(ix1,jx0);
694 dy10 = _fjsp_sub_v2r8(iy1,jy0);
695 dz10 = _fjsp_sub_v2r8(iz1,jz0);
696 dx20 = _fjsp_sub_v2r8(ix2,jx0);
697 dy20 = _fjsp_sub_v2r8(iy2,jy0);
698 dz20 = _fjsp_sub_v2r8(iz2,jz0);
700 /* Calculate squared distance and things based on it */
701 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
702 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
703 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
705 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
706 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
707 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
709 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
710 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
711 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
713 /* Load parameters for j particles */
714 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
715 vdwjidx0A = 2*vdwtype[jnrA+0];
716 vdwjidx0B = 2*vdwtype[jnrB+0];
718 fjx0 = _fjsp_setzero_v2r8();
719 fjy0 = _fjsp_setzero_v2r8();
720 fjz0 = _fjsp_setzero_v2r8();
722 /**************************
723 * CALCULATE INTERACTIONS *
724 **************************/
726 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
729 /* Compute parameters for interactions between i and j atoms */
730 qq00 = _fjsp_mul_v2r8(iq0,jq0);
731 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
732 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
734 /* REACTION-FIELD ELECTROSTATICS */
735 felec = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
737 /* LENNARD-JONES DISPERSION/REPULSION */
739 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
740 fvdw = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
742 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
744 fscal = _fjsp_add_v2r8(felec,fvdw);
746 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
748 /* Update vectorial force */
749 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
750 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
751 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
753 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
754 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
755 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
759 /**************************
760 * CALCULATE INTERACTIONS *
761 **************************/
763 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
766 /* Compute parameters for interactions between i and j atoms */
767 qq10 = _fjsp_mul_v2r8(iq1,jq0);
769 /* REACTION-FIELD ELECTROSTATICS */
770 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
772 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
776 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
778 /* Update vectorial force */
779 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
780 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
781 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
783 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
784 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
785 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
789 /**************************
790 * CALCULATE INTERACTIONS *
791 **************************/
793 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
796 /* Compute parameters for interactions between i and j atoms */
797 qq20 = _fjsp_mul_v2r8(iq2,jq0);
799 /* REACTION-FIELD ELECTROSTATICS */
800 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
802 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
806 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
808 /* Update vectorial force */
809 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
810 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
811 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
813 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
814 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
815 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
819 gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
821 /* Inner loop uses 109 flops */
828 j_coord_offsetA = DIM*jnrA;
830 /* load j atom coordinates */
831 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
834 /* Calculate displacement vector */
835 dx00 = _fjsp_sub_v2r8(ix0,jx0);
836 dy00 = _fjsp_sub_v2r8(iy0,jy0);
837 dz00 = _fjsp_sub_v2r8(iz0,jz0);
838 dx10 = _fjsp_sub_v2r8(ix1,jx0);
839 dy10 = _fjsp_sub_v2r8(iy1,jy0);
840 dz10 = _fjsp_sub_v2r8(iz1,jz0);
841 dx20 = _fjsp_sub_v2r8(ix2,jx0);
842 dy20 = _fjsp_sub_v2r8(iy2,jy0);
843 dz20 = _fjsp_sub_v2r8(iz2,jz0);
845 /* Calculate squared distance and things based on it */
846 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
847 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
848 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
850 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
851 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
852 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
854 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
855 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
856 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
858 /* Load parameters for j particles */
859 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
860 vdwjidx0A = 2*vdwtype[jnrA+0];
862 fjx0 = _fjsp_setzero_v2r8();
863 fjy0 = _fjsp_setzero_v2r8();
864 fjz0 = _fjsp_setzero_v2r8();
866 /**************************
867 * CALCULATE INTERACTIONS *
868 **************************/
870 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
873 /* Compute parameters for interactions between i and j atoms */
874 qq00 = _fjsp_mul_v2r8(iq0,jq0);
875 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
876 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
878 /* REACTION-FIELD ELECTROSTATICS */
879 felec = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
881 /* LENNARD-JONES DISPERSION/REPULSION */
883 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
884 fvdw = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
886 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
888 fscal = _fjsp_add_v2r8(felec,fvdw);
890 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
892 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
894 /* Update vectorial force */
895 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
896 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
897 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
899 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
900 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
901 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
905 /**************************
906 * CALCULATE INTERACTIONS *
907 **************************/
909 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
912 /* Compute parameters for interactions between i and j atoms */
913 qq10 = _fjsp_mul_v2r8(iq1,jq0);
915 /* REACTION-FIELD ELECTROSTATICS */
916 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
918 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
922 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
924 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
926 /* Update vectorial force */
927 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
928 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
929 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
931 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
932 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
933 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
937 /**************************
938 * CALCULATE INTERACTIONS *
939 **************************/
941 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
944 /* Compute parameters for interactions between i and j atoms */
945 qq20 = _fjsp_mul_v2r8(iq2,jq0);
947 /* REACTION-FIELD ELECTROSTATICS */
948 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
950 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
954 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
956 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
958 /* Update vectorial force */
959 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
960 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
961 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
963 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
964 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
965 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
969 gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
971 /* Inner loop uses 109 flops */
974 /* End of innermost loop */
976 gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
977 f+i_coord_offset,fshift+i_shift_offset);
979 /* Increment number of inner iterations */
980 inneriter += j_index_end - j_index_start;
982 /* Outer loop uses 18 flops */
985 /* Increment number of outer iterations */
988 /* Update outer/inner flops */
990 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*109);