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_ElecEwSh_VdwLJSh_GeomW4P1_VF_sparc64_hpc_ace_double
53 * Electrostatics interaction: Ewald
54 * VdW interaction: LennardJones
55 * Geometry: Water4-Particle
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecEwSh_VdwLJSh_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 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
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 nvdwtype = fr->ntype;
126 vdwtype = mdatoms->typeA;
128 sh_ewald = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
129 ewtab = fr->ic->tabq_coul_FDV0;
130 ewtabscale = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
131 ewtabhalfspace = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
133 /* Setup water-specific parameters */
134 inr = nlist->iinr[0];
135 iq1 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
136 iq2 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
137 iq3 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
138 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
140 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
141 rcutoff_scalar = fr->rcoulomb;
142 rcutoff = gmx_fjsp_set1_v2r8(rcutoff_scalar);
143 rcutoff2 = _fjsp_mul_v2r8(rcutoff,rcutoff);
145 sh_vdw_invrcut6 = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
146 rvdw = gmx_fjsp_set1_v2r8(fr->rvdw);
148 /* Avoid stupid compiler warnings */
156 /* Start outer loop over neighborlists */
157 for(iidx=0; iidx<nri; iidx++)
159 /* Load shift vector for this list */
160 i_shift_offset = DIM*shiftidx[iidx];
162 /* Load limits for loop over neighbors */
163 j_index_start = jindex[iidx];
164 j_index_end = jindex[iidx+1];
166 /* Get outer coordinate index */
168 i_coord_offset = DIM*inr;
170 /* Load i particle coords and add shift vector */
171 gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
172 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
174 fix0 = _fjsp_setzero_v2r8();
175 fiy0 = _fjsp_setzero_v2r8();
176 fiz0 = _fjsp_setzero_v2r8();
177 fix1 = _fjsp_setzero_v2r8();
178 fiy1 = _fjsp_setzero_v2r8();
179 fiz1 = _fjsp_setzero_v2r8();
180 fix2 = _fjsp_setzero_v2r8();
181 fiy2 = _fjsp_setzero_v2r8();
182 fiz2 = _fjsp_setzero_v2r8();
183 fix3 = _fjsp_setzero_v2r8();
184 fiy3 = _fjsp_setzero_v2r8();
185 fiz3 = _fjsp_setzero_v2r8();
187 /* Reset potential sums */
188 velecsum = _fjsp_setzero_v2r8();
189 vvdwsum = _fjsp_setzero_v2r8();
191 /* Start inner kernel loop */
192 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
195 /* Get j neighbor index, and coordinate index */
198 j_coord_offsetA = DIM*jnrA;
199 j_coord_offsetB = DIM*jnrB;
201 /* load j atom coordinates */
202 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
205 /* Calculate displacement vector */
206 dx00 = _fjsp_sub_v2r8(ix0,jx0);
207 dy00 = _fjsp_sub_v2r8(iy0,jy0);
208 dz00 = _fjsp_sub_v2r8(iz0,jz0);
209 dx10 = _fjsp_sub_v2r8(ix1,jx0);
210 dy10 = _fjsp_sub_v2r8(iy1,jy0);
211 dz10 = _fjsp_sub_v2r8(iz1,jz0);
212 dx20 = _fjsp_sub_v2r8(ix2,jx0);
213 dy20 = _fjsp_sub_v2r8(iy2,jy0);
214 dz20 = _fjsp_sub_v2r8(iz2,jz0);
215 dx30 = _fjsp_sub_v2r8(ix3,jx0);
216 dy30 = _fjsp_sub_v2r8(iy3,jy0);
217 dz30 = _fjsp_sub_v2r8(iz3,jz0);
219 /* Calculate squared distance and things based on it */
220 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
221 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
222 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
223 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
225 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
226 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
227 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
229 rinvsq00 = gmx_fjsp_inv_v2r8(rsq00);
230 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
231 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
232 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
234 /* Load parameters for j particles */
235 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
236 vdwjidx0A = 2*vdwtype[jnrA+0];
237 vdwjidx0B = 2*vdwtype[jnrB+0];
239 fjx0 = _fjsp_setzero_v2r8();
240 fjy0 = _fjsp_setzero_v2r8();
241 fjz0 = _fjsp_setzero_v2r8();
243 /**************************
244 * CALCULATE INTERACTIONS *
245 **************************/
247 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
250 /* Compute parameters for interactions between i and j atoms */
251 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
252 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
254 /* LENNARD-JONES DISPERSION/REPULSION */
256 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
257 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
258 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
259 vvdw = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
260 _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
261 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
263 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
265 /* Update potential sum for this i atom from the interaction with this j atom. */
266 vvdw = _fjsp_and_v2r8(vvdw,cutoff_mask);
267 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
271 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
273 /* Update vectorial force */
274 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
275 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
276 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
278 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
279 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
280 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
284 /**************************
285 * CALCULATE INTERACTIONS *
286 **************************/
288 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
291 r10 = _fjsp_mul_v2r8(rsq10,rinv10);
293 /* Compute parameters for interactions between i and j atoms */
294 qq10 = _fjsp_mul_v2r8(iq1,jq0);
296 /* EWALD ELECTROSTATICS */
298 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
299 ewrt = _fjsp_mul_v2r8(r10,ewtabscale);
300 itab_tmp = _fjsp_dtox_v2r8(ewrt);
301 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
302 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
304 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
305 ewtabD = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
306 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
307 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
308 ewtabFn = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
309 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
310 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
311 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
312 velec = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv10,sh_ewald),velec));
313 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,rinv10),_fjsp_sub_v2r8(rinvsq10,felec));
315 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
317 /* Update potential sum for this i atom from the interaction with this j atom. */
318 velec = _fjsp_and_v2r8(velec,cutoff_mask);
319 velecsum = _fjsp_add_v2r8(velecsum,velec);
323 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
325 /* Update vectorial force */
326 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
327 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
328 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
330 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
331 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
332 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
336 /**************************
337 * CALCULATE INTERACTIONS *
338 **************************/
340 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
343 r20 = _fjsp_mul_v2r8(rsq20,rinv20);
345 /* Compute parameters for interactions between i and j atoms */
346 qq20 = _fjsp_mul_v2r8(iq2,jq0);
348 /* EWALD ELECTROSTATICS */
350 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
351 ewrt = _fjsp_mul_v2r8(r20,ewtabscale);
352 itab_tmp = _fjsp_dtox_v2r8(ewrt);
353 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
354 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
356 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
357 ewtabD = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
358 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
359 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
360 ewtabFn = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
361 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
362 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
363 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
364 velec = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv20,sh_ewald),velec));
365 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,rinv20),_fjsp_sub_v2r8(rinvsq20,felec));
367 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
369 /* Update potential sum for this i atom from the interaction with this j atom. */
370 velec = _fjsp_and_v2r8(velec,cutoff_mask);
371 velecsum = _fjsp_add_v2r8(velecsum,velec);
375 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
377 /* Update vectorial force */
378 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
379 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
380 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
382 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
383 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
384 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
388 /**************************
389 * CALCULATE INTERACTIONS *
390 **************************/
392 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
395 r30 = _fjsp_mul_v2r8(rsq30,rinv30);
397 /* Compute parameters for interactions between i and j atoms */
398 qq30 = _fjsp_mul_v2r8(iq3,jq0);
400 /* EWALD ELECTROSTATICS */
402 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
403 ewrt = _fjsp_mul_v2r8(r30,ewtabscale);
404 itab_tmp = _fjsp_dtox_v2r8(ewrt);
405 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
406 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
408 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
409 ewtabD = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
410 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
411 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
412 ewtabFn = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
413 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
414 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
415 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
416 velec = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv30,sh_ewald),velec));
417 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,rinv30),_fjsp_sub_v2r8(rinvsq30,felec));
419 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
421 /* Update potential sum for this i atom from the interaction with this j atom. */
422 velec = _fjsp_and_v2r8(velec,cutoff_mask);
423 velecsum = _fjsp_add_v2r8(velecsum,velec);
427 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
429 /* Update vectorial force */
430 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
431 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
432 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
434 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
435 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
436 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
440 gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
442 /* Inner loop uses 194 flops */
449 j_coord_offsetA = DIM*jnrA;
451 /* load j atom coordinates */
452 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
455 /* Calculate displacement vector */
456 dx00 = _fjsp_sub_v2r8(ix0,jx0);
457 dy00 = _fjsp_sub_v2r8(iy0,jy0);
458 dz00 = _fjsp_sub_v2r8(iz0,jz0);
459 dx10 = _fjsp_sub_v2r8(ix1,jx0);
460 dy10 = _fjsp_sub_v2r8(iy1,jy0);
461 dz10 = _fjsp_sub_v2r8(iz1,jz0);
462 dx20 = _fjsp_sub_v2r8(ix2,jx0);
463 dy20 = _fjsp_sub_v2r8(iy2,jy0);
464 dz20 = _fjsp_sub_v2r8(iz2,jz0);
465 dx30 = _fjsp_sub_v2r8(ix3,jx0);
466 dy30 = _fjsp_sub_v2r8(iy3,jy0);
467 dz30 = _fjsp_sub_v2r8(iz3,jz0);
469 /* Calculate squared distance and things based on it */
470 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
471 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
472 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
473 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
475 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
476 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
477 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
479 rinvsq00 = gmx_fjsp_inv_v2r8(rsq00);
480 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
481 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
482 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
484 /* Load parameters for j particles */
485 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
486 vdwjidx0A = 2*vdwtype[jnrA+0];
488 fjx0 = _fjsp_setzero_v2r8();
489 fjy0 = _fjsp_setzero_v2r8();
490 fjz0 = _fjsp_setzero_v2r8();
492 /**************************
493 * CALCULATE INTERACTIONS *
494 **************************/
496 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
499 /* Compute parameters for interactions between i and j atoms */
500 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
501 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
503 /* LENNARD-JONES DISPERSION/REPULSION */
505 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
506 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
507 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
508 vvdw = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
509 _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
510 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
512 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
514 /* Update potential sum for this i atom from the interaction with this j atom. */
515 vvdw = _fjsp_and_v2r8(vvdw,cutoff_mask);
516 vvdw = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
517 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
521 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
523 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
525 /* Update vectorial force */
526 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
527 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
528 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
530 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
531 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
532 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
536 /**************************
537 * CALCULATE INTERACTIONS *
538 **************************/
540 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
543 r10 = _fjsp_mul_v2r8(rsq10,rinv10);
545 /* Compute parameters for interactions between i and j atoms */
546 qq10 = _fjsp_mul_v2r8(iq1,jq0);
548 /* EWALD ELECTROSTATICS */
550 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
551 ewrt = _fjsp_mul_v2r8(r10,ewtabscale);
552 itab_tmp = _fjsp_dtox_v2r8(ewrt);
553 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
554 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
556 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
557 ewtabD = _fjsp_setzero_v2r8();
558 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
559 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
560 ewtabFn = _fjsp_setzero_v2r8();
561 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
562 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
563 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
564 velec = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv10,sh_ewald),velec));
565 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,rinv10),_fjsp_sub_v2r8(rinvsq10,felec));
567 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
569 /* Update potential sum for this i atom from the interaction with this j atom. */
570 velec = _fjsp_and_v2r8(velec,cutoff_mask);
571 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
572 velecsum = _fjsp_add_v2r8(velecsum,velec);
576 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
578 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
580 /* Update vectorial force */
581 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
582 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
583 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
585 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
586 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
587 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
591 /**************************
592 * CALCULATE INTERACTIONS *
593 **************************/
595 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
598 r20 = _fjsp_mul_v2r8(rsq20,rinv20);
600 /* Compute parameters for interactions between i and j atoms */
601 qq20 = _fjsp_mul_v2r8(iq2,jq0);
603 /* EWALD ELECTROSTATICS */
605 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
606 ewrt = _fjsp_mul_v2r8(r20,ewtabscale);
607 itab_tmp = _fjsp_dtox_v2r8(ewrt);
608 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
609 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
611 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
612 ewtabD = _fjsp_setzero_v2r8();
613 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
614 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
615 ewtabFn = _fjsp_setzero_v2r8();
616 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
617 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
618 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
619 velec = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv20,sh_ewald),velec));
620 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,rinv20),_fjsp_sub_v2r8(rinvsq20,felec));
622 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
624 /* Update potential sum for this i atom from the interaction with this j atom. */
625 velec = _fjsp_and_v2r8(velec,cutoff_mask);
626 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
627 velecsum = _fjsp_add_v2r8(velecsum,velec);
631 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
633 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
635 /* Update vectorial force */
636 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
637 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
638 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
640 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
641 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
642 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
646 /**************************
647 * CALCULATE INTERACTIONS *
648 **************************/
650 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
653 r30 = _fjsp_mul_v2r8(rsq30,rinv30);
655 /* Compute parameters for interactions between i and j atoms */
656 qq30 = _fjsp_mul_v2r8(iq3,jq0);
658 /* EWALD ELECTROSTATICS */
660 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
661 ewrt = _fjsp_mul_v2r8(r30,ewtabscale);
662 itab_tmp = _fjsp_dtox_v2r8(ewrt);
663 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
664 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
666 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
667 ewtabD = _fjsp_setzero_v2r8();
668 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
669 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
670 ewtabFn = _fjsp_setzero_v2r8();
671 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
672 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
673 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
674 velec = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv30,sh_ewald),velec));
675 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,rinv30),_fjsp_sub_v2r8(rinvsq30,felec));
677 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
679 /* Update potential sum for this i atom from the interaction with this j atom. */
680 velec = _fjsp_and_v2r8(velec,cutoff_mask);
681 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
682 velecsum = _fjsp_add_v2r8(velecsum,velec);
686 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
688 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
690 /* Update vectorial force */
691 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
692 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
693 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
695 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
696 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
697 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
701 gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
703 /* Inner loop uses 194 flops */
706 /* End of innermost loop */
708 gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
709 f+i_coord_offset,fshift+i_shift_offset);
712 /* Update potential energies */
713 gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
714 gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
716 /* Increment number of inner iterations */
717 inneriter += j_index_end - j_index_start;
719 /* Outer loop uses 26 flops */
722 /* Increment number of outer iterations */
725 /* Update outer/inner flops */
727 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*194);
730 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW4P1_F_sparc64_hpc_ace_double
731 * Electrostatics interaction: Ewald
732 * VdW interaction: LennardJones
733 * Geometry: Water4-Particle
734 * Calculate force/pot: Force
737 nb_kernel_ElecEwSh_VdwLJSh_GeomW4P1_F_sparc64_hpc_ace_double
738 (t_nblist * gmx_restrict nlist,
739 rvec * gmx_restrict xx,
740 rvec * gmx_restrict ff,
741 t_forcerec * gmx_restrict fr,
742 t_mdatoms * gmx_restrict mdatoms,
743 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
744 t_nrnb * gmx_restrict nrnb)
746 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
747 * just 0 for non-waters.
748 * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
749 * jnr indices corresponding to data put in the four positions in the SIMD register.
751 int i_shift_offset,i_coord_offset,outeriter,inneriter;
752 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
754 int j_coord_offsetA,j_coord_offsetB;
755 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
757 real *shiftvec,*fshift,*x,*f;
758 _fjsp_v2r8 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
760 _fjsp_v2r8 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
762 _fjsp_v2r8 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
764 _fjsp_v2r8 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
766 _fjsp_v2r8 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
767 int vdwjidx0A,vdwjidx0B;
768 _fjsp_v2r8 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
769 _fjsp_v2r8 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
770 _fjsp_v2r8 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
771 _fjsp_v2r8 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
772 _fjsp_v2r8 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
773 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
776 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
779 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
780 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
781 _fjsp_v2r8 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
784 _fjsp_v2r8 dummy_mask,cutoff_mask;
785 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
786 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
787 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
794 jindex = nlist->jindex;
796 shiftidx = nlist->shift;
798 shiftvec = fr->shift_vec[0];
799 fshift = fr->fshift[0];
800 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
801 charge = mdatoms->chargeA;
802 nvdwtype = fr->ntype;
804 vdwtype = mdatoms->typeA;
806 sh_ewald = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
807 ewtab = fr->ic->tabq_coul_F;
808 ewtabscale = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
809 ewtabhalfspace = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
811 /* Setup water-specific parameters */
812 inr = nlist->iinr[0];
813 iq1 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
814 iq2 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
815 iq3 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
816 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
818 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
819 rcutoff_scalar = fr->rcoulomb;
820 rcutoff = gmx_fjsp_set1_v2r8(rcutoff_scalar);
821 rcutoff2 = _fjsp_mul_v2r8(rcutoff,rcutoff);
823 sh_vdw_invrcut6 = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
824 rvdw = gmx_fjsp_set1_v2r8(fr->rvdw);
826 /* Avoid stupid compiler warnings */
834 /* Start outer loop over neighborlists */
835 for(iidx=0; iidx<nri; iidx++)
837 /* Load shift vector for this list */
838 i_shift_offset = DIM*shiftidx[iidx];
840 /* Load limits for loop over neighbors */
841 j_index_start = jindex[iidx];
842 j_index_end = jindex[iidx+1];
844 /* Get outer coordinate index */
846 i_coord_offset = DIM*inr;
848 /* Load i particle coords and add shift vector */
849 gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
850 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
852 fix0 = _fjsp_setzero_v2r8();
853 fiy0 = _fjsp_setzero_v2r8();
854 fiz0 = _fjsp_setzero_v2r8();
855 fix1 = _fjsp_setzero_v2r8();
856 fiy1 = _fjsp_setzero_v2r8();
857 fiz1 = _fjsp_setzero_v2r8();
858 fix2 = _fjsp_setzero_v2r8();
859 fiy2 = _fjsp_setzero_v2r8();
860 fiz2 = _fjsp_setzero_v2r8();
861 fix3 = _fjsp_setzero_v2r8();
862 fiy3 = _fjsp_setzero_v2r8();
863 fiz3 = _fjsp_setzero_v2r8();
865 /* Start inner kernel loop */
866 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
869 /* Get j neighbor index, and coordinate index */
872 j_coord_offsetA = DIM*jnrA;
873 j_coord_offsetB = DIM*jnrB;
875 /* load j atom coordinates */
876 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
879 /* Calculate displacement vector */
880 dx00 = _fjsp_sub_v2r8(ix0,jx0);
881 dy00 = _fjsp_sub_v2r8(iy0,jy0);
882 dz00 = _fjsp_sub_v2r8(iz0,jz0);
883 dx10 = _fjsp_sub_v2r8(ix1,jx0);
884 dy10 = _fjsp_sub_v2r8(iy1,jy0);
885 dz10 = _fjsp_sub_v2r8(iz1,jz0);
886 dx20 = _fjsp_sub_v2r8(ix2,jx0);
887 dy20 = _fjsp_sub_v2r8(iy2,jy0);
888 dz20 = _fjsp_sub_v2r8(iz2,jz0);
889 dx30 = _fjsp_sub_v2r8(ix3,jx0);
890 dy30 = _fjsp_sub_v2r8(iy3,jy0);
891 dz30 = _fjsp_sub_v2r8(iz3,jz0);
893 /* Calculate squared distance and things based on it */
894 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
895 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
896 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
897 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
899 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
900 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
901 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
903 rinvsq00 = gmx_fjsp_inv_v2r8(rsq00);
904 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
905 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
906 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
908 /* Load parameters for j particles */
909 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
910 vdwjidx0A = 2*vdwtype[jnrA+0];
911 vdwjidx0B = 2*vdwtype[jnrB+0];
913 fjx0 = _fjsp_setzero_v2r8();
914 fjy0 = _fjsp_setzero_v2r8();
915 fjz0 = _fjsp_setzero_v2r8();
917 /**************************
918 * CALCULATE INTERACTIONS *
919 **************************/
921 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
924 /* Compute parameters for interactions between i and j atoms */
925 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
926 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
928 /* LENNARD-JONES DISPERSION/REPULSION */
930 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
931 fvdw = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
933 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
937 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
939 /* Update vectorial force */
940 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
941 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
942 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
944 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
945 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
946 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
950 /**************************
951 * CALCULATE INTERACTIONS *
952 **************************/
954 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
957 r10 = _fjsp_mul_v2r8(rsq10,rinv10);
959 /* Compute parameters for interactions between i and j atoms */
960 qq10 = _fjsp_mul_v2r8(iq1,jq0);
962 /* EWALD ELECTROSTATICS */
964 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
965 ewrt = _fjsp_mul_v2r8(r10,ewtabscale);
966 itab_tmp = _fjsp_dtox_v2r8(ewrt);
967 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
968 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
970 gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
972 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
973 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,rinv10),_fjsp_sub_v2r8(rinvsq10,felec));
975 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
979 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
981 /* Update vectorial force */
982 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
983 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
984 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
986 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
987 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
988 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
992 /**************************
993 * CALCULATE INTERACTIONS *
994 **************************/
996 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
999 r20 = _fjsp_mul_v2r8(rsq20,rinv20);
1001 /* Compute parameters for interactions between i and j atoms */
1002 qq20 = _fjsp_mul_v2r8(iq2,jq0);
1004 /* EWALD ELECTROSTATICS */
1006 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1007 ewrt = _fjsp_mul_v2r8(r20,ewtabscale);
1008 itab_tmp = _fjsp_dtox_v2r8(ewrt);
1009 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1010 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1012 gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
1014 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1015 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,rinv20),_fjsp_sub_v2r8(rinvsq20,felec));
1017 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
1021 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1023 /* Update vectorial force */
1024 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
1025 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1026 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1028 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1029 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1030 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1034 /**************************
1035 * CALCULATE INTERACTIONS *
1036 **************************/
1038 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
1041 r30 = _fjsp_mul_v2r8(rsq30,rinv30);
1043 /* Compute parameters for interactions between i and j atoms */
1044 qq30 = _fjsp_mul_v2r8(iq3,jq0);
1046 /* EWALD ELECTROSTATICS */
1048 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1049 ewrt = _fjsp_mul_v2r8(r30,ewtabscale);
1050 itab_tmp = _fjsp_dtox_v2r8(ewrt);
1051 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1052 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1054 gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
1056 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1057 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,rinv30),_fjsp_sub_v2r8(rinvsq30,felec));
1059 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
1063 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1065 /* Update vectorial force */
1066 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
1067 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
1068 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
1070 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
1071 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
1072 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
1076 gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
1078 /* Inner loop uses 162 flops */
1081 if(jidx<j_index_end)
1085 j_coord_offsetA = DIM*jnrA;
1087 /* load j atom coordinates */
1088 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
1091 /* Calculate displacement vector */
1092 dx00 = _fjsp_sub_v2r8(ix0,jx0);
1093 dy00 = _fjsp_sub_v2r8(iy0,jy0);
1094 dz00 = _fjsp_sub_v2r8(iz0,jz0);
1095 dx10 = _fjsp_sub_v2r8(ix1,jx0);
1096 dy10 = _fjsp_sub_v2r8(iy1,jy0);
1097 dz10 = _fjsp_sub_v2r8(iz1,jz0);
1098 dx20 = _fjsp_sub_v2r8(ix2,jx0);
1099 dy20 = _fjsp_sub_v2r8(iy2,jy0);
1100 dz20 = _fjsp_sub_v2r8(iz2,jz0);
1101 dx30 = _fjsp_sub_v2r8(ix3,jx0);
1102 dy30 = _fjsp_sub_v2r8(iy3,jy0);
1103 dz30 = _fjsp_sub_v2r8(iz3,jz0);
1105 /* Calculate squared distance and things based on it */
1106 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1107 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
1108 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
1109 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
1111 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
1112 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
1113 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
1115 rinvsq00 = gmx_fjsp_inv_v2r8(rsq00);
1116 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
1117 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
1118 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
1120 /* Load parameters for j particles */
1121 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
1122 vdwjidx0A = 2*vdwtype[jnrA+0];
1124 fjx0 = _fjsp_setzero_v2r8();
1125 fjy0 = _fjsp_setzero_v2r8();
1126 fjz0 = _fjsp_setzero_v2r8();
1128 /**************************
1129 * CALCULATE INTERACTIONS *
1130 **************************/
1132 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
1135 /* Compute parameters for interactions between i and j atoms */
1136 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
1137 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
1139 /* LENNARD-JONES DISPERSION/REPULSION */
1141 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
1142 fvdw = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
1144 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
1148 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1150 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1152 /* Update vectorial force */
1153 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
1154 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1155 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1157 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1158 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1159 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1163 /**************************
1164 * CALCULATE INTERACTIONS *
1165 **************************/
1167 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
1170 r10 = _fjsp_mul_v2r8(rsq10,rinv10);
1172 /* Compute parameters for interactions between i and j atoms */
1173 qq10 = _fjsp_mul_v2r8(iq1,jq0);
1175 /* EWALD ELECTROSTATICS */
1177 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1178 ewrt = _fjsp_mul_v2r8(r10,ewtabscale);
1179 itab_tmp = _fjsp_dtox_v2r8(ewrt);
1180 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1181 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1183 gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
1184 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1185 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,rinv10),_fjsp_sub_v2r8(rinvsq10,felec));
1187 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
1191 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1193 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1195 /* Update vectorial force */
1196 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
1197 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
1198 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
1200 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
1201 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
1202 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
1206 /**************************
1207 * CALCULATE INTERACTIONS *
1208 **************************/
1210 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
1213 r20 = _fjsp_mul_v2r8(rsq20,rinv20);
1215 /* Compute parameters for interactions between i and j atoms */
1216 qq20 = _fjsp_mul_v2r8(iq2,jq0);
1218 /* EWALD ELECTROSTATICS */
1220 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1221 ewrt = _fjsp_mul_v2r8(r20,ewtabscale);
1222 itab_tmp = _fjsp_dtox_v2r8(ewrt);
1223 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1224 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1226 gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
1227 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1228 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,rinv20),_fjsp_sub_v2r8(rinvsq20,felec));
1230 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
1234 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1236 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1238 /* Update vectorial force */
1239 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
1240 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1241 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1243 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1244 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1245 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1249 /**************************
1250 * CALCULATE INTERACTIONS *
1251 **************************/
1253 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
1256 r30 = _fjsp_mul_v2r8(rsq30,rinv30);
1258 /* Compute parameters for interactions between i and j atoms */
1259 qq30 = _fjsp_mul_v2r8(iq3,jq0);
1261 /* EWALD ELECTROSTATICS */
1263 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1264 ewrt = _fjsp_mul_v2r8(r30,ewtabscale);
1265 itab_tmp = _fjsp_dtox_v2r8(ewrt);
1266 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1267 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1269 gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
1270 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1271 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,rinv30),_fjsp_sub_v2r8(rinvsq30,felec));
1273 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
1277 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1279 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1281 /* Update vectorial force */
1282 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
1283 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
1284 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
1286 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
1287 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
1288 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
1292 gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1294 /* Inner loop uses 162 flops */
1297 /* End of innermost loop */
1299 gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1300 f+i_coord_offset,fshift+i_shift_offset);
1302 /* Increment number of inner iterations */
1303 inneriter += j_index_end - j_index_start;
1305 /* Outer loop uses 24 flops */
1308 /* Increment number of outer iterations */
1311 /* Update outer/inner flops */
1313 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*162);