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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
47 #include "kernelutil_sparc64_hpc_ace_double.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomP1P1_VF_sparc64_hpc_ace_double
51 * Electrostatics interaction: Ewald
52 * VdW interaction: CubicSplineTable
53 * Geometry: Particle-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEw_VdwCSTab_GeomP1P1_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;
81 int vdwjidx0A,vdwjidx0B;
82 _fjsp_v2r8 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
83 _fjsp_v2r8 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
84 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
87 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
90 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
91 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
92 _fjsp_v2r8 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
94 _fjsp_v2r8 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
97 _fjsp_v2r8 dummy_mask,cutoff_mask;
98 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
99 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
100 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
107 jindex = nlist->jindex;
109 shiftidx = nlist->shift;
111 shiftvec = fr->shift_vec[0];
112 fshift = fr->fshift[0];
113 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
114 charge = mdatoms->chargeA;
115 nvdwtype = fr->ntype;
117 vdwtype = mdatoms->typeA;
119 vftab = kernel_data->table_vdw->data;
120 vftabscale = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
122 sh_ewald = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
123 ewtab = fr->ic->tabq_coul_FDV0;
124 ewtabscale = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
125 ewtabhalfspace = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
127 /* Avoid stupid compiler warnings */
135 /* Start outer loop over neighborlists */
136 for(iidx=0; iidx<nri; iidx++)
138 /* Load shift vector for this list */
139 i_shift_offset = DIM*shiftidx[iidx];
141 /* Load limits for loop over neighbors */
142 j_index_start = jindex[iidx];
143 j_index_end = jindex[iidx+1];
145 /* Get outer coordinate index */
147 i_coord_offset = DIM*inr;
149 /* Load i particle coords and add shift vector */
150 gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
152 fix0 = _fjsp_setzero_v2r8();
153 fiy0 = _fjsp_setzero_v2r8();
154 fiz0 = _fjsp_setzero_v2r8();
156 /* Load parameters for i particles */
157 iq0 = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
158 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
160 /* Reset potential sums */
161 velecsum = _fjsp_setzero_v2r8();
162 vvdwsum = _fjsp_setzero_v2r8();
164 /* Start inner kernel loop */
165 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
168 /* Get j neighbor index, and coordinate index */
171 j_coord_offsetA = DIM*jnrA;
172 j_coord_offsetB = DIM*jnrB;
174 /* load j atom coordinates */
175 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
178 /* Calculate displacement vector */
179 dx00 = _fjsp_sub_v2r8(ix0,jx0);
180 dy00 = _fjsp_sub_v2r8(iy0,jy0);
181 dz00 = _fjsp_sub_v2r8(iz0,jz0);
183 /* Calculate squared distance and things based on it */
184 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
186 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
188 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
190 /* Load parameters for j particles */
191 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
192 vdwjidx0A = 2*vdwtype[jnrA+0];
193 vdwjidx0B = 2*vdwtype[jnrB+0];
195 /**************************
196 * CALCULATE INTERACTIONS *
197 **************************/
199 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
201 /* Compute parameters for interactions between i and j atoms */
202 qq00 = _fjsp_mul_v2r8(iq0,jq0);
203 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
204 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
206 /* Calculate table index by multiplying r with table scale and truncate to integer */
207 rt = _fjsp_mul_v2r8(r00,vftabscale);
208 itab_tmp = _fjsp_dtox_v2r8(rt);
209 vfeps = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
210 twovfeps = _fjsp_add_v2r8(vfeps,vfeps);
211 _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
216 /* EWALD ELECTROSTATICS */
218 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
219 ewrt = _fjsp_mul_v2r8(r00,ewtabscale);
220 itab_tmp = _fjsp_dtox_v2r8(ewrt);
221 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
222 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
224 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
225 ewtabD = _fjsp_load_v2r8( ewtab + 4*ewconv.i[1] );
226 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
227 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
228 ewtabFn = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[1] +2);
229 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
230 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
231 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
232 velec = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(rinv00,velec));
233 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
235 /* CUBIC SPLINE TABLE DISPERSION */
236 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] );
237 F = _fjsp_load_v2r8( vftab + vfconv.i[1] );
238 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
239 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
240 H = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
241 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
242 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
243 VV = _fjsp_madd_v2r8(vfeps,Fp,Y);
244 vvdw6 = _fjsp_mul_v2r8(c6_00,VV);
245 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
246 fvdw6 = _fjsp_mul_v2r8(c6_00,FF);
248 /* CUBIC SPLINE TABLE REPULSION */
249 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
250 F = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
251 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
252 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
253 H = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
254 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
255 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
256 VV = _fjsp_madd_v2r8(vfeps,Fp,Y);
257 vvdw12 = _fjsp_mul_v2r8(c12_00,VV);
258 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
259 fvdw12 = _fjsp_mul_v2r8(c12_00,FF);
260 vvdw = _fjsp_add_v2r8(vvdw12,vvdw6);
261 fvdw = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
263 /* Update potential sum for this i atom from the interaction with this j atom. */
264 velecsum = _fjsp_add_v2r8(velecsum,velec);
265 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
267 fscal = _fjsp_add_v2r8(felec,fvdw);
269 /* Update vectorial force */
270 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
271 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
272 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
274 gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
276 /* Inner loop uses 78 flops */
283 j_coord_offsetA = DIM*jnrA;
285 /* load j atom coordinates */
286 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
289 /* Calculate displacement vector */
290 dx00 = _fjsp_sub_v2r8(ix0,jx0);
291 dy00 = _fjsp_sub_v2r8(iy0,jy0);
292 dz00 = _fjsp_sub_v2r8(iz0,jz0);
294 /* Calculate squared distance and things based on it */
295 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
297 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
299 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
301 /* Load parameters for j particles */
302 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
303 vdwjidx0A = 2*vdwtype[jnrA+0];
305 /**************************
306 * CALCULATE INTERACTIONS *
307 **************************/
309 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
311 /* Compute parameters for interactions between i and j atoms */
312 qq00 = _fjsp_mul_v2r8(iq0,jq0);
313 gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
315 /* Calculate table index by multiplying r with table scale and truncate to integer */
316 rt = _fjsp_mul_v2r8(r00,vftabscale);
317 itab_tmp = _fjsp_dtox_v2r8(rt);
318 vfeps = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
319 twovfeps = _fjsp_add_v2r8(vfeps,vfeps);
320 _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
325 /* EWALD ELECTROSTATICS */
327 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
328 ewrt = _fjsp_mul_v2r8(r00,ewtabscale);
329 itab_tmp = _fjsp_dtox_v2r8(ewrt);
330 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
331 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
333 ewtabF = _fjsp_load_v2r8( ewtab + 4*ewconv.i[0] );
334 ewtabD = _fjsp_setzero_v2r8();
335 GMX_FJSP_TRANSPOSE2_V2R8(ewtabF,ewtabD);
336 ewtabV = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(), ewtab + 4*ewconv.i[0] +2);
337 ewtabFn = _fjsp_setzero_v2r8();
338 GMX_FJSP_TRANSPOSE2_V2R8(ewtabV,ewtabFn);
339 felec = _fjsp_madd_v2r8(eweps,ewtabD,ewtabF);
340 velec = _fjsp_nmsub_v2r8(_fjsp_mul_v2r8(ewtabhalfspace,eweps) ,_fjsp_add_v2r8(ewtabF,felec), ewtabV);
341 velec = _fjsp_mul_v2r8(qq00,_fjsp_sub_v2r8(rinv00,velec));
342 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
344 /* CUBIC SPLINE TABLE DISPERSION */
345 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] );
346 F = _fjsp_setzero_v2r8();
347 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
348 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
349 H = _fjsp_setzero_v2r8();
350 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
351 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
352 VV = _fjsp_madd_v2r8(vfeps,Fp,Y);
353 vvdw6 = _fjsp_mul_v2r8(c6_00,VV);
354 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
355 fvdw6 = _fjsp_mul_v2r8(c6_00,FF);
357 /* CUBIC SPLINE TABLE REPULSION */
358 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
359 F = _fjsp_setzero_v2r8();
360 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
361 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
362 H = _fjsp_setzero_v2r8();
363 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
364 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
365 VV = _fjsp_madd_v2r8(vfeps,Fp,Y);
366 vvdw12 = _fjsp_mul_v2r8(c12_00,VV);
367 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
368 fvdw12 = _fjsp_mul_v2r8(c12_00,FF);
369 vvdw = _fjsp_add_v2r8(vvdw12,vvdw6);
370 fvdw = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
372 /* Update potential sum for this i atom from the interaction with this j atom. */
373 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
374 velecsum = _fjsp_add_v2r8(velecsum,velec);
375 vvdw = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
376 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
378 fscal = _fjsp_add_v2r8(felec,fvdw);
380 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
382 /* Update vectorial force */
383 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
384 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
385 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
387 gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
389 /* Inner loop uses 78 flops */
392 /* End of innermost loop */
394 gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
395 f+i_coord_offset,fshift+i_shift_offset);
398 /* Update potential energies */
399 gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
400 gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
402 /* Increment number of inner iterations */
403 inneriter += j_index_end - j_index_start;
405 /* Outer loop uses 9 flops */
408 /* Increment number of outer iterations */
411 /* Update outer/inner flops */
413 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*78);
416 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwCSTab_GeomP1P1_F_sparc64_hpc_ace_double
417 * Electrostatics interaction: Ewald
418 * VdW interaction: CubicSplineTable
419 * Geometry: Particle-Particle
420 * Calculate force/pot: Force
423 nb_kernel_ElecEw_VdwCSTab_GeomP1P1_F_sparc64_hpc_ace_double
424 (t_nblist * gmx_restrict nlist,
425 rvec * gmx_restrict xx,
426 rvec * gmx_restrict ff,
427 t_forcerec * gmx_restrict fr,
428 t_mdatoms * gmx_restrict mdatoms,
429 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
430 t_nrnb * gmx_restrict nrnb)
432 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
433 * just 0 for non-waters.
434 * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
435 * jnr indices corresponding to data put in the four positions in the SIMD register.
437 int i_shift_offset,i_coord_offset,outeriter,inneriter;
438 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
440 int j_coord_offsetA,j_coord_offsetB;
441 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
443 real *shiftvec,*fshift,*x,*f;
444 _fjsp_v2r8 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
446 _fjsp_v2r8 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
447 int vdwjidx0A,vdwjidx0B;
448 _fjsp_v2r8 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
449 _fjsp_v2r8 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
450 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
453 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
456 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
457 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
458 _fjsp_v2r8 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
460 _fjsp_v2r8 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
463 _fjsp_v2r8 dummy_mask,cutoff_mask;
464 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
465 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
466 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
473 jindex = nlist->jindex;
475 shiftidx = nlist->shift;
477 shiftvec = fr->shift_vec[0];
478 fshift = fr->fshift[0];
479 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
480 charge = mdatoms->chargeA;
481 nvdwtype = fr->ntype;
483 vdwtype = mdatoms->typeA;
485 vftab = kernel_data->table_vdw->data;
486 vftabscale = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
488 sh_ewald = gmx_fjsp_set1_v2r8(fr->ic->sh_ewald);
489 ewtab = fr->ic->tabq_coul_F;
490 ewtabscale = gmx_fjsp_set1_v2r8(fr->ic->tabq_scale);
491 ewtabhalfspace = gmx_fjsp_set1_v2r8(0.5/fr->ic->tabq_scale);
493 /* Avoid stupid compiler warnings */
501 /* Start outer loop over neighborlists */
502 for(iidx=0; iidx<nri; iidx++)
504 /* Load shift vector for this list */
505 i_shift_offset = DIM*shiftidx[iidx];
507 /* Load limits for loop over neighbors */
508 j_index_start = jindex[iidx];
509 j_index_end = jindex[iidx+1];
511 /* Get outer coordinate index */
513 i_coord_offset = DIM*inr;
515 /* Load i particle coords and add shift vector */
516 gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
518 fix0 = _fjsp_setzero_v2r8();
519 fiy0 = _fjsp_setzero_v2r8();
520 fiz0 = _fjsp_setzero_v2r8();
522 /* Load parameters for i particles */
523 iq0 = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
524 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
526 /* Start inner kernel loop */
527 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
530 /* Get j neighbor index, and coordinate index */
533 j_coord_offsetA = DIM*jnrA;
534 j_coord_offsetB = DIM*jnrB;
536 /* load j atom coordinates */
537 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
540 /* Calculate displacement vector */
541 dx00 = _fjsp_sub_v2r8(ix0,jx0);
542 dy00 = _fjsp_sub_v2r8(iy0,jy0);
543 dz00 = _fjsp_sub_v2r8(iz0,jz0);
545 /* Calculate squared distance and things based on it */
546 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
548 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
550 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
552 /* Load parameters for j particles */
553 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
554 vdwjidx0A = 2*vdwtype[jnrA+0];
555 vdwjidx0B = 2*vdwtype[jnrB+0];
557 /**************************
558 * CALCULATE INTERACTIONS *
559 **************************/
561 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
563 /* Compute parameters for interactions between i and j atoms */
564 qq00 = _fjsp_mul_v2r8(iq0,jq0);
565 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
566 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
568 /* Calculate table index by multiplying r with table scale and truncate to integer */
569 rt = _fjsp_mul_v2r8(r00,vftabscale);
570 itab_tmp = _fjsp_dtox_v2r8(rt);
571 vfeps = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
572 twovfeps = _fjsp_add_v2r8(vfeps,vfeps);
573 _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
578 /* EWALD ELECTROSTATICS */
580 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
581 ewrt = _fjsp_mul_v2r8(r00,ewtabscale);
582 itab_tmp = _fjsp_dtox_v2r8(ewrt);
583 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
584 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
586 gmx_fjsp_load_2pair_swizzle_v2r8(ewtab+ewconv.i[0],ewtab+ewconv.i[1],
588 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
589 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
591 /* CUBIC SPLINE TABLE DISPERSION */
592 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] );
593 F = _fjsp_load_v2r8( vftab + vfconv.i[1] );
594 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
595 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
596 H = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
597 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
598 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
599 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
600 fvdw6 = _fjsp_mul_v2r8(c6_00,FF);
602 /* CUBIC SPLINE TABLE REPULSION */
603 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
604 F = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
605 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
606 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
607 H = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
608 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
609 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
610 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
611 fvdw12 = _fjsp_mul_v2r8(c12_00,FF);
612 fvdw = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
614 fscal = _fjsp_add_v2r8(felec,fvdw);
616 /* Update vectorial force */
617 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
618 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
619 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
621 gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
623 /* Inner loop uses 65 flops */
630 j_coord_offsetA = DIM*jnrA;
632 /* load j atom coordinates */
633 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
636 /* Calculate displacement vector */
637 dx00 = _fjsp_sub_v2r8(ix0,jx0);
638 dy00 = _fjsp_sub_v2r8(iy0,jy0);
639 dz00 = _fjsp_sub_v2r8(iz0,jz0);
641 /* Calculate squared distance and things based on it */
642 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
644 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
646 rinvsq00 = _fjsp_mul_v2r8(rinv00,rinv00);
648 /* Load parameters for j particles */
649 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
650 vdwjidx0A = 2*vdwtype[jnrA+0];
652 /**************************
653 * CALCULATE INTERACTIONS *
654 **************************/
656 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
658 /* Compute parameters for interactions between i and j atoms */
659 qq00 = _fjsp_mul_v2r8(iq0,jq0);
660 gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
662 /* Calculate table index by multiplying r with table scale and truncate to integer */
663 rt = _fjsp_mul_v2r8(r00,vftabscale);
664 itab_tmp = _fjsp_dtox_v2r8(rt);
665 vfeps = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
666 twovfeps = _fjsp_add_v2r8(vfeps,vfeps);
667 _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
672 /* EWALD ELECTROSTATICS */
674 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
675 ewrt = _fjsp_mul_v2r8(r00,ewtabscale);
676 itab_tmp = _fjsp_dtox_v2r8(ewrt);
677 eweps = _fjsp_sub_v2r8(ewrt,_fjsp_xtod_v2r8(itab_tmp));
678 _fjsp_store_v2r8(&ewconv.simd,itab_tmp);
680 gmx_fjsp_load_1pair_swizzle_v2r8(ewtab+ewconv.i[0],&ewtabF,&ewtabFn);
681 felec = _fjsp_madd_v2r8(eweps,ewtabFn,_fjsp_nmsub_v2r8(eweps,ewtabF,ewtabF));
682 felec = _fjsp_mul_v2r8(_fjsp_mul_v2r8(qq00,rinv00),_fjsp_sub_v2r8(rinvsq00,felec));
684 /* CUBIC SPLINE TABLE DISPERSION */
685 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] );
686 F = _fjsp_setzero_v2r8();
687 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
688 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
689 H = _fjsp_setzero_v2r8();
690 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
691 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
692 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
693 fvdw6 = _fjsp_mul_v2r8(c6_00,FF);
695 /* CUBIC SPLINE TABLE REPULSION */
696 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
697 F = _fjsp_setzero_v2r8();
698 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
699 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
700 H = _fjsp_setzero_v2r8();
701 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
702 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
703 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
704 fvdw12 = _fjsp_mul_v2r8(c12_00,FF);
705 fvdw = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
707 fscal = _fjsp_add_v2r8(felec,fvdw);
709 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
711 /* Update vectorial force */
712 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
713 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
714 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
716 gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
718 /* Inner loop uses 65 flops */
721 /* End of innermost loop */
723 gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
724 f+i_coord_offset,fshift+i_shift_offset);
726 /* Increment number of inner iterations */
727 inneriter += j_index_end - j_index_start;
729 /* Outer loop uses 7 flops */
732 /* Increment number of outer iterations */
735 /* Update outer/inner flops */
737 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*65);