2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012, by the GROMACS development team, led by
5 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 * others, as listed in the AUTHORS file in the top-level source
7 * directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS sparc64_hpc_ace_double kernel generator.
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
49 #include "kernelutil_sparc64_hpc_ace_double.h"
52 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwCSTab_GeomP1P1_VF_sparc64_hpc_ace_double
53 * Electrostatics interaction: GeneralizedBorn
54 * VdW interaction: CubicSplineTable
55 * Geometry: Particle-Particle
56 * Calculate force/pot: PotentialAndForce
59 nb_kernel_ElecGB_VdwCSTab_GeomP1P1_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_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;
83 int vdwjidx0A,vdwjidx0B;
84 _fjsp_v2r8 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
85 _fjsp_v2r8 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
86 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
88 _fjsp_v2r8 vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,twogbeps,dvdatmp;
89 _fjsp_v2r8 minushalf = gmx_fjsp_set1_v2r8(-0.5);
90 real *invsqrta,*dvda,*gbtab;
92 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
95 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
96 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
97 _fjsp_v2r8 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
100 _fjsp_v2r8 dummy_mask,cutoff_mask;
101 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
102 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
103 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
110 jindex = nlist->jindex;
112 shiftidx = nlist->shift;
114 shiftvec = fr->shift_vec[0];
115 fshift = fr->fshift[0];
116 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
117 charge = mdatoms->chargeA;
118 nvdwtype = fr->ntype;
120 vdwtype = mdatoms->typeA;
122 vftab = kernel_data->table_vdw->data;
123 vftabscale = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
125 invsqrta = fr->invsqrta;
127 gbtabscale = gmx_fjsp_set1_v2r8(fr->gbtab.scale);
128 gbtab = fr->gbtab.data;
129 gbinvepsdiff = gmx_fjsp_set1_v2r8((1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent));
131 /* Avoid stupid compiler warnings */
139 /* Start outer loop over neighborlists */
140 for(iidx=0; iidx<nri; iidx++)
142 /* Load shift vector for this list */
143 i_shift_offset = DIM*shiftidx[iidx];
145 /* Load limits for loop over neighbors */
146 j_index_start = jindex[iidx];
147 j_index_end = jindex[iidx+1];
149 /* Get outer coordinate index */
151 i_coord_offset = DIM*inr;
153 /* Load i particle coords and add shift vector */
154 gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
156 fix0 = _fjsp_setzero_v2r8();
157 fiy0 = _fjsp_setzero_v2r8();
158 fiz0 = _fjsp_setzero_v2r8();
160 /* Load parameters for i particles */
161 iq0 = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
162 isai0 = gmx_fjsp_load1_v2r8(invsqrta+inr+0);
163 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
165 /* Reset potential sums */
166 velecsum = _fjsp_setzero_v2r8();
167 vgbsum = _fjsp_setzero_v2r8();
168 vvdwsum = _fjsp_setzero_v2r8();
169 dvdasum = _fjsp_setzero_v2r8();
171 /* Start inner kernel loop */
172 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
175 /* Get j neighbor index, and coordinate index */
178 j_coord_offsetA = DIM*jnrA;
179 j_coord_offsetB = DIM*jnrB;
181 /* load j atom coordinates */
182 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
185 /* Calculate displacement vector */
186 dx00 = _fjsp_sub_v2r8(ix0,jx0);
187 dy00 = _fjsp_sub_v2r8(iy0,jy0);
188 dz00 = _fjsp_sub_v2r8(iz0,jz0);
190 /* Calculate squared distance and things based on it */
191 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
193 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
195 /* Load parameters for j particles */
196 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
197 isaj0 = gmx_fjsp_load_2real_swizzle_v2r8(invsqrta+jnrA+0,invsqrta+jnrB+0);
198 vdwjidx0A = 2*vdwtype[jnrA+0];
199 vdwjidx0B = 2*vdwtype[jnrB+0];
201 /**************************
202 * CALCULATE INTERACTIONS *
203 **************************/
205 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
207 /* Compute parameters for interactions between i and j atoms */
208 qq00 = _fjsp_mul_v2r8(iq0,jq0);
209 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
210 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
212 /* Calculate table index by multiplying r with table scale and truncate to integer */
213 rt = _fjsp_mul_v2r8(r00,vftabscale);
214 itab_tmp = _fjsp_dtox_v2r8(rt);
215 vfeps = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
216 twovfeps = _fjsp_add_v2r8(vfeps,vfeps);
217 _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
222 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
223 isaprod = _fjsp_mul_v2r8(isai0,isaj0);
224 gbqqfactor = _fjsp_neg_v2r8(_fjsp_mul_v2r8(qq00,_fjsp_mul_v2r8(isaprod,gbinvepsdiff)));
225 gbscale = _fjsp_mul_v2r8(isaprod,gbtabscale);
227 /* Calculate generalized born table index - this is a separate table from the normal one,
228 * but we use the same procedure by multiplying r with scale and truncating to integer.
230 rt = _fjsp_mul_v2r8(r00,gbscale);
231 itab_tmp = _fjsp_dtox_v2r8(rt);
232 gbeps = _fjsp_sub_v2r8(rt,_fjsp_xtod_v2r8(itab_tmp));
233 _fjsp_store_v2r8(&gbconv.simd,itab_tmp);
235 Y = _fjsp_load_v2r8( gbtab + 4*gbconv.i[0] );
236 F = _fjsp_load_v2r8( gbtab + 4*gbconv.i[1] );
237 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
238 G = _fjsp_load_v2r8( gbtab + 4*gbconv.i[0] +2);
239 H = _fjsp_load_v2r8( gbtab + 4*gbconv.i[1] +2);
240 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
241 Fp = _fjsp_madd_v2r8(gbeps,_fjsp_madd_v2r8(gbeps,H,G),F);
242 VV = _fjsp_madd_v2r8(gbeps,Fp,Y);
243 vgb = _fjsp_mul_v2r8(gbqqfactor,VV);
245 twogbeps = _fjsp_add_v2r8(gbeps,gbeps);
246 FF = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twogbeps,H,G),gbeps,Fp);
247 fgb = _fjsp_mul_v2r8(gbqqfactor,_fjsp_mul_v2r8(FF,gbscale));
248 dvdatmp = _fjsp_mul_v2r8(minushalf,_fjsp_madd_v2r8(fgb,r00,vgb));
249 dvdasum = _fjsp_add_v2r8(dvdasum,dvdatmp);
250 gmx_fjsp_increment_2real_swizzle_v2r8(dvda+jnrA,dvda+jnrB,_fjsp_mul_v2r8(dvdatmp,_fjsp_mul_v2r8(isaj0,isaj0)));
251 velec = _fjsp_mul_v2r8(qq00,rinv00);
252 felec = _fjsp_mul_v2r8(_fjsp_msub_v2r8(velec,rinv00,fgb),rinv00);
254 /* CUBIC SPLINE TABLE DISPERSION */
255 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] );
256 F = _fjsp_load_v2r8( vftab + vfconv.i[1] );
257 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
258 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
259 H = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
260 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
261 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
262 VV = _fjsp_madd_v2r8(vfeps,Fp,Y);
263 vvdw6 = _fjsp_mul_v2r8(c6_00,VV);
264 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
265 fvdw6 = _fjsp_mul_v2r8(c6_00,FF);
267 /* CUBIC SPLINE TABLE REPULSION */
268 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
269 F = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
270 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
271 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
272 H = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
273 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
274 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
275 VV = _fjsp_madd_v2r8(vfeps,Fp,Y);
276 vvdw12 = _fjsp_mul_v2r8(c12_00,VV);
277 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
278 fvdw12 = _fjsp_mul_v2r8(c12_00,FF);
279 vvdw = _fjsp_add_v2r8(vvdw12,vvdw6);
280 fvdw = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
282 /* Update potential sum for this i atom from the interaction with this j atom. */
283 velecsum = _fjsp_add_v2r8(velecsum,velec);
284 vgbsum = _fjsp_add_v2r8(vgbsum,vgb);
285 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
287 fscal = _fjsp_add_v2r8(felec,fvdw);
289 /* Update vectorial force */
290 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
291 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
292 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
294 gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
296 /* Inner loop uses 95 flops */
303 j_coord_offsetA = DIM*jnrA;
305 /* load j atom coordinates */
306 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
309 /* Calculate displacement vector */
310 dx00 = _fjsp_sub_v2r8(ix0,jx0);
311 dy00 = _fjsp_sub_v2r8(iy0,jy0);
312 dz00 = _fjsp_sub_v2r8(iz0,jz0);
314 /* Calculate squared distance and things based on it */
315 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
317 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
319 /* Load parameters for j particles */
320 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
321 isaj0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),invsqrta+jnrA+0);
322 vdwjidx0A = 2*vdwtype[jnrA+0];
324 /**************************
325 * CALCULATE INTERACTIONS *
326 **************************/
328 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
330 /* Compute parameters for interactions between i and j atoms */
331 qq00 = _fjsp_mul_v2r8(iq0,jq0);
332 gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
334 /* Calculate table index by multiplying r with table scale and truncate to integer */
335 rt = _fjsp_mul_v2r8(r00,vftabscale);
336 itab_tmp = _fjsp_dtox_v2r8(rt);
337 vfeps = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
338 twovfeps = _fjsp_add_v2r8(vfeps,vfeps);
339 _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
344 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
345 isaprod = _fjsp_mul_v2r8(isai0,isaj0);
346 gbqqfactor = _fjsp_neg_v2r8(_fjsp_mul_v2r8(qq00,_fjsp_mul_v2r8(isaprod,gbinvepsdiff)));
347 gbscale = _fjsp_mul_v2r8(isaprod,gbtabscale);
349 /* Calculate generalized born table index - this is a separate table from the normal one,
350 * but we use the same procedure by multiplying r with scale and truncating to integer.
352 rt = _fjsp_mul_v2r8(r00,gbscale);
353 itab_tmp = _fjsp_dtox_v2r8(rt);
354 gbeps = _fjsp_sub_v2r8(rt,_fjsp_xtod_v2r8(itab_tmp));
355 _fjsp_store_v2r8(&gbconv.simd,itab_tmp);
357 Y = _fjsp_load_v2r8( gbtab + 4*gbconv.i[0] );
358 F = _fjsp_setzero_v2r8();
359 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
360 G = _fjsp_load_v2r8( gbtab + 4*gbconv.i[0] +2);
361 H = _fjsp_setzero_v2r8();
362 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
363 Fp = _fjsp_madd_v2r8(gbeps,_fjsp_madd_v2r8(gbeps,H,G),F);
364 VV = _fjsp_madd_v2r8(gbeps,Fp,Y);
365 vgb = _fjsp_mul_v2r8(gbqqfactor,VV);
367 twogbeps = _fjsp_add_v2r8(gbeps,gbeps);
368 FF = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twogbeps,H,G),gbeps,Fp);
369 fgb = _fjsp_mul_v2r8(gbqqfactor,_fjsp_mul_v2r8(FF,gbscale));
370 dvdatmp = _fjsp_mul_v2r8(minushalf,_fjsp_madd_v2r8(fgb,r00,vgb));
371 dvdasum = _fjsp_add_v2r8(dvdasum,dvdatmp);
372 gmx_fjsp_increment_1real_v2r8(dvda+jnrA,_fjsp_mul_v2r8(dvdatmp,_fjsp_mul_v2r8(isaj0,isaj0)));
373 velec = _fjsp_mul_v2r8(qq00,rinv00);
374 felec = _fjsp_mul_v2r8(_fjsp_msub_v2r8(velec,rinv00,fgb),rinv00);
376 /* CUBIC SPLINE TABLE DISPERSION */
377 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] );
378 F = _fjsp_setzero_v2r8();
379 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
380 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
381 H = _fjsp_setzero_v2r8();
382 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
383 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
384 VV = _fjsp_madd_v2r8(vfeps,Fp,Y);
385 vvdw6 = _fjsp_mul_v2r8(c6_00,VV);
386 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
387 fvdw6 = _fjsp_mul_v2r8(c6_00,FF);
389 /* CUBIC SPLINE TABLE REPULSION */
390 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
391 F = _fjsp_setzero_v2r8();
392 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
393 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
394 H = _fjsp_setzero_v2r8();
395 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
396 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
397 VV = _fjsp_madd_v2r8(vfeps,Fp,Y);
398 vvdw12 = _fjsp_mul_v2r8(c12_00,VV);
399 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
400 fvdw12 = _fjsp_mul_v2r8(c12_00,FF);
401 vvdw = _fjsp_add_v2r8(vvdw12,vvdw6);
402 fvdw = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
404 /* Update potential sum for this i atom from the interaction with this j atom. */
405 velec = _fjsp_unpacklo_v2r8(velec,_fjsp_setzero_v2r8());
406 velecsum = _fjsp_add_v2r8(velecsum,velec);
407 vgb = _fjsp_unpacklo_v2r8(vgb,_fjsp_setzero_v2r8());
408 vgbsum = _fjsp_add_v2r8(vgbsum,vgb);
409 vvdw = _fjsp_unpacklo_v2r8(vvdw,_fjsp_setzero_v2r8());
410 vvdwsum = _fjsp_add_v2r8(vvdwsum,vvdw);
412 fscal = _fjsp_add_v2r8(felec,fvdw);
414 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
416 /* Update vectorial force */
417 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
418 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
419 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
421 gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
423 /* Inner loop uses 95 flops */
426 /* End of innermost loop */
428 gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
429 f+i_coord_offset,fshift+i_shift_offset);
432 /* Update potential energies */
433 gmx_fjsp_update_1pot_v2r8(velecsum,kernel_data->energygrp_elec+ggid);
434 gmx_fjsp_update_1pot_v2r8(vgbsum,kernel_data->energygrp_polarization+ggid);
435 gmx_fjsp_update_1pot_v2r8(vvdwsum,kernel_data->energygrp_vdw+ggid);
436 dvdasum = _fjsp_mul_v2r8(dvdasum, _fjsp_mul_v2r8(isai0,isai0));
437 gmx_fjsp_update_1pot_v2r8(dvdasum,dvda+inr);
439 /* Increment number of inner iterations */
440 inneriter += j_index_end - j_index_start;
442 /* Outer loop uses 10 flops */
445 /* Increment number of outer iterations */
448 /* Update outer/inner flops */
450 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*10 + inneriter*95);
453 * Gromacs nonbonded kernel: nb_kernel_ElecGB_VdwCSTab_GeomP1P1_F_sparc64_hpc_ace_double
454 * Electrostatics interaction: GeneralizedBorn
455 * VdW interaction: CubicSplineTable
456 * Geometry: Particle-Particle
457 * Calculate force/pot: Force
460 nb_kernel_ElecGB_VdwCSTab_GeomP1P1_F_sparc64_hpc_ace_double
461 (t_nblist * gmx_restrict nlist,
462 rvec * gmx_restrict xx,
463 rvec * gmx_restrict ff,
464 t_forcerec * gmx_restrict fr,
465 t_mdatoms * gmx_restrict mdatoms,
466 nb_kernel_data_t * gmx_restrict kernel_data,
467 t_nrnb * gmx_restrict nrnb)
469 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
470 * just 0 for non-waters.
471 * Suffixes A,B refer to j loop unrolling done with double precision SIMD, e.g. for the two different
472 * jnr indices corresponding to data put in the four positions in the SIMD register.
474 int i_shift_offset,i_coord_offset,outeriter,inneriter;
475 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
477 int j_coord_offsetA,j_coord_offsetB;
478 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
480 real *shiftvec,*fshift,*x,*f;
481 _fjsp_v2r8 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
483 _fjsp_v2r8 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
484 int vdwjidx0A,vdwjidx0B;
485 _fjsp_v2r8 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
486 _fjsp_v2r8 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
487 _fjsp_v2r8 velec,felec,velecsum,facel,crf,krf,krf2;
489 _fjsp_v2r8 vgb,fgb,vgbsum,dvdasum,gbscale,gbtabscale,isaprod,gbqqfactor,gbinvepsdiff,dvdaj,gbeps,twogbeps,dvdatmp;
490 _fjsp_v2r8 minushalf = gmx_fjsp_set1_v2r8(-0.5);
491 real *invsqrta,*dvda,*gbtab;
493 _fjsp_v2r8 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
496 _fjsp_v2r8 one_sixth = gmx_fjsp_set1_v2r8(1.0/6.0);
497 _fjsp_v2r8 one_twelfth = gmx_fjsp_set1_v2r8(1.0/12.0);
498 _fjsp_v2r8 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF,twovfeps;
501 _fjsp_v2r8 dummy_mask,cutoff_mask;
502 _fjsp_v2r8 one = gmx_fjsp_set1_v2r8(1.0);
503 _fjsp_v2r8 two = gmx_fjsp_set1_v2r8(2.0);
504 union { _fjsp_v2r8 simd; long long int i[2]; } vfconv,gbconv,ewconv;
511 jindex = nlist->jindex;
513 shiftidx = nlist->shift;
515 shiftvec = fr->shift_vec[0];
516 fshift = fr->fshift[0];
517 facel = gmx_fjsp_set1_v2r8(fr->epsfac);
518 charge = mdatoms->chargeA;
519 nvdwtype = fr->ntype;
521 vdwtype = mdatoms->typeA;
523 vftab = kernel_data->table_vdw->data;
524 vftabscale = gmx_fjsp_set1_v2r8(kernel_data->table_vdw->scale);
526 invsqrta = fr->invsqrta;
528 gbtabscale = gmx_fjsp_set1_v2r8(fr->gbtab.scale);
529 gbtab = fr->gbtab.data;
530 gbinvepsdiff = gmx_fjsp_set1_v2r8((1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent));
532 /* Avoid stupid compiler warnings */
540 /* Start outer loop over neighborlists */
541 for(iidx=0; iidx<nri; iidx++)
543 /* Load shift vector for this list */
544 i_shift_offset = DIM*shiftidx[iidx];
546 /* Load limits for loop over neighbors */
547 j_index_start = jindex[iidx];
548 j_index_end = jindex[iidx+1];
550 /* Get outer coordinate index */
552 i_coord_offset = DIM*inr;
554 /* Load i particle coords and add shift vector */
555 gmx_fjsp_load_shift_and_1rvec_broadcast_v2r8(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
557 fix0 = _fjsp_setzero_v2r8();
558 fiy0 = _fjsp_setzero_v2r8();
559 fiz0 = _fjsp_setzero_v2r8();
561 /* Load parameters for i particles */
562 iq0 = _fjsp_mul_v2r8(facel,gmx_fjsp_load1_v2r8(charge+inr+0));
563 isai0 = gmx_fjsp_load1_v2r8(invsqrta+inr+0);
564 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
566 dvdasum = _fjsp_setzero_v2r8();
568 /* Start inner kernel loop */
569 for(jidx=j_index_start; jidx<j_index_end-1; jidx+=2)
572 /* Get j neighbor index, and coordinate index */
575 j_coord_offsetA = DIM*jnrA;
576 j_coord_offsetB = DIM*jnrB;
578 /* load j atom coordinates */
579 gmx_fjsp_load_1rvec_2ptr_swizzle_v2r8(x+j_coord_offsetA,x+j_coord_offsetB,
582 /* Calculate displacement vector */
583 dx00 = _fjsp_sub_v2r8(ix0,jx0);
584 dy00 = _fjsp_sub_v2r8(iy0,jy0);
585 dz00 = _fjsp_sub_v2r8(iz0,jz0);
587 /* Calculate squared distance and things based on it */
588 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
590 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
592 /* Load parameters for j particles */
593 jq0 = gmx_fjsp_load_2real_swizzle_v2r8(charge+jnrA+0,charge+jnrB+0);
594 isaj0 = gmx_fjsp_load_2real_swizzle_v2r8(invsqrta+jnrA+0,invsqrta+jnrB+0);
595 vdwjidx0A = 2*vdwtype[jnrA+0];
596 vdwjidx0B = 2*vdwtype[jnrB+0];
598 /**************************
599 * CALCULATE INTERACTIONS *
600 **************************/
602 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
604 /* Compute parameters for interactions between i and j atoms */
605 qq00 = _fjsp_mul_v2r8(iq0,jq0);
606 gmx_fjsp_load_2pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,
607 vdwparam+vdwioffset0+vdwjidx0B,&c6_00,&c12_00);
609 /* Calculate table index by multiplying r with table scale and truncate to integer */
610 rt = _fjsp_mul_v2r8(r00,vftabscale);
611 itab_tmp = _fjsp_dtox_v2r8(rt);
612 vfeps = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
613 twovfeps = _fjsp_add_v2r8(vfeps,vfeps);
614 _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
619 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
620 isaprod = _fjsp_mul_v2r8(isai0,isaj0);
621 gbqqfactor = _fjsp_neg_v2r8(_fjsp_mul_v2r8(qq00,_fjsp_mul_v2r8(isaprod,gbinvepsdiff)));
622 gbscale = _fjsp_mul_v2r8(isaprod,gbtabscale);
624 /* Calculate generalized born table index - this is a separate table from the normal one,
625 * but we use the same procedure by multiplying r with scale and truncating to integer.
627 rt = _fjsp_mul_v2r8(r00,gbscale);
628 itab_tmp = _fjsp_dtox_v2r8(rt);
629 gbeps = _fjsp_sub_v2r8(rt,_fjsp_xtod_v2r8(itab_tmp));
630 _fjsp_store_v2r8(&gbconv.simd,itab_tmp);
632 Y = _fjsp_load_v2r8( gbtab + 4*gbconv.i[0] );
633 F = _fjsp_load_v2r8( gbtab + 4*gbconv.i[1] );
634 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
635 G = _fjsp_load_v2r8( gbtab + 4*gbconv.i[0] +2);
636 H = _fjsp_load_v2r8( gbtab + 4*gbconv.i[1] +2);
637 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
638 Fp = _fjsp_madd_v2r8(gbeps,_fjsp_madd_v2r8(gbeps,H,G),F);
639 VV = _fjsp_madd_v2r8(gbeps,Fp,Y);
640 vgb = _fjsp_mul_v2r8(gbqqfactor,VV);
642 twogbeps = _fjsp_add_v2r8(gbeps,gbeps);
643 FF = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twogbeps,H,G),gbeps,Fp);
644 fgb = _fjsp_mul_v2r8(gbqqfactor,_fjsp_mul_v2r8(FF,gbscale));
645 dvdatmp = _fjsp_mul_v2r8(minushalf,_fjsp_madd_v2r8(fgb,r00,vgb));
646 dvdasum = _fjsp_add_v2r8(dvdasum,dvdatmp);
647 gmx_fjsp_increment_2real_swizzle_v2r8(dvda+jnrA,dvda+jnrB,_fjsp_mul_v2r8(dvdatmp,_fjsp_mul_v2r8(isaj0,isaj0)));
648 velec = _fjsp_mul_v2r8(qq00,rinv00);
649 felec = _fjsp_mul_v2r8(_fjsp_msub_v2r8(velec,rinv00,fgb),rinv00);
651 /* CUBIC SPLINE TABLE DISPERSION */
652 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] );
653 F = _fjsp_load_v2r8( vftab + vfconv.i[1] );
654 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
655 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
656 H = _fjsp_load_v2r8( vftab + vfconv.i[1] + 2 );
657 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
658 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
659 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
660 fvdw6 = _fjsp_mul_v2r8(c6_00,FF);
662 /* CUBIC SPLINE TABLE REPULSION */
663 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
664 F = _fjsp_load_v2r8( vftab + vfconv.i[1] + 4 );
665 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
666 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
667 H = _fjsp_load_v2r8( vftab + vfconv.i[1] + 6 );
668 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
669 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
670 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
671 fvdw12 = _fjsp_mul_v2r8(c12_00,FF);
672 fvdw = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
674 fscal = _fjsp_add_v2r8(felec,fvdw);
676 /* Update vectorial force */
677 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
678 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
679 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
681 gmx_fjsp_decrement_fma_1rvec_2ptr_swizzle_v2r8(f+j_coord_offsetA,f+j_coord_offsetB,fscal,dx00,dy00,dz00);
683 /* Inner loop uses 85 flops */
690 j_coord_offsetA = DIM*jnrA;
692 /* load j atom coordinates */
693 gmx_fjsp_load_1rvec_1ptr_swizzle_v2r8(x+j_coord_offsetA,
696 /* Calculate displacement vector */
697 dx00 = _fjsp_sub_v2r8(ix0,jx0);
698 dy00 = _fjsp_sub_v2r8(iy0,jy0);
699 dz00 = _fjsp_sub_v2r8(iz0,jz0);
701 /* Calculate squared distance and things based on it */
702 rsq00 = gmx_fjsp_calc_rsq_v2r8(dx00,dy00,dz00);
704 rinv00 = gmx_fjsp_invsqrt_v2r8(rsq00);
706 /* Load parameters for j particles */
707 jq0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),charge+jnrA+0);
708 isaj0 = _fjsp_loadl_v2r8(_fjsp_setzero_v2r8(),invsqrta+jnrA+0);
709 vdwjidx0A = 2*vdwtype[jnrA+0];
711 /**************************
712 * CALCULATE INTERACTIONS *
713 **************************/
715 r00 = _fjsp_mul_v2r8(rsq00,rinv00);
717 /* Compute parameters for interactions between i and j atoms */
718 qq00 = _fjsp_mul_v2r8(iq0,jq0);
719 gmx_fjsp_load_1pair_swizzle_v2r8(vdwparam+vdwioffset0+vdwjidx0A,&c6_00,&c12_00);
721 /* Calculate table index by multiplying r with table scale and truncate to integer */
722 rt = _fjsp_mul_v2r8(r00,vftabscale);
723 itab_tmp = _fjsp_dtox_v2r8(rt);
724 vfeps = _fjsp_sub_v2r8(rt, _fjsp_xtod_v2r8(itab_tmp));
725 twovfeps = _fjsp_add_v2r8(vfeps,vfeps);
726 _fjsp_store_v2r8(&vfconv.simd,itab_tmp);
731 /* GENERALIZED BORN AND COULOMB ELECTROSTATICS */
732 isaprod = _fjsp_mul_v2r8(isai0,isaj0);
733 gbqqfactor = _fjsp_neg_v2r8(_fjsp_mul_v2r8(qq00,_fjsp_mul_v2r8(isaprod,gbinvepsdiff)));
734 gbscale = _fjsp_mul_v2r8(isaprod,gbtabscale);
736 /* Calculate generalized born table index - this is a separate table from the normal one,
737 * but we use the same procedure by multiplying r with scale and truncating to integer.
739 rt = _fjsp_mul_v2r8(r00,gbscale);
740 itab_tmp = _fjsp_dtox_v2r8(rt);
741 gbeps = _fjsp_sub_v2r8(rt,_fjsp_xtod_v2r8(itab_tmp));
742 _fjsp_store_v2r8(&gbconv.simd,itab_tmp);
744 Y = _fjsp_load_v2r8( gbtab + 4*gbconv.i[0] );
745 F = _fjsp_setzero_v2r8();
746 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
747 G = _fjsp_load_v2r8( gbtab + 4*gbconv.i[0] +2);
748 H = _fjsp_setzero_v2r8();
749 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
750 Fp = _fjsp_madd_v2r8(gbeps,_fjsp_madd_v2r8(gbeps,H,G),F);
751 VV = _fjsp_madd_v2r8(gbeps,Fp,Y);
752 vgb = _fjsp_mul_v2r8(gbqqfactor,VV);
754 twogbeps = _fjsp_add_v2r8(gbeps,gbeps);
755 FF = _fjsp_madd_v2r8(_fjsp_madd_v2r8(twogbeps,H,G),gbeps,Fp);
756 fgb = _fjsp_mul_v2r8(gbqqfactor,_fjsp_mul_v2r8(FF,gbscale));
757 dvdatmp = _fjsp_mul_v2r8(minushalf,_fjsp_madd_v2r8(fgb,r00,vgb));
758 dvdasum = _fjsp_add_v2r8(dvdasum,dvdatmp);
759 gmx_fjsp_increment_1real_v2r8(dvda+jnrA,_fjsp_mul_v2r8(dvdatmp,_fjsp_mul_v2r8(isaj0,isaj0)));
760 velec = _fjsp_mul_v2r8(qq00,rinv00);
761 felec = _fjsp_mul_v2r8(_fjsp_msub_v2r8(velec,rinv00,fgb),rinv00);
763 /* CUBIC SPLINE TABLE DISPERSION */
764 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] );
765 F = _fjsp_setzero_v2r8();
766 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
767 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 2 );
768 H = _fjsp_setzero_v2r8();
769 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
770 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
771 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
772 fvdw6 = _fjsp_mul_v2r8(c6_00,FF);
774 /* CUBIC SPLINE TABLE REPULSION */
775 Y = _fjsp_load_v2r8( vftab + vfconv.i[0] + 4 );
776 F = _fjsp_setzero_v2r8();
777 GMX_FJSP_TRANSPOSE2_V2R8(Y,F);
778 G = _fjsp_load_v2r8( vftab + vfconv.i[0] + 6 );
779 H = _fjsp_setzero_v2r8();
780 GMX_FJSP_TRANSPOSE2_V2R8(G,H);
781 Fp = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(H,vfeps,G),F);
782 FF = _fjsp_madd_v2r8(vfeps,_fjsp_madd_v2r8(twovfeps,H,G),Fp);
783 fvdw12 = _fjsp_mul_v2r8(c12_00,FF);
784 fvdw = _fjsp_neg_v2r8(_fjsp_mul_v2r8(_fjsp_add_v2r8(fvdw6,fvdw12),_fjsp_mul_v2r8(vftabscale,rinv00)));
786 fscal = _fjsp_add_v2r8(felec,fvdw);
788 fscal = _fjsp_unpacklo_v2r8(fscal,_fjsp_setzero_v2r8());
790 /* Update vectorial force */
791 fix0 = _fjsp_madd_v2r8(dx00,fscal,fix0);
792 fiy0 = _fjsp_madd_v2r8(dy00,fscal,fiy0);
793 fiz0 = _fjsp_madd_v2r8(dz00,fscal,fiz0);
795 gmx_fjsp_decrement_fma_1rvec_1ptr_swizzle_v2r8(f+j_coord_offsetA,fscal,dx00,dy00,dz00);
797 /* Inner loop uses 85 flops */
800 /* End of innermost loop */
802 gmx_fjsp_update_iforce_1atom_swizzle_v2r8(fix0,fiy0,fiz0,
803 f+i_coord_offset,fshift+i_shift_offset);
805 dvdasum = _fjsp_mul_v2r8(dvdasum, _fjsp_mul_v2r8(isai0,isai0));
806 gmx_fjsp_update_1pot_v2r8(dvdasum,dvda+inr);
808 /* Increment number of inner iterations */
809 inneriter += j_index_end - j_index_start;
811 /* Outer loop uses 7 flops */
814 /* Increment number of outer iterations */
817 /* Update outer/inner flops */
819 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*85);