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_ElecRF_VdwLJ_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_ElecRF_VdwLJ_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 /* Avoid stupid compiler warnings */
141 /* Start outer loop over neighborlists */
142 for(iidx=0; iidx<nri; iidx++)
144 /* Load shift vector for this list */
145 i_shift_offset = DIM*shiftidx[iidx];
147 /* Load limits for loop over neighbors */
148 j_index_start = jindex[iidx];
149 j_index_end = jindex[iidx+1];
151 /* Get outer coordinate index */
153 i_coord_offset = DIM*inr;
155 /* Load i particle coords and add shift vector */
156 gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
157 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
159 fix0 = _fjsp_setzero_v2r8();
160 fiy0 = _fjsp_setzero_v2r8();
161 fiz0 = _fjsp_setzero_v2r8();
162 fix1 = _fjsp_setzero_v2r8();
163 fiy1 = _fjsp_setzero_v2r8();
164 fiz1 = _fjsp_setzero_v2r8();
165 fix2 = _fjsp_setzero_v2r8();
166 fiy2 = _fjsp_setzero_v2r8();
167 fiz2 = _fjsp_setzero_v2r8();
169 /* Reset potential sums */
170 velecsum = _fjsp_setzero_v2r8();
171 vvdwsum = _fjsp_setzero_v2r8();
173 /* Start inner kernel loop */
174 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
177 /* Get j neighbor index, and coordinate index */
180 j_coord_offsetA = DIM*jnrA;
181 j_coord_offsetB = DIM*jnrB;
183 /* load j atom coordinates */
184 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
187 /* Calculate displacement vector */
188 dx00 = _fjsp_sub_v2r8(ix0,jx0);
189 dy00 = _fjsp_sub_v2r8(iy0,jy0);
190 dz00 = _fjsp_sub_v2r8(iz0,jz0);
191 dx10 = _fjsp_sub_v2r8(ix1,jx0);
192 dy10 = _fjsp_sub_v2r8(iy1,jy0);
193 dz10 = _fjsp_sub_v2r8(iz1,jz0);
194 dx20 = _fjsp_sub_v2r8(ix2,jx0);
195 dy20 = _fjsp_sub_v2r8(iy2,jy0);
196 dz20 = _fjsp_sub_v2r8(iz2,jz0);
198 /* Calculate squared distance and things based on it */
199 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
200 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
201 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
203 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
204 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
205 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
207 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
208 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
209 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
211 /* Load parameters for j particles */
212 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
213 vdwjidx0A = 2*vdwtype[jnrA+0];
214 vdwjidx0B = 2*vdwtype[jnrB+0];
216 fjx0 = _fjsp_setzero_v2r8();
217 fjy0 = _fjsp_setzero_v2r8();
218 fjz0 = _fjsp_setzero_v2r8();
220 /**************************
221 * CALCULATE INTERACTIONS *
222 **************************/
224 /* Compute parameters for interactions between i and j atoms */
225 qq00 = _fjsp_mul_v2r8(iq0,jq0);
226 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
227 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
229 /* REACTION-FIELD ELECTROSTATICS */
230 velec = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
231 felec = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
233 /* LENNARD-JONES DISPERSION/REPULSION */
235 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
236 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
237 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
238 vvdw = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
239 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
241 /* Update potential sum for this i atom from the interaction with this j atom. */
242 velecsum = _fjsp_add_v2r8(velecsum,velec);
243 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
245 fscal = _fjsp_add_v2r8(felec,fvdw);
247 /* Update vectorial force */
248 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
249 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
250 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
252 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
253 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
254 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
256 /**************************
257 * CALCULATE INTERACTIONS *
258 **************************/
260 /* Compute parameters for interactions between i and j atoms */
261 qq10 = _fjsp_mul_v2r8(iq1,jq0);
263 /* REACTION-FIELD ELECTROSTATICS */
264 velec = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
265 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
267 /* Update potential sum for this i atom from the interaction with this j atom. */
268 velecsum = _fjsp_add_v2r8(velecsum,velec);
272 /* Update vectorial force */
273 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
274 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
275 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
277 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
278 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
279 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
281 /**************************
282 * CALCULATE INTERACTIONS *
283 **************************/
285 /* Compute parameters for interactions between i and j atoms */
286 qq20 = _fjsp_mul_v2r8(iq2,jq0);
288 /* REACTION-FIELD ELECTROSTATICS */
289 velec = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
290 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
292 /* Update potential sum for this i atom from the interaction with this j atom. */
293 velecsum = _fjsp_add_v2r8(velecsum,velec);
297 /* Update vectorial force */
298 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
299 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
300 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
302 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
303 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
304 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
306 gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
308 /* Inner loop uses 120 flops */
315 j_coord_offsetA = DIM*jnrA;
317 /* load j atom coordinates */
318 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
321 /* Calculate displacement vector */
322 dx00 = _fjsp_sub_v2r8(ix0,jx0);
323 dy00 = _fjsp_sub_v2r8(iy0,jy0);
324 dz00 = _fjsp_sub_v2r8(iz0,jz0);
325 dx10 = _fjsp_sub_v2r8(ix1,jx0);
326 dy10 = _fjsp_sub_v2r8(iy1,jy0);
327 dz10 = _fjsp_sub_v2r8(iz1,jz0);
328 dx20 = _fjsp_sub_v2r8(ix2,jx0);
329 dy20 = _fjsp_sub_v2r8(iy2,jy0);
330 dz20 = _fjsp_sub_v2r8(iz2,jz0);
332 /* Calculate squared distance and things based on it */
333 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
334 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
335 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
337 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
338 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
339 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
341 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
342 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
343 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
345 /* Load parameters for j particles */
346 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
347 vdwjidx0A = 2*vdwtype[jnrA+0];
349 fjx0 = _fjsp_setzero_v2r8();
350 fjy0 = _fjsp_setzero_v2r8();
351 fjz0 = _fjsp_setzero_v2r8();
353 /**************************
354 * CALCULATE INTERACTIONS *
355 **************************/
357 /* Compute parameters for interactions between i and j atoms */
358 qq00 = _fjsp_mul_v2r8(iq0,jq0);
359 gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
361 /* REACTION-FIELD ELECTROSTATICS */
362 velec = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq00,rinv00),crf));
363 felec = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
365 /* LENNARD-JONES DISPERSION/REPULSION */
367 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
368 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
369 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
370 vvdw = _fjsp_msub_v2r8( vvdw12,one_twelfth, _fjsp_mul_v2r8(vvdw6,one_sixth) );
371 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
373 /* Update potential sum for this i atom from the interaction with this j atom. */
374 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
375 velecsum = _fjsp_add_v2r8(velecsum,velec);
376 vvdw = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
377 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
379 fscal = _fjsp_add_v2r8(felec,fvdw);
381 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
383 /* Update vectorial force */
384 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
385 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
386 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
388 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
389 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
390 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
392 /**************************
393 * CALCULATE INTERACTIONS *
394 **************************/
396 /* Compute parameters for interactions between i and j atoms */
397 qq10 = _fjsp_mul_v2r8(iq1,jq0);
399 /* REACTION-FIELD ELECTROSTATICS */
400 velec = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq10,rinv10),crf));
401 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
403 /* Update potential sum for this i atom from the interaction with this j atom. */
404 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
405 velecsum = _fjsp_add_v2r8(velecsum,velec);
409 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
411 /* Update vectorial force */
412 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
413 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
414 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
416 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
417 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
418 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
420 /**************************
421 * CALCULATE INTERACTIONS *
422 **************************/
424 /* Compute parameters for interactions between i and j atoms */
425 qq20 = _fjsp_mul_v2r8(iq2,jq0);
427 /* REACTION-FIELD ELECTROSTATICS */
428 velec = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_madd_v2r8(krf,rsq20,rinv20),crf));
429 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
431 /* Update potential sum for this i atom from the interaction with this j atom. */
432 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
433 velecsum = _fjsp_add_v2r8(velecsum,velec);
437 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
439 /* Update vectorial force */
440 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
441 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
442 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
444 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
445 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
446 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
448 gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
450 /* Inner loop uses 120 flops */
453 /* End of innermost loop */
455 gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
456 f+i_coord_offset,fshift+i_shift_offset);
459 /* Update potential energies */
460 gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
461 gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
463 /* Increment number of inner iterations */
464 inneriter += j_index_end - j_index_start;
466 /* Outer loop uses 20 flops */
469 /* Increment number of outer iterations */
472 /* Update outer/inner flops */
474 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*120);
477 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW3P1_F_sparc64_hpc_ace_double
478 * Electrostatics interaction: ReactionField
479 * VdW interaction: LennardJones
480 * Geometry: Water3-Particle
481 * Calculate force/pot: Force
484 nb_kernel_ElecRF_VdwLJ_GeomW3P1_F_sparc64_hpc_ace_double
485 (t_nblist * gmx_restrict nlist,
486 rvec * gmx_restrict xx,
487 rvec * gmx_restrict ff,
488 t_forcerec * gmx_restrict fr,
489 t_mdatoms * gmx_restrict mdatoms,
490 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
491 t_nrnb * gmx_restrict nrnb)
493 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
494 * just 0 for non-waters.
495 * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
496 * jnr indices corresponding to data put in the four positions in the SIMD register.
498 int i_shift_offset,i_coord_offset,outeriter,inneriter;
499 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
501 int j_coord_offsetA,j_coord_offsetB;
502 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
504 real *shiftvec,*fshift,*x,*f;
505 _fjsp_v2r8 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
507 _fjsp_v2r8 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
509 _fjsp_v2r8 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
511 _fjsp_v2r8 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
512 int vdwjidx0A,vdwjidx0B;
513 _fjsp_v2r8 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
514 _fjsp_v2r8 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
515 _fjsp_v2r8 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
516 _fjsp_v2r8 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
517 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
520 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
523 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
524 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
526 _fjsp_v2r8 dummy_mask,cutoff_mask;
527 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
528 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
529 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
536 jindex = nlist->jindex;
538 shiftidx = nlist->shift;
540 shiftvec = fr->shift_vec[0];
541 fshift = fr->fshift[0];
542 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
543 charge = mdatoms->chargeA;
544 krf = gmx_fjsp_set1_v2r8(fr->ic->k_rf);
545 krf2 = gmx_fjsp_set1_v2r8(fr->ic->k_rf*2.0);
546 crf = gmx_fjsp_set1_v2r8(fr->ic->c_rf);
547 nvdwtype = fr->ntype;
549 vdwtype = mdatoms->typeA;
551 /* Setup water-specific parameters */
552 inr = nlist->iinr[0];
553 iq0 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+0]));
554 iq1 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
555 iq2 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
556 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
558 /* Avoid stupid compiler warnings */
566 /* Start outer loop over neighborlists */
567 for(iidx=0; iidx<nri; iidx++)
569 /* Load shift vector for this list */
570 i_shift_offset = DIM*shiftidx[iidx];
572 /* Load limits for loop over neighbors */
573 j_index_start = jindex[iidx];
574 j_index_end = jindex[iidx+1];
576 /* Get outer coordinate index */
578 i_coord_offset = DIM*inr;
580 /* Load i particle coords and add shift vector */
581 gmx_fjsp_load_shift_and_3rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
582 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
584 fix0 = _fjsp_setzero_v2r8();
585 fiy0 = _fjsp_setzero_v2r8();
586 fiz0 = _fjsp_setzero_v2r8();
587 fix1 = _fjsp_setzero_v2r8();
588 fiy1 = _fjsp_setzero_v2r8();
589 fiz1 = _fjsp_setzero_v2r8();
590 fix2 = _fjsp_setzero_v2r8();
591 fiy2 = _fjsp_setzero_v2r8();
592 fiz2 = _fjsp_setzero_v2r8();
594 /* Start inner kernel loop */
595 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
598 /* Get j neighbor index, and coordinate index */
601 j_coord_offsetA = DIM*jnrA;
602 j_coord_offsetB = DIM*jnrB;
604 /* load j atom coordinates */
605 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
608 /* Calculate displacement vector */
609 dx00 = _fjsp_sub_v2r8(ix0,jx0);
610 dy00 = _fjsp_sub_v2r8(iy0,jy0);
611 dz00 = _fjsp_sub_v2r8(iz0,jz0);
612 dx10 = _fjsp_sub_v2r8(ix1,jx0);
613 dy10 = _fjsp_sub_v2r8(iy1,jy0);
614 dz10 = _fjsp_sub_v2r8(iz1,jz0);
615 dx20 = _fjsp_sub_v2r8(ix2,jx0);
616 dy20 = _fjsp_sub_v2r8(iy2,jy0);
617 dz20 = _fjsp_sub_v2r8(iz2,jz0);
619 /* Calculate squared distance and things based on it */
620 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
621 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
622 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
624 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
625 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
626 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
628 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
629 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
630 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
632 /* Load parameters for j particles */
633 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
634 vdwjidx0A = 2*vdwtype[jnrA+0];
635 vdwjidx0B = 2*vdwtype[jnrB+0];
637 fjx0 = _fjsp_setzero_v2r8();
638 fjy0 = _fjsp_setzero_v2r8();
639 fjz0 = _fjsp_setzero_v2r8();
641 /**************************
642 * CALCULATE INTERACTIONS *
643 **************************/
645 /* Compute parameters for interactions between i and j atoms */
646 qq00 = _fjsp_mul_v2r8(iq0,jq0);
647 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
648 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
650 /* REACTION-FIELD ELECTROSTATICS */
651 felec = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
653 /* LENNARD-JONES DISPERSION/REPULSION */
655 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
656 fvdw = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
658 fscal = _fjsp_add_v2r8(felec,fvdw);
660 /* Update vectorial force */
661 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
662 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
663 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
665 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
666 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
667 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
669 /**************************
670 * CALCULATE INTERACTIONS *
671 **************************/
673 /* Compute parameters for interactions between i and j atoms */
674 qq10 = _fjsp_mul_v2r8(iq1,jq0);
676 /* REACTION-FIELD ELECTROSTATICS */
677 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
681 /* Update vectorial force */
682 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
683 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
684 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
686 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
687 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
688 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
690 /**************************
691 * CALCULATE INTERACTIONS *
692 **************************/
694 /* Compute parameters for interactions between i and j atoms */
695 qq20 = _fjsp_mul_v2r8(iq2,jq0);
697 /* REACTION-FIELD ELECTROSTATICS */
698 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
702 /* Update vectorial force */
703 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
704 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
705 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
707 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
708 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
709 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
711 gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
713 /* Inner loop uses 100 flops */
720 j_coord_offsetA = DIM*jnrA;
722 /* load j atom coordinates */
723 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
726 /* Calculate displacement vector */
727 dx00 = _fjsp_sub_v2r8(ix0,jx0);
728 dy00 = _fjsp_sub_v2r8(iy0,jy0);
729 dz00 = _fjsp_sub_v2r8(iz0,jz0);
730 dx10 = _fjsp_sub_v2r8(ix1,jx0);
731 dy10 = _fjsp_sub_v2r8(iy1,jy0);
732 dz10 = _fjsp_sub_v2r8(iz1,jz0);
733 dx20 = _fjsp_sub_v2r8(ix2,jx0);
734 dy20 = _fjsp_sub_v2r8(iy2,jy0);
735 dz20 = _fjsp_sub_v2r8(iz2,jz0);
737 /* Calculate squared distance and things based on it */
738 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
739 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
740 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
742 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
743 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
744 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
746 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
747 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
748 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
750 /* Load parameters for j particles */
751 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
752 vdwjidx0A = 2*vdwtype[jnrA+0];
754 fjx0 = _fjsp_setzero_v2r8();
755 fjy0 = _fjsp_setzero_v2r8();
756 fjz0 = _fjsp_setzero_v2r8();
758 /**************************
759 * CALCULATE INTERACTIONS *
760 **************************/
762 /* Compute parameters for interactions between i and j atoms */
763 qq00 = _fjsp_mul_v2r8(iq0,jq0);
764 gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
766 /* REACTION-FIELD ELECTROSTATICS */
767 felec = _fjsp_mul_v2r8(qq00,_fjsp_msub_v2r8(rinv00,rinvsq00,krf2));
769 /* LENNARD-JONES DISPERSION/REPULSION */
771 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
772 fvdw = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
774 fscal = _fjsp_add_v2r8(felec,fvdw);
776 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
778 /* Update vectorial force */
779 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
780 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
781 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
783 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
784 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
785 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
787 /**************************
788 * CALCULATE INTERACTIONS *
789 **************************/
791 /* Compute parameters for interactions between i and j atoms */
792 qq10 = _fjsp_mul_v2r8(iq1,jq0);
794 /* REACTION-FIELD ELECTROSTATICS */
795 felec = _fjsp_mul_v2r8(qq10,_fjsp_msub_v2r8(rinv10,rinvsq10,krf2));
799 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
801 /* Update vectorial force */
802 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
803 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
804 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
806 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
807 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
808 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
810 /**************************
811 * CALCULATE INTERACTIONS *
812 **************************/
814 /* Compute parameters for interactions between i and j atoms */
815 qq20 = _fjsp_mul_v2r8(iq2,jq0);
817 /* REACTION-FIELD ELECTROSTATICS */
818 felec = _fjsp_mul_v2r8(qq20,_fjsp_msub_v2r8(rinv20,rinvsq20,krf2));
822 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
824 /* Update vectorial force */
825 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
826 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
827 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
829 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
830 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
831 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
833 gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
835 /* Inner loop uses 100 flops */
838 /* End of innermost loop */
840 gmx_fjsp_update_iforce_3atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
841 f+i_coord_offset,fshift+i_shift_offset);
843 /* Increment number of inner iterations */
844 inneriter += j_index_end - j_index_start;
846 /* Outer loop uses 18 flops */
849 /* Increment number of outer iterations */
852 /* Update outer/inner flops */
854 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*100);