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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
47 #include "kernelutil_sparc64_hpc_ace_double.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW4P1_VF_sparc64_hpc_ace_double
51 * Electrostatics interaction: Ewald
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwLJSh_GeomW4P1_VF_sparc64_hpc_ace_double
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67 * just 0 for non-waters.
68 * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
69 * jnr indices corresponding to data put in the four positions in the SIMD register.
71 int i_shift_offset,i_coord_offset,outeriter,inneriter;
72 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74 int j_coord_offsetA,j_coord_offsetB;
75 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
77 real *shiftvec,*fshift,*x,*f;
78 _fjsp_v2r8 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
80 _fjsp_v2r8 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
82 _fjsp_v2r8 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
84 _fjsp_v2r8 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
86 _fjsp_v2r8 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
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 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
93 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
96 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
99 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
100 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
101 _fjsp_v2r8 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
104 _fjsp_v2r8 dummy_mask,cutoff_mask;
105 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
106 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
107 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
114 jindex = nlist->jindex;
116 shiftidx = nlist->shift;
118 shiftvec = fr->shift_vec[0];
119 fshift = fr->fshift[0];
120 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
121 charge = mdatoms->chargeA;
122 nvdwtype = fr->ntype;
124 vdwtype = mdatoms->typeA;
126 sh_ewald = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
127 ewtab = fr->ic->tabq_coul_FDV0;
128 ewtabscale = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
129 ewtabhalfspace = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
131 /* Setup water-specific parameters */
132 inr = nlist->iinr[0];
133 iq1 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
134 iq2 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
135 iq3 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
136 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
138 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
139 rcutoff_scalar = fr->rcoulomb;
140 rcutoff = gmx_fjsp_set1_v2r8(rcutoff_scalar);
141 rcutoff2 = _fjsp_mul_v2r8(rcutoff,rcutoff);
143 sh_vdw_invrcut6 = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
144 rvdw = gmx_fjsp_set1_v2r8(fr->rvdw);
146 /* Avoid stupid compiler warnings */
154 /* Start outer loop over neighborlists */
155 for(iidx=0; iidx<nri; iidx++)
157 /* Load shift vector for this list */
158 i_shift_offset = DIM*shiftidx[iidx];
160 /* Load limits for loop over neighbors */
161 j_index_start = jindex[iidx];
162 j_index_end = jindex[iidx+1];
164 /* Get outer coordinate index */
166 i_coord_offset = DIM*inr;
168 /* Load i particle coords and add shift vector */
169 gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
170 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
172 fix0 = _fjsp_setzero_v2r8();
173 fiy0 = _fjsp_setzero_v2r8();
174 fiz0 = _fjsp_setzero_v2r8();
175 fix1 = _fjsp_setzero_v2r8();
176 fiy1 = _fjsp_setzero_v2r8();
177 fiz1 = _fjsp_setzero_v2r8();
178 fix2 = _fjsp_setzero_v2r8();
179 fiy2 = _fjsp_setzero_v2r8();
180 fiz2 = _fjsp_setzero_v2r8();
181 fix3 = _fjsp_setzero_v2r8();
182 fiy3 = _fjsp_setzero_v2r8();
183 fiz3 = _fjsp_setzero_v2r8();
185 /* Reset potential sums */
186 velecsum = _fjsp_setzero_v2r8();
187 vvdwsum = _fjsp_setzero_v2r8();
189 /* Start inner kernel loop */
190 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
193 /* Get j neighbor index, and coordinate index */
196 j_coord_offsetA = DIM*jnrA;
197 j_coord_offsetB = DIM*jnrB;
199 /* load j atom coordinates */
200 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
203 /* Calculate displacement vector */
204 dx00 = _fjsp_sub_v2r8(ix0,jx0);
205 dy00 = _fjsp_sub_v2r8(iy0,jy0);
206 dz00 = _fjsp_sub_v2r8(iz0,jz0);
207 dx10 = _fjsp_sub_v2r8(ix1,jx0);
208 dy10 = _fjsp_sub_v2r8(iy1,jy0);
209 dz10 = _fjsp_sub_v2r8(iz1,jz0);
210 dx20 = _fjsp_sub_v2r8(ix2,jx0);
211 dy20 = _fjsp_sub_v2r8(iy2,jy0);
212 dz20 = _fjsp_sub_v2r8(iz2,jz0);
213 dx30 = _fjsp_sub_v2r8(ix3,jx0);
214 dy30 = _fjsp_sub_v2r8(iy3,jy0);
215 dz30 = _fjsp_sub_v2r8(iz3,jz0);
217 /* Calculate squared distance and things based on it */
218 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
219 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
220 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
221 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
223 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
224 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
225 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
227 rinvsq00 = gmx_fjsp_inv_v2r8(rsq00);
228 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
229 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
230 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
232 /* Load parameters for j particles */
233 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
234 vdwjidx0A = 2*vdwtype[jnrA+0];
235 vdwjidx0B = 2*vdwtype[jnrB+0];
237 fjx0 = _fjsp_setzero_v2r8();
238 fjy0 = _fjsp_setzero_v2r8();
239 fjz0 = _fjsp_setzero_v2r8();
241 /**************************
242 * CALCULATE INTERACTIONS *
243 **************************/
245 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
248 /* Compute parameters for interactions between i and j atoms */
249 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
250 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
252 /* LENNARD-JONES DISPERSION/REPULSION */
254 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
255 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
256 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
257 vvdw = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
258 _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
259 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
261 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
263 /* Update potential sum for this i atom from the interaction with this j atom. */
264 vvdw = _fjsp_and_v2r8(vvdw,cutoff_mask);
265 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
269 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
271 /* Update vectorial force */
272 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
273 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
274 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
276 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
277 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
278 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
282 /**************************
283 * CALCULATE INTERACTIONS *
284 **************************/
286 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
289 r10 = _fjsp_mul_v2r8(rsq10,rinv10);
291 /* Compute parameters for interactions between i and j atoms */
292 qq10 = _fjsp_mul_v2r8(iq1,jq0);
294 /* EWALD ELECTROSTATICS */
296 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
297 ewrt = _fjsp_mul_v2r8(r10,ewtabscale);
298 itab_tmp = _fjsp_dtox_v2r8(ewrt);
299 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
300 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
302 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
303 ewtabD = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
304 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
305 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
306 ewtabFn = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
307 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
308 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
309 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
310 velec = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv10,sh_ewald),velec));
311 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,rinv10),_fjsp_sub_v2r8(rinvsq10,felec));
313 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
315 /* Update potential sum for this i atom from the interaction with this j atom. */
316 velec = _fjsp_and_v2r8(velec,cutoff_mask);
317 velecsum = _fjsp_add_v2r8(velecsum,velec);
321 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
323 /* Update vectorial force */
324 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
325 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
326 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
328 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
329 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
330 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
334 /**************************
335 * CALCULATE INTERACTIONS *
336 **************************/
338 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
341 r20 = _fjsp_mul_v2r8(rsq20,rinv20);
343 /* Compute parameters for interactions between i and j atoms */
344 qq20 = _fjsp_mul_v2r8(iq2,jq0);
346 /* EWALD ELECTROSTATICS */
348 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
349 ewrt = _fjsp_mul_v2r8(r20,ewtabscale);
350 itab_tmp = _fjsp_dtox_v2r8(ewrt);
351 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
352 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
354 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
355 ewtabD = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
356 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
357 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
358 ewtabFn = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
359 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
360 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
361 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
362 velec = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv20,sh_ewald),velec));
363 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,rinv20),_fjsp_sub_v2r8(rinvsq20,felec));
365 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
367 /* Update potential sum for this i atom from the interaction with this j atom. */
368 velec = _fjsp_and_v2r8(velec,cutoff_mask);
369 velecsum = _fjsp_add_v2r8(velecsum,velec);
373 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
375 /* Update vectorial force */
376 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
377 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
378 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
380 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
381 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
382 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
386 /**************************
387 * CALCULATE INTERACTIONS *
388 **************************/
390 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
393 r30 = _fjsp_mul_v2r8(rsq30,rinv30);
395 /* Compute parameters for interactions between i and j atoms */
396 qq30 = _fjsp_mul_v2r8(iq3,jq0);
398 /* EWALD ELECTROSTATICS */
400 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
401 ewrt = _fjsp_mul_v2r8(r30,ewtabscale);
402 itab_tmp = _fjsp_dtox_v2r8(ewrt);
403 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
404 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
406 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
407 ewtabD = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
408 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
409 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
410 ewtabFn = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
411 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
412 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
413 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
414 velec = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv30,sh_ewald),velec));
415 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,rinv30),_fjsp_sub_v2r8(rinvsq30,felec));
417 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
419 /* Update potential sum for this i atom from the interaction with this j atom. */
420 velec = _fjsp_and_v2r8(velec,cutoff_mask);
421 velecsum = _fjsp_add_v2r8(velecsum,velec);
425 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
427 /* Update vectorial force */
428 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
429 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
430 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
432 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
433 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
434 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
438 gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
440 /* Inner loop uses 194 flops */
447 j_coord_offsetA = DIM*jnrA;
449 /* load j atom coordinates */
450 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
453 /* Calculate displacement vector */
454 dx00 = _fjsp_sub_v2r8(ix0,jx0);
455 dy00 = _fjsp_sub_v2r8(iy0,jy0);
456 dz00 = _fjsp_sub_v2r8(iz0,jz0);
457 dx10 = _fjsp_sub_v2r8(ix1,jx0);
458 dy10 = _fjsp_sub_v2r8(iy1,jy0);
459 dz10 = _fjsp_sub_v2r8(iz1,jz0);
460 dx20 = _fjsp_sub_v2r8(ix2,jx0);
461 dy20 = _fjsp_sub_v2r8(iy2,jy0);
462 dz20 = _fjsp_sub_v2r8(iz2,jz0);
463 dx30 = _fjsp_sub_v2r8(ix3,jx0);
464 dy30 = _fjsp_sub_v2r8(iy3,jy0);
465 dz30 = _fjsp_sub_v2r8(iz3,jz0);
467 /* Calculate squared distance and things based on it */
468 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
469 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
470 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
471 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
473 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
474 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
475 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
477 rinvsq00 = gmx_fjsp_inv_v2r8(rsq00);
478 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
479 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
480 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
482 /* Load parameters for j particles */
483 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
484 vdwjidx0A = 2*vdwtype[jnrA+0];
486 fjx0 = _fjsp_setzero_v2r8();
487 fjy0 = _fjsp_setzero_v2r8();
488 fjz0 = _fjsp_setzero_v2r8();
490 /**************************
491 * CALCULATE INTERACTIONS *
492 **************************/
494 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
497 /* Compute parameters for interactions between i and j atoms */
498 gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
500 /* LENNARD-JONES DISPERSION/REPULSION */
502 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
503 vvdw6 = _fjsp_mul_v2r8(c6_00,rinvsix);
504 vvdw12 = _fjsp_mul_v2r8(c12_00,_fjsp_mul_v2r8(rinvsix,rinvsix));
505 vvdw = _fjsp_msub_v2r8(_fjsp_nmsub_v2r8(c12_00,_fjsp_mul_v2r8(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
506 _fjsp_mul_v2r8(_fjsp_nmsub_v2r8( c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
507 fvdw = _fjsp_mul_v2r8(_fjsp_sub_v2r8(vvdw12,vvdw6),rinvsq00);
509 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
511 /* Update potential sum for this i atom from the interaction with this j atom. */
512 vvdw = _fjsp_and_v2r8(vvdw,cutoff_mask);
513 vvdw = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
514 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
518 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
520 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
522 /* Update vectorial force */
523 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
524 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
525 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
527 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
528 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
529 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
533 /**************************
534 * CALCULATE INTERACTIONS *
535 **************************/
537 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
540 r10 = _fjsp_mul_v2r8(rsq10,rinv10);
542 /* Compute parameters for interactions between i and j atoms */
543 qq10 = _fjsp_mul_v2r8(iq1,jq0);
545 /* EWALD ELECTROSTATICS */
547 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
548 ewrt = _fjsp_mul_v2r8(r10,ewtabscale);
549 itab_tmp = _fjsp_dtox_v2r8(ewrt);
550 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
551 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
553 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
554 ewtabD = _fjsp_setzero_v2r8();
555 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
556 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
557 ewtabFn = _fjsp_setzero_v2r8();
558 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
559 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
560 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
561 velec = _fjsp_mul_v2r8(qq10,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv10,sh_ewald),velec));
562 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,rinv10),_fjsp_sub_v2r8(rinvsq10,felec));
564 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
566 /* Update potential sum for this i atom from the interaction with this j atom. */
567 velec = _fjsp_and_v2r8(velec,cutoff_mask);
568 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
569 velecsum = _fjsp_add_v2r8(velecsum,velec);
573 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
575 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
577 /* Update vectorial force */
578 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
579 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
580 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
582 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
583 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
584 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
588 /**************************
589 * CALCULATE INTERACTIONS *
590 **************************/
592 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
595 r20 = _fjsp_mul_v2r8(rsq20,rinv20);
597 /* Compute parameters for interactions between i and j atoms */
598 qq20 = _fjsp_mul_v2r8(iq2,jq0);
600 /* EWALD ELECTROSTATICS */
602 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
603 ewrt = _fjsp_mul_v2r8(r20,ewtabscale);
604 itab_tmp = _fjsp_dtox_v2r8(ewrt);
605 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
606 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
608 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
609 ewtabD = _fjsp_setzero_v2r8();
610 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
611 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
612 ewtabFn = _fjsp_setzero_v2r8();
613 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
614 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
615 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
616 velec = _fjsp_mul_v2r8(qq20,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv20,sh_ewald),velec));
617 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,rinv20),_fjsp_sub_v2r8(rinvsq20,felec));
619 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
621 /* Update potential sum for this i atom from the interaction with this j atom. */
622 velec = _fjsp_and_v2r8(velec,cutoff_mask);
623 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
624 velecsum = _fjsp_add_v2r8(velecsum,velec);
628 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
630 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
632 /* Update vectorial force */
633 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
634 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
635 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
637 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
638 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
639 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
643 /**************************
644 * CALCULATE INTERACTIONS *
645 **************************/
647 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
650 r30 = _fjsp_mul_v2r8(rsq30,rinv30);
652 /* Compute parameters for interactions between i and j atoms */
653 qq30 = _fjsp_mul_v2r8(iq3,jq0);
655 /* EWALD ELECTROSTATICS */
657 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
658 ewrt = _fjsp_mul_v2r8(r30,ewtabscale);
659 itab_tmp = _fjsp_dtox_v2r8(ewrt);
660 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
661 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
663 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
664 ewtabD = _fjsp_setzero_v2r8();
665 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
666 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
667 ewtabFn = _fjsp_setzero_v2r8();
668 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
669 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
670 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
671 velec = _fjsp_mul_v2r8(qq30,_fjsp_sub_v2r8(_fjsp_sub_v2r8(rinv30,sh_ewald),velec));
672 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,rinv30),_fjsp_sub_v2r8(rinvsq30,felec));
674 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
676 /* Update potential sum for this i atom from the interaction with this j atom. */
677 velec = _fjsp_and_v2r8(velec,cutoff_mask);
678 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
679 velecsum = _fjsp_add_v2r8(velecsum,velec);
683 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
685 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
687 /* Update vectorial force */
688 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
689 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
690 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
692 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
693 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
694 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
698 gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
700 /* Inner loop uses 194 flops */
703 /* End of innermost loop */
705 gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
706 f+i_coord_offset,fshift+i_shift_offset);
709 /* Update potential energies */
710 gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
711 gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
713 /* Increment number of inner iterations */
714 inneriter += j_index_end - j_index_start;
716 /* Outer loop uses 26 flops */
719 /* Increment number of outer iterations */
722 /* Update outer/inner flops */
724 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*194);
727 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW4P1_F_sparc64_hpc_ace_double
728 * Electrostatics interaction: Ewald
729 * VdW interaction: LennardJones
730 * Geometry: Water4-Particle
731 * Calculate force/pot: Force
734 nb_kernel_ElecEwSh_VdwLJSh_GeomW4P1_F_sparc64_hpc_ace_double
735 (t_nblist * gmx_restrict nlist,
736 rvec * gmx_restrict xx,
737 rvec * gmx_restrict ff,
738 t_forcerec * gmx_restrict fr,
739 t_mdatoms * gmx_restrict mdatoms,
740 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
741 t_nrnb * gmx_restrict nrnb)
743 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
744 * just 0 for non-waters.
745 * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
746 * jnr indices corresponding to data put in the four positions in the SIMD register.
748 int i_shift_offset,i_coord_offset,outeriter,inneriter;
749 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
751 int j_coord_offsetA,j_coord_offsetB;
752 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
754 real *shiftvec,*fshift,*x,*f;
755 _fjsp_v2r8 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
757 _fjsp_v2r8 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
759 _fjsp_v2r8 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
761 _fjsp_v2r8 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
763 _fjsp_v2r8 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
764 int vdwjidx0A,vdwjidx0B;
765 _fjsp_v2r8 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
766 _fjsp_v2r8 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
767 _fjsp_v2r8 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
768 _fjsp_v2r8 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
769 _fjsp_v2r8 dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
770 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
773 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
776 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
777 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
778 _fjsp_v2r8 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
781 _fjsp_v2r8 dummy_mask,cutoff_mask;
782 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
783 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
784 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
791 jindex = nlist->jindex;
793 shiftidx = nlist->shift;
795 shiftvec = fr->shift_vec[0];
796 fshift = fr->fshift[0];
797 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
798 charge = mdatoms->chargeA;
799 nvdwtype = fr->ntype;
801 vdwtype = mdatoms->typeA;
803 sh_ewald = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
804 ewtab = fr->ic->tabq_coul_F;
805 ewtabscale = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
806 ewtabhalfspace = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
808 /* Setup water-specific parameters */
809 inr = nlist->iinr[0];
810 iq1 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+1]));
811 iq2 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+2]));
812 iq3 = _fjsp_mul_v2r8(facel,gmx_fjsp_set1_v2r8(charge[inr+3]));
813 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
815 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
816 rcutoff_scalar = fr->rcoulomb;
817 rcutoff = gmx_fjsp_set1_v2r8(rcutoff_scalar);
818 rcutoff2 = _fjsp_mul_v2r8(rcutoff,rcutoff);
820 sh_vdw_invrcut6 = gmx_fjsp_set1_v2r8(fr->ic->sh_invrc6);
821 rvdw = gmx_fjsp_set1_v2r8(fr->rvdw);
823 /* Avoid stupid compiler warnings */
831 /* Start outer loop over neighborlists */
832 for(iidx=0; iidx<nri; iidx++)
834 /* Load shift vector for this list */
835 i_shift_offset = DIM*shiftidx[iidx];
837 /* Load limits for loop over neighbors */
838 j_index_start = jindex[iidx];
839 j_index_end = jindex[iidx+1];
841 /* Get outer coordinate index */
843 i_coord_offset = DIM*inr;
845 /* Load i particle coords and add shift vector */
846 gmx_fjsp_load_shift_and_4rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,
847 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
849 fix0 = _fjsp_setzero_v2r8();
850 fiy0 = _fjsp_setzero_v2r8();
851 fiz0 = _fjsp_setzero_v2r8();
852 fix1 = _fjsp_setzero_v2r8();
853 fiy1 = _fjsp_setzero_v2r8();
854 fiz1 = _fjsp_setzero_v2r8();
855 fix2 = _fjsp_setzero_v2r8();
856 fiy2 = _fjsp_setzero_v2r8();
857 fiz2 = _fjsp_setzero_v2r8();
858 fix3 = _fjsp_setzero_v2r8();
859 fiy3 = _fjsp_setzero_v2r8();
860 fiz3 = _fjsp_setzero_v2r8();
862 /* Start inner kernel loop */
863 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
866 /* Get j neighbor index, and coordinate index */
869 j_coord_offsetA = DIM*jnrA;
870 j_coord_offsetB = DIM*jnrB;
872 /* load j atom coordinates */
873 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
876 /* Calculate displacement vector */
877 dx00 = _fjsp_sub_v2r8(ix0,jx0);
878 dy00 = _fjsp_sub_v2r8(iy0,jy0);
879 dz00 = _fjsp_sub_v2r8(iz0,jz0);
880 dx10 = _fjsp_sub_v2r8(ix1,jx0);
881 dy10 = _fjsp_sub_v2r8(iy1,jy0);
882 dz10 = _fjsp_sub_v2r8(iz1,jz0);
883 dx20 = _fjsp_sub_v2r8(ix2,jx0);
884 dy20 = _fjsp_sub_v2r8(iy2,jy0);
885 dz20 = _fjsp_sub_v2r8(iz2,jz0);
886 dx30 = _fjsp_sub_v2r8(ix3,jx0);
887 dy30 = _fjsp_sub_v2r8(iy3,jy0);
888 dz30 = _fjsp_sub_v2r8(iz3,jz0);
890 /* Calculate squared distance and things based on it */
891 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
892 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
893 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
894 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
896 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
897 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
898 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
900 rinvsq00 = gmx_fjsp_inv_v2r8(rsq00);
901 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
902 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
903 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
905 /* Load parameters for j particles */
906 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
907 vdwjidx0A = 2*vdwtype[jnrA+0];
908 vdwjidx0B = 2*vdwtype[jnrB+0];
910 fjx0 = _fjsp_setzero_v2r8();
911 fjy0 = _fjsp_setzero_v2r8();
912 fjz0 = _fjsp_setzero_v2r8();
914 /**************************
915 * CALCULATE INTERACTIONS *
916 **************************/
918 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
921 /* Compute parameters for interactions between i and j atoms */
922 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
923 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
925 /* LENNARD-JONES DISPERSION/REPULSION */
927 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
928 fvdw = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
930 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
934 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
936 /* Update vectorial force */
937 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
938 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
939 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
941 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
942 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
943 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
947 /**************************
948 * CALCULATE INTERACTIONS *
949 **************************/
951 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
954 r10 = _fjsp_mul_v2r8(rsq10,rinv10);
956 /* Compute parameters for interactions between i and j atoms */
957 qq10 = _fjsp_mul_v2r8(iq1,jq0);
959 /* EWALD ELECTROSTATICS */
961 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
962 ewrt = _fjsp_mul_v2r8(r10,ewtabscale);
963 itab_tmp = _fjsp_dtox_v2r8(ewrt);
964 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
965 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
967 gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
969 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
970 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,rinv10),_fjsp_sub_v2r8(rinvsq10,felec));
972 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
976 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
978 /* Update vectorial force */
979 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
980 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
981 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
983 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
984 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
985 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
989 /**************************
990 * CALCULATE INTERACTIONS *
991 **************************/
993 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
996 r20 = _fjsp_mul_v2r8(rsq20,rinv20);
998 /* Compute parameters for interactions between i and j atoms */
999 qq20 = _fjsp_mul_v2r8(iq2,jq0);
1001 /* EWALD ELECTROSTATICS */
1003 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1004 ewrt = _fjsp_mul_v2r8(r20,ewtabscale);
1005 itab_tmp = _fjsp_dtox_v2r8(ewrt);
1006 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1007 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1009 gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
1011 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1012 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,rinv20),_fjsp_sub_v2r8(rinvsq20,felec));
1014 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
1018 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1020 /* Update vectorial force */
1021 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
1022 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1023 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1025 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1026 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1027 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1031 /**************************
1032 * CALCULATE INTERACTIONS *
1033 **************************/
1035 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
1038 r30 = _fjsp_mul_v2r8(rsq30,rinv30);
1040 /* Compute parameters for interactions between i and j atoms */
1041 qq30 = _fjsp_mul_v2r8(iq3,jq0);
1043 /* EWALD ELECTROSTATICS */
1045 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1046 ewrt = _fjsp_mul_v2r8(r30,ewtabscale);
1047 itab_tmp = _fjsp_dtox_v2r8(ewrt);
1048 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1049 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1051 gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
1053 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1054 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,rinv30),_fjsp_sub_v2r8(rinvsq30,felec));
1056 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
1060 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1062 /* Update vectorial force */
1063 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
1064 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
1065 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
1067 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
1068 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
1069 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
1073 gmx_fjsp_decrement_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fjx0,fjy0,fjz0);
1075 /* Inner loop uses 162 flops */
1078 if(jidx<j_index_end)
1082 j_coord_offsetA = DIM*jnrA;
1084 /* load j atom coordinates */
1085 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
1088 /* Calculate displacement vector */
1089 dx00 = _fjsp_sub_v2r8(ix0,jx0);
1090 dy00 = _fjsp_sub_v2r8(iy0,jy0);
1091 dz00 = _fjsp_sub_v2r8(iz0,jz0);
1092 dx10 = _fjsp_sub_v2r8(ix1,jx0);
1093 dy10 = _fjsp_sub_v2r8(iy1,jy0);
1094 dz10 = _fjsp_sub_v2r8(iz1,jz0);
1095 dx20 = _fjsp_sub_v2r8(ix2,jx0);
1096 dy20 = _fjsp_sub_v2r8(iy2,jy0);
1097 dz20 = _fjsp_sub_v2r8(iz2,jz0);
1098 dx30 = _fjsp_sub_v2r8(ix3,jx0);
1099 dy30 = _fjsp_sub_v2r8(iy3,jy0);
1100 dz30 = _fjsp_sub_v2r8(iz3,jz0);
1102 /* Calculate squared distance and things based on it */
1103 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
1104 rsq10 = gmx_fjsp_calc_rsq_v2r8(dx10,dy10,dz10);
1105 rsq20 = gmx_fjsp_calc_rsq_v2r8(dx20,dy20,dz20);
1106 rsq30 = gmx_fjsp_calc_rsq_v2r8(dx30,dy30,dz30);
1108 rinv10 = gmx_fjsp_invsqrt_v2r8(rsq10);
1109 rinv20 = gmx_fjsp_invsqrt_v2r8(rsq20);
1110 rinv30 = gmx_fjsp_invsqrt_v2r8(rsq30);
1112 rinvsq00 = gmx_fjsp_inv_v2r8(rsq00);
1113 rinvsq10 = _fjsp_mul_v2r8(rinv10,rinv10);
1114 rinvsq20 = _fjsp_mul_v2r8(rinv20,rinv20);
1115 rinvsq30 = _fjsp_mul_v2r8(rinv30,rinv30);
1117 /* Load parameters for j particles */
1118 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
1119 vdwjidx0A = 2*vdwtype[jnrA+0];
1121 fjx0 = _fjsp_setzero_v2r8();
1122 fjy0 = _fjsp_setzero_v2r8();
1123 fjz0 = _fjsp_setzero_v2r8();
1125 /**************************
1126 * CALCULATE INTERACTIONS *
1127 **************************/
1129 if (gmx_fjsp_any_lt_v2r8(rsq00,rcutoff2))
1132 /* Compute parameters for interactions between i and j atoms */
1133 gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
1135 /* LENNARD-JONES DISPERSION/REPULSION */
1137 rinvsix = _fjsp_mul_v2r8(_fjsp_mul_v2r8(rinvsq00,rinvsq00),rinvsq00);
1138 fvdw = _fjsp_mul_v2r8(_fjsp_msub_v2r8(c12_00,rinvsix,c6_00),_fjsp_mul_v2r8(rinvsix,rinvsq00));
1140 cutoff_mask = _fjsp_cmplt_v2r8(rsq00,rcutoff2);
1144 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1146 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1148 /* Update vectorial force */
1149 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
1150 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
1151 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
1153 fjx0 = _fjsp_madd_v2r8(dx00,fscal,fjx0);
1154 fjy0 = _fjsp_madd_v2r8(dy00,fscal,fjy0);
1155 fjz0 = _fjsp_madd_v2r8(dz00,fscal,fjz0);
1159 /**************************
1160 * CALCULATE INTERACTIONS *
1161 **************************/
1163 if (gmx_fjsp_any_lt_v2r8(rsq10,rcutoff2))
1166 r10 = _fjsp_mul_v2r8(rsq10,rinv10);
1168 /* Compute parameters for interactions between i and j atoms */
1169 qq10 = _fjsp_mul_v2r8(iq1,jq0);
1171 /* EWALD ELECTROSTATICS */
1173 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1174 ewrt = _fjsp_mul_v2r8(r10,ewtabscale);
1175 itab_tmp = _fjsp_dtox_v2r8(ewrt);
1176 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1177 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1179 gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
1180 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1181 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq10,rinv10),_fjsp_sub_v2r8(rinvsq10,felec));
1183 cutoff_mask = _fjsp_cmplt_v2r8(rsq10,rcutoff2);
1187 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1189 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1191 /* Update vectorial force */
1192 fix1 = _fjsp_madd_v2r8(dx10,fscal,fix1);
1193 fiy1 = _fjsp_madd_v2r8(dy10,fscal,fiy1);
1194 fiz1 = _fjsp_madd_v2r8(dz10,fscal,fiz1);
1196 fjx0 = _fjsp_madd_v2r8(dx10,fscal,fjx0);
1197 fjy0 = _fjsp_madd_v2r8(dy10,fscal,fjy0);
1198 fjz0 = _fjsp_madd_v2r8(dz10,fscal,fjz0);
1202 /**************************
1203 * CALCULATE INTERACTIONS *
1204 **************************/
1206 if (gmx_fjsp_any_lt_v2r8(rsq20,rcutoff2))
1209 r20 = _fjsp_mul_v2r8(rsq20,rinv20);
1211 /* Compute parameters for interactions between i and j atoms */
1212 qq20 = _fjsp_mul_v2r8(iq2,jq0);
1214 /* EWALD ELECTROSTATICS */
1216 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1217 ewrt = _fjsp_mul_v2r8(r20,ewtabscale);
1218 itab_tmp = _fjsp_dtox_v2r8(ewrt);
1219 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1220 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1222 gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
1223 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1224 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq20,rinv20),_fjsp_sub_v2r8(rinvsq20,felec));
1226 cutoff_mask = _fjsp_cmplt_v2r8(rsq20,rcutoff2);
1230 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1232 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1234 /* Update vectorial force */
1235 fix2 = _fjsp_madd_v2r8(dx20,fscal,fix2);
1236 fiy2 = _fjsp_madd_v2r8(dy20,fscal,fiy2);
1237 fiz2 = _fjsp_madd_v2r8(dz20,fscal,fiz2);
1239 fjx0 = _fjsp_madd_v2r8(dx20,fscal,fjx0);
1240 fjy0 = _fjsp_madd_v2r8(dy20,fscal,fjy0);
1241 fjz0 = _fjsp_madd_v2r8(dz20,fscal,fjz0);
1245 /**************************
1246 * CALCULATE INTERACTIONS *
1247 **************************/
1249 if (gmx_fjsp_any_lt_v2r8(rsq30,rcutoff2))
1252 r30 = _fjsp_mul_v2r8(rsq30,rinv30);
1254 /* Compute parameters for interactions between i and j atoms */
1255 qq30 = _fjsp_mul_v2r8(iq3,jq0);
1257 /* EWALD ELECTROSTATICS */
1259 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1260 ewrt = _fjsp_mul_v2r8(r30,ewtabscale);
1261 itab_tmp = _fjsp_dtox_v2r8(ewrt);
1262 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
1263 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
1265 gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
1266 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
1267 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq30,rinv30),_fjsp_sub_v2r8(rinvsq30,felec));
1269 cutoff_mask = _fjsp_cmplt_v2r8(rsq30,rcutoff2);
1273 fscal = _fjsp_and_v2r8(fscal,cutoff_mask);
1275 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
1277 /* Update vectorial force */
1278 fix3 = _fjsp_madd_v2r8(dx30,fscal,fix3);
1279 fiy3 = _fjsp_madd_v2r8(dy30,fscal,fiy3);
1280 fiz3 = _fjsp_madd_v2r8(dz30,fscal,fiz3);
1282 fjx0 = _fjsp_madd_v2r8(dx30,fscal,fjx0);
1283 fjy0 = _fjsp_madd_v2r8(dy30,fscal,fjy0);
1284 fjz0 = _fjsp_madd_v2r8(dz30,fscal,fjz0);
1288 gmx_fjsp_decrement_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fjx0,fjy0,fjz0);
1290 /* Inner loop uses 162 flops */
1293 /* End of innermost loop */
1295 gmx_fjsp_update_iforce_4atom_swizzle_v2r8(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1296 f+i_coord_offset,fshift+i_shift_offset);
1298 /* Increment number of inner iterations */
1299 inneriter += j_index_end - j_index_start;
1301 /* Outer loop uses 24 flops */
1304 /* Increment number of outer iterations */
1307 /* Update outer/inner flops */
1309 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*162);