File: | gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_ElecEwSh_VdwLJEwSh_GeomP1P1_sse4_1_single.c |
Location: | line 558, column 5 |
Description: | Value stored to 'ewtabhalfspace' is never read |
1 | /* |
2 | * This file is part of the GROMACS molecular simulation package. |
3 | * |
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. |
8 | * |
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. |
13 | * |
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. |
18 | * |
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. |
23 | * |
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. |
31 | * |
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. |
34 | */ |
35 | /* |
36 | * Note: this file was generated by the GROMACS sse4_1_single kernel generator. |
37 | */ |
38 | #ifdef HAVE_CONFIG_H1 |
39 | #include <config.h> |
40 | #endif |
41 | |
42 | #include <math.h> |
43 | |
44 | #include "../nb_kernel.h" |
45 | #include "types/simple.h" |
46 | #include "gromacs/math/vec.h" |
47 | #include "nrnb.h" |
48 | |
49 | #include "gromacs/simd/math_x86_sse4_1_single.h" |
50 | #include "kernelutil_x86_sse4_1_single.h" |
51 | |
52 | /* |
53 | * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJEwSh_GeomP1P1_VF_sse4_1_single |
54 | * Electrostatics interaction: Ewald |
55 | * VdW interaction: LJEwald |
56 | * Geometry: Particle-Particle |
57 | * Calculate force/pot: PotentialAndForce |
58 | */ |
59 | void |
60 | nb_kernel_ElecEwSh_VdwLJEwSh_GeomP1P1_VF_sse4_1_single |
61 | (t_nblist * gmx_restrict nlist, |
62 | rvec * gmx_restrict xx, |
63 | rvec * gmx_restrict ff, |
64 | t_forcerec * gmx_restrict fr, |
65 | t_mdatoms * gmx_restrict mdatoms, |
66 | nb_kernel_data_t gmx_unused__attribute__ ((unused)) * gmx_restrict kernel_data, |
67 | t_nrnb * gmx_restrict nrnb) |
68 | { |
69 | /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or |
70 | * just 0 for non-waters. |
71 | * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different |
72 | * jnr indices corresponding to data put in the four positions in the SIMD register. |
73 | */ |
74 | int i_shift_offset,i_coord_offset,outeriter,inneriter; |
75 | int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx; |
76 | int jnrA,jnrB,jnrC,jnrD; |
77 | int jnrlistA,jnrlistB,jnrlistC,jnrlistD; |
78 | int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD; |
79 | int *iinr,*jindex,*jjnr,*shiftidx,*gid; |
80 | real rcutoff_scalar; |
81 | real *shiftvec,*fshift,*x,*f; |
82 | real *fjptrA,*fjptrB,*fjptrC,*fjptrD; |
83 | real scratch[4*DIM3]; |
84 | __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall; |
85 | int vdwioffset0; |
86 | __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0; |
87 | int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D; |
88 | __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0; |
89 | __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00; |
90 | __m128 velec,felec,velecsum,facel,crf,krf,krf2; |
91 | real *charge; |
92 | int nvdwtype; |
93 | __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6; |
94 | int *vdwtype; |
95 | real *vdwparam; |
96 | __m128 one_sixth = _mm_set1_ps(1.0/6.0); |
97 | __m128 one_twelfth = _mm_set1_ps(1.0/12.0); |
98 | __m128 c6grid_00; |
99 | __m128 ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald; |
100 | real *vdwgridparam; |
101 | __m128 one_half = _mm_set1_ps(0.5); |
102 | __m128 minus_one = _mm_set1_ps(-1.0); |
103 | __m128i ewitab; |
104 | __m128 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV; |
105 | real *ewtab; |
106 | __m128 dummy_mask,cutoff_mask; |
107 | __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) ); |
108 | __m128 one = _mm_set1_ps(1.0); |
109 | __m128 two = _mm_set1_ps(2.0); |
110 | x = xx[0]; |
111 | f = ff[0]; |
112 | |
113 | nri = nlist->nri; |
114 | iinr = nlist->iinr; |
115 | jindex = nlist->jindex; |
116 | jjnr = nlist->jjnr; |
117 | shiftidx = nlist->shift; |
118 | gid = nlist->gid; |
119 | shiftvec = fr->shift_vec[0]; |
120 | fshift = fr->fshift[0]; |
121 | facel = _mm_set1_ps(fr->epsfac); |
122 | charge = mdatoms->chargeA; |
123 | nvdwtype = fr->ntype; |
124 | vdwparam = fr->nbfp; |
125 | vdwtype = mdatoms->typeA; |
126 | vdwgridparam = fr->ljpme_c6grid; |
127 | sh_lj_ewald = _mm_set1_ps(fr->ic->sh_lj_ewald); |
128 | ewclj = _mm_set1_ps(fr->ewaldcoeff_lj); |
129 | ewclj2 = _mm_mul_ps(minus_one,_mm_mul_ps(ewclj,ewclj)); |
130 | |
131 | sh_ewald = _mm_set1_ps(fr->ic->sh_ewald); |
132 | ewtab = fr->ic->tabq_coul_FDV0; |
133 | ewtabscale = _mm_set1_ps(fr->ic->tabq_scale); |
134 | ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale); |
135 | |
136 | /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */ |
137 | rcutoff_scalar = fr->rcoulomb; |
138 | rcutoff = _mm_set1_ps(rcutoff_scalar); |
139 | rcutoff2 = _mm_mul_ps(rcutoff,rcutoff); |
140 | |
141 | sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6); |
142 | rvdw = _mm_set1_ps(fr->rvdw); |
143 | |
144 | /* Avoid stupid compiler warnings */ |
145 | jnrA = jnrB = jnrC = jnrD = 0; |
146 | j_coord_offsetA = 0; |
147 | j_coord_offsetB = 0; |
148 | j_coord_offsetC = 0; |
149 | j_coord_offsetD = 0; |
150 | |
151 | outeriter = 0; |
152 | inneriter = 0; |
153 | |
154 | for(iidx=0;iidx<4*DIM3;iidx++) |
155 | { |
156 | scratch[iidx] = 0.0; |
157 | } |
158 | |
159 | /* Start outer loop over neighborlists */ |
160 | for(iidx=0; iidx<nri; iidx++) |
161 | { |
162 | /* Load shift vector for this list */ |
163 | i_shift_offset = DIM3*shiftidx[iidx]; |
164 | |
165 | /* Load limits for loop over neighbors */ |
166 | j_index_start = jindex[iidx]; |
167 | j_index_end = jindex[iidx+1]; |
168 | |
169 | /* Get outer coordinate index */ |
170 | inr = iinr[iidx]; |
171 | i_coord_offset = DIM3*inr; |
172 | |
173 | /* Load i particle coords and add shift vector */ |
174 | gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0); |
175 | |
176 | fix0 = _mm_setzero_ps(); |
177 | fiy0 = _mm_setzero_ps(); |
178 | fiz0 = _mm_setzero_ps(); |
179 | |
180 | /* Load parameters for i particles */ |
181 | iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0)); |
182 | vdwioffset0 = 2*nvdwtype*vdwtype[inr+0]; |
183 | |
184 | /* Reset potential sums */ |
185 | velecsum = _mm_setzero_ps(); |
186 | vvdwsum = _mm_setzero_ps(); |
187 | |
188 | /* Start inner kernel loop */ |
189 | for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4) |
190 | { |
191 | |
192 | /* Get j neighbor index, and coordinate index */ |
193 | jnrA = jjnr[jidx]; |
194 | jnrB = jjnr[jidx+1]; |
195 | jnrC = jjnr[jidx+2]; |
196 | jnrD = jjnr[jidx+3]; |
197 | j_coord_offsetA = DIM3*jnrA; |
198 | j_coord_offsetB = DIM3*jnrB; |
199 | j_coord_offsetC = DIM3*jnrC; |
200 | j_coord_offsetD = DIM3*jnrD; |
201 | |
202 | /* load j atom coordinates */ |
203 | gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB, |
204 | x+j_coord_offsetC,x+j_coord_offsetD, |
205 | &jx0,&jy0,&jz0); |
206 | |
207 | /* Calculate displacement vector */ |
208 | dx00 = _mm_sub_ps(ix0,jx0); |
209 | dy00 = _mm_sub_ps(iy0,jy0); |
210 | dz00 = _mm_sub_ps(iz0,jz0); |
211 | |
212 | /* Calculate squared distance and things based on it */ |
213 | rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00); |
214 | |
215 | rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00); |
216 | |
217 | rinvsq00 = _mm_mul_ps(rinv00,rinv00); |
218 | |
219 | /* Load parameters for j particles */ |
220 | jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0, |
221 | charge+jnrC+0,charge+jnrD+0); |
222 | vdwjidx0A = 2*vdwtype[jnrA+0]; |
223 | vdwjidx0B = 2*vdwtype[jnrB+0]; |
224 | vdwjidx0C = 2*vdwtype[jnrC+0]; |
225 | vdwjidx0D = 2*vdwtype[jnrD+0]; |
226 | |
227 | /************************** |
228 | * CALCULATE INTERACTIONS * |
229 | **************************/ |
230 | |
231 | if (gmx_mm_any_lt(rsq00,rcutoff2)) |
232 | { |
233 | |
234 | r00 = _mm_mul_ps(rsq00,rinv00); |
235 | |
236 | /* Compute parameters for interactions between i and j atoms */ |
237 | qq00 = _mm_mul_ps(iq0,jq0); |
238 | gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A, |
239 | vdwparam+vdwioffset0+vdwjidx0B, |
240 | vdwparam+vdwioffset0+vdwjidx0C, |
241 | vdwparam+vdwioffset0+vdwjidx0D, |
242 | &c6_00,&c12_00); |
243 | |
244 | c6grid_00 = gmx_mm_load_4real_swizzle_ps(vdwgridparam+vdwioffset0+vdwjidx0A, |
245 | vdwgridparam+vdwioffset0+vdwjidx0B, |
246 | vdwgridparam+vdwioffset0+vdwjidx0C, |
247 | vdwgridparam+vdwioffset0+vdwjidx0D); |
248 | |
249 | /* EWALD ELECTROSTATICS */ |
250 | |
251 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
252 | ewrt = _mm_mul_ps(r00,ewtabscale); |
253 | ewitab = _mm_cvttps_epi32(ewrt); |
254 | eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps ((__v4sf)__X, ((0x00 | 0x01))); })); |
255 | ewitab = _mm_slli_epi32(ewitab,2); |
256 | ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) & 3];})) ); |
257 | ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) & 3];})) ); |
258 | ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) & 3];})) ); |
259 | ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) & 3];})) ); |
260 | _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF ), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1 = _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps ((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); ( ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps (tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while ( 0); |
261 | felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD)); |
262 | velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec))); |
263 | velec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_sub_ps(rinv00,sh_ewald),velec)); |
264 | felec = _mm_mul_ps(_mm_mul_ps(qq00,rinv00),_mm_sub_ps(rinvsq00,felec)); |
265 | |
266 | /* Analytical LJ-PME */ |
267 | rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00); |
268 | ewcljrsq = _mm_mul_ps(ewclj2,rsq00); |
269 | ewclj6 = _mm_mul_ps(ewclj2,_mm_mul_ps(ewclj2,ewclj2)); |
270 | exponent = gmx_simd_exp_rgmx_simd_exp_f(ewcljrsq); |
271 | /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */ |
272 | poly = _mm_mul_ps(exponent,_mm_add_ps(_mm_sub_ps(one,ewcljrsq),_mm_mul_ps(_mm_mul_ps(ewcljrsq,ewcljrsq),one_half))); |
273 | /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */ |
274 | vvdw6 = _mm_mul_ps(_mm_sub_ps(c6_00,_mm_mul_ps(c6grid_00,_mm_sub_ps(one,poly))),rinvsix); |
275 | vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix)); |
276 | vvdw = _mm_sub_ps(_mm_mul_ps( _mm_sub_ps(vvdw12 , _mm_mul_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6))),one_twelfth), |
277 | _mm_mul_ps( _mm_sub_ps(vvdw6,_mm_add_ps(_mm_mul_ps(c6_00,sh_vdw_invrcut6),_mm_mul_ps(c6grid_00,sh_lj_ewald))),one_sixth)); |
278 | /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */ |
279 | fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,_mm_sub_ps(vvdw6,_mm_mul_ps(_mm_mul_ps(c6grid_00,one_sixth),_mm_mul_ps(exponent,ewclj6)))),rinvsq00); |
280 | |
281 | cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2); |
282 | |
283 | /* Update potential sum for this i atom from the interaction with this j atom. */ |
284 | velec = _mm_and_ps(velec,cutoff_mask); |
285 | velecsum = _mm_add_ps(velecsum,velec); |
286 | vvdw = _mm_and_ps(vvdw,cutoff_mask); |
287 | vvdwsum = _mm_add_ps(vvdwsum,vvdw); |
288 | |
289 | fscal = _mm_add_ps(felec,fvdw); |
290 | |
291 | fscal = _mm_and_ps(fscal,cutoff_mask); |
292 | |
293 | /* Calculate temporary vectorial force */ |
294 | tx = _mm_mul_ps(fscal,dx00); |
295 | ty = _mm_mul_ps(fscal,dy00); |
296 | tz = _mm_mul_ps(fscal,dz00); |
297 | |
298 | /* Update vectorial force */ |
299 | fix0 = _mm_add_ps(fix0,tx); |
300 | fiy0 = _mm_add_ps(fiy0,ty); |
301 | fiz0 = _mm_add_ps(fiz0,tz); |
302 | |
303 | fjptrA = f+j_coord_offsetA; |
304 | fjptrB = f+j_coord_offsetB; |
305 | fjptrC = f+j_coord_offsetC; |
306 | fjptrD = f+j_coord_offsetD; |
307 | gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz); |
308 | |
309 | } |
310 | |
311 | /* Inner loop uses 82 flops */ |
312 | } |
313 | |
314 | if(jidx<j_index_end) |
315 | { |
316 | |
317 | /* Get j neighbor index, and coordinate index */ |
318 | jnrlistA = jjnr[jidx]; |
319 | jnrlistB = jjnr[jidx+1]; |
320 | jnrlistC = jjnr[jidx+2]; |
321 | jnrlistD = jjnr[jidx+3]; |
322 | /* Sign of each element will be negative for non-real atoms. |
323 | * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones, |
324 | * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries. |
325 | */ |
326 | dummy_mask = gmx_mm_castsi128_ps_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())); |
327 | jnrA = (jnrlistA>=0) ? jnrlistA : 0; |
328 | jnrB = (jnrlistB>=0) ? jnrlistB : 0; |
329 | jnrC = (jnrlistC>=0) ? jnrlistC : 0; |
330 | jnrD = (jnrlistD>=0) ? jnrlistD : 0; |
331 | j_coord_offsetA = DIM3*jnrA; |
332 | j_coord_offsetB = DIM3*jnrB; |
333 | j_coord_offsetC = DIM3*jnrC; |
334 | j_coord_offsetD = DIM3*jnrD; |
335 | |
336 | /* load j atom coordinates */ |
337 | gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB, |
338 | x+j_coord_offsetC,x+j_coord_offsetD, |
339 | &jx0,&jy0,&jz0); |
340 | |
341 | /* Calculate displacement vector */ |
342 | dx00 = _mm_sub_ps(ix0,jx0); |
343 | dy00 = _mm_sub_ps(iy0,jy0); |
344 | dz00 = _mm_sub_ps(iz0,jz0); |
345 | |
346 | /* Calculate squared distance and things based on it */ |
347 | rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00); |
348 | |
349 | rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00); |
350 | |
351 | rinvsq00 = _mm_mul_ps(rinv00,rinv00); |
352 | |
353 | /* Load parameters for j particles */ |
354 | jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0, |
355 | charge+jnrC+0,charge+jnrD+0); |
356 | vdwjidx0A = 2*vdwtype[jnrA+0]; |
357 | vdwjidx0B = 2*vdwtype[jnrB+0]; |
358 | vdwjidx0C = 2*vdwtype[jnrC+0]; |
359 | vdwjidx0D = 2*vdwtype[jnrD+0]; |
360 | |
361 | /************************** |
362 | * CALCULATE INTERACTIONS * |
363 | **************************/ |
364 | |
365 | if (gmx_mm_any_lt(rsq00,rcutoff2)) |
366 | { |
367 | |
368 | r00 = _mm_mul_ps(rsq00,rinv00); |
369 | r00 = _mm_andnot_ps(dummy_mask,r00); |
370 | |
371 | /* Compute parameters for interactions between i and j atoms */ |
372 | qq00 = _mm_mul_ps(iq0,jq0); |
373 | gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A, |
374 | vdwparam+vdwioffset0+vdwjidx0B, |
375 | vdwparam+vdwioffset0+vdwjidx0C, |
376 | vdwparam+vdwioffset0+vdwjidx0D, |
377 | &c6_00,&c12_00); |
378 | |
379 | c6grid_00 = gmx_mm_load_4real_swizzle_ps(vdwgridparam+vdwioffset0+vdwjidx0A, |
380 | vdwgridparam+vdwioffset0+vdwjidx0B, |
381 | vdwgridparam+vdwioffset0+vdwjidx0C, |
382 | vdwgridparam+vdwioffset0+vdwjidx0D); |
383 | |
384 | /* EWALD ELECTROSTATICS */ |
385 | |
386 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
387 | ewrt = _mm_mul_ps(r00,ewtabscale); |
388 | ewitab = _mm_cvttps_epi32(ewrt); |
389 | eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps ((__v4sf)__X, ((0x00 | 0x01))); })); |
390 | ewitab = _mm_slli_epi32(ewitab,2); |
391 | ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) & 3];})) ); |
392 | ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) & 3];})) ); |
393 | ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) & 3];})) ); |
394 | ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) & 3];})) ); |
395 | _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF ), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1 = _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps ((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); ( ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps (tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while ( 0); |
396 | felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD)); |
397 | velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec))); |
398 | velec = _mm_mul_ps(qq00,_mm_sub_ps(_mm_sub_ps(rinv00,sh_ewald),velec)); |
399 | felec = _mm_mul_ps(_mm_mul_ps(qq00,rinv00),_mm_sub_ps(rinvsq00,felec)); |
400 | |
401 | /* Analytical LJ-PME */ |
402 | rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00); |
403 | ewcljrsq = _mm_mul_ps(ewclj2,rsq00); |
404 | ewclj6 = _mm_mul_ps(ewclj2,_mm_mul_ps(ewclj2,ewclj2)); |
405 | exponent = gmx_simd_exp_rgmx_simd_exp_f(ewcljrsq); |
406 | /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */ |
407 | poly = _mm_mul_ps(exponent,_mm_add_ps(_mm_sub_ps(one,ewcljrsq),_mm_mul_ps(_mm_mul_ps(ewcljrsq,ewcljrsq),one_half))); |
408 | /* vvdw6 = [C6 - C6grid * (1-poly)]/r6 */ |
409 | vvdw6 = _mm_mul_ps(_mm_sub_ps(c6_00,_mm_mul_ps(c6grid_00,_mm_sub_ps(one,poly))),rinvsix); |
410 | vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix)); |
411 | vvdw = _mm_sub_ps(_mm_mul_ps( _mm_sub_ps(vvdw12 , _mm_mul_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6))),one_twelfth), |
412 | _mm_mul_ps( _mm_sub_ps(vvdw6,_mm_add_ps(_mm_mul_ps(c6_00,sh_vdw_invrcut6),_mm_mul_ps(c6grid_00,sh_lj_ewald))),one_sixth)); |
413 | /* fvdw = vvdw12/r - (vvdw6/r + (C6grid * exponent * beta^6)/r) */ |
414 | fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,_mm_sub_ps(vvdw6,_mm_mul_ps(_mm_mul_ps(c6grid_00,one_sixth),_mm_mul_ps(exponent,ewclj6)))),rinvsq00); |
415 | |
416 | cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2); |
417 | |
418 | /* Update potential sum for this i atom from the interaction with this j atom. */ |
419 | velec = _mm_and_ps(velec,cutoff_mask); |
420 | velec = _mm_andnot_ps(dummy_mask,velec); |
421 | velecsum = _mm_add_ps(velecsum,velec); |
422 | vvdw = _mm_and_ps(vvdw,cutoff_mask); |
423 | vvdw = _mm_andnot_ps(dummy_mask,vvdw); |
424 | vvdwsum = _mm_add_ps(vvdwsum,vvdw); |
425 | |
426 | fscal = _mm_add_ps(felec,fvdw); |
427 | |
428 | fscal = _mm_and_ps(fscal,cutoff_mask); |
429 | |
430 | fscal = _mm_andnot_ps(dummy_mask,fscal); |
431 | |
432 | /* Calculate temporary vectorial force */ |
433 | tx = _mm_mul_ps(fscal,dx00); |
434 | ty = _mm_mul_ps(fscal,dy00); |
435 | tz = _mm_mul_ps(fscal,dz00); |
436 | |
437 | /* Update vectorial force */ |
438 | fix0 = _mm_add_ps(fix0,tx); |
439 | fiy0 = _mm_add_ps(fiy0,ty); |
440 | fiz0 = _mm_add_ps(fiz0,tz); |
441 | |
442 | fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch; |
443 | fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch; |
444 | fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch; |
445 | fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch; |
446 | gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz); |
447 | |
448 | } |
449 | |
450 | /* Inner loop uses 83 flops */ |
451 | } |
452 | |
453 | /* End of innermost loop */ |
454 | |
455 | gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0, |
456 | f+i_coord_offset,fshift+i_shift_offset); |
457 | |
458 | ggid = gid[iidx]; |
459 | /* Update potential energies */ |
460 | gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid); |
461 | gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid); |
462 | |
463 | /* Increment number of inner iterations */ |
464 | inneriter += j_index_end - j_index_start; |
465 | |
466 | /* Outer loop uses 9 flops */ |
467 | } |
468 | |
469 | /* Increment number of outer iterations */ |
470 | outeriter += nri; |
471 | |
472 | /* Update outer/inner flops */ |
473 | |
474 | inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*83)(nrnb)->n[eNR_NBKERNEL_ELEC_VDW_VF] += outeriter*9 + inneriter *83; |
475 | } |
476 | /* |
477 | * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJEwSh_GeomP1P1_F_sse4_1_single |
478 | * Electrostatics interaction: Ewald |
479 | * VdW interaction: LJEwald |
480 | * Geometry: Particle-Particle |
481 | * Calculate force/pot: Force |
482 | */ |
483 | void |
484 | nb_kernel_ElecEwSh_VdwLJEwSh_GeomP1P1_F_sse4_1_single |
485 | (t_nblist * gmx_restrict nlist, |
486 | rvec * gmx_restrict xx, |
487 | rvec * gmx_restrict ff, |
488 | t_forcerec * gmx_restrict fr, |
489 | t_mdatoms * gmx_restrict mdatoms, |
490 | nb_kernel_data_t gmx_unused__attribute__ ((unused)) * gmx_restrict kernel_data, |
491 | t_nrnb * gmx_restrict nrnb) |
492 | { |
493 | /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or |
494 | * just 0 for non-waters. |
495 | * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different |
496 | * jnr indices corresponding to data put in the four positions in the SIMD register. |
497 | */ |
498 | int i_shift_offset,i_coord_offset,outeriter,inneriter; |
499 | int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx; |
500 | int jnrA,jnrB,jnrC,jnrD; |
501 | int jnrlistA,jnrlistB,jnrlistC,jnrlistD; |
502 | int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD; |
503 | int *iinr,*jindex,*jjnr,*shiftidx,*gid; |
504 | real rcutoff_scalar; |
505 | real *shiftvec,*fshift,*x,*f; |
506 | real *fjptrA,*fjptrB,*fjptrC,*fjptrD; |
507 | real scratch[4*DIM3]; |
508 | __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall; |
509 | int vdwioffset0; |
510 | __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0; |
511 | int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D; |
512 | __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0; |
513 | __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00; |
514 | __m128 velec,felec,velecsum,facel,crf,krf,krf2; |
515 | real *charge; |
516 | int nvdwtype; |
517 | __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6; |
518 | int *vdwtype; |
519 | real *vdwparam; |
520 | __m128 one_sixth = _mm_set1_ps(1.0/6.0); |
521 | __m128 one_twelfth = _mm_set1_ps(1.0/12.0); |
522 | __m128 c6grid_00; |
523 | __m128 ewclj,ewclj2,ewclj6,ewcljrsq,poly,exponent,f6A,f6B,sh_lj_ewald; |
524 | real *vdwgridparam; |
525 | __m128 one_half = _mm_set1_ps(0.5); |
526 | __m128 minus_one = _mm_set1_ps(-1.0); |
527 | __m128i ewitab; |
528 | __m128 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV; |
529 | real *ewtab; |
530 | __m128 dummy_mask,cutoff_mask; |
531 | __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) ); |
532 | __m128 one = _mm_set1_ps(1.0); |
533 | __m128 two = _mm_set1_ps(2.0); |
534 | x = xx[0]; |
535 | f = ff[0]; |
536 | |
537 | nri = nlist->nri; |
538 | iinr = nlist->iinr; |
539 | jindex = nlist->jindex; |
540 | jjnr = nlist->jjnr; |
541 | shiftidx = nlist->shift; |
542 | gid = nlist->gid; |
543 | shiftvec = fr->shift_vec[0]; |
544 | fshift = fr->fshift[0]; |
545 | facel = _mm_set1_ps(fr->epsfac); |
546 | charge = mdatoms->chargeA; |
547 | nvdwtype = fr->ntype; |
548 | vdwparam = fr->nbfp; |
549 | vdwtype = mdatoms->typeA; |
550 | vdwgridparam = fr->ljpme_c6grid; |
551 | sh_lj_ewald = _mm_set1_ps(fr->ic->sh_lj_ewald); |
552 | ewclj = _mm_set1_ps(fr->ewaldcoeff_lj); |
553 | ewclj2 = _mm_mul_ps(minus_one,_mm_mul_ps(ewclj,ewclj)); |
554 | |
555 | sh_ewald = _mm_set1_ps(fr->ic->sh_ewald); |
556 | ewtab = fr->ic->tabq_coul_F; |
557 | ewtabscale = _mm_set1_ps(fr->ic->tabq_scale); |
558 | ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale); |
Value stored to 'ewtabhalfspace' is never read | |
559 | |
560 | /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */ |
561 | rcutoff_scalar = fr->rcoulomb; |
562 | rcutoff = _mm_set1_ps(rcutoff_scalar); |
563 | rcutoff2 = _mm_mul_ps(rcutoff,rcutoff); |
564 | |
565 | sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6); |
566 | rvdw = _mm_set1_ps(fr->rvdw); |
567 | |
568 | /* Avoid stupid compiler warnings */ |
569 | jnrA = jnrB = jnrC = jnrD = 0; |
570 | j_coord_offsetA = 0; |
571 | j_coord_offsetB = 0; |
572 | j_coord_offsetC = 0; |
573 | j_coord_offsetD = 0; |
574 | |
575 | outeriter = 0; |
576 | inneriter = 0; |
577 | |
578 | for(iidx=0;iidx<4*DIM3;iidx++) |
579 | { |
580 | scratch[iidx] = 0.0; |
581 | } |
582 | |
583 | /* Start outer loop over neighborlists */ |
584 | for(iidx=0; iidx<nri; iidx++) |
585 | { |
586 | /* Load shift vector for this list */ |
587 | i_shift_offset = DIM3*shiftidx[iidx]; |
588 | |
589 | /* Load limits for loop over neighbors */ |
590 | j_index_start = jindex[iidx]; |
591 | j_index_end = jindex[iidx+1]; |
592 | |
593 | /* Get outer coordinate index */ |
594 | inr = iinr[iidx]; |
595 | i_coord_offset = DIM3*inr; |
596 | |
597 | /* Load i particle coords and add shift vector */ |
598 | gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0); |
599 | |
600 | fix0 = _mm_setzero_ps(); |
601 | fiy0 = _mm_setzero_ps(); |
602 | fiz0 = _mm_setzero_ps(); |
603 | |
604 | /* Load parameters for i particles */ |
605 | iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0)); |
606 | vdwioffset0 = 2*nvdwtype*vdwtype[inr+0]; |
607 | |
608 | /* Start inner kernel loop */ |
609 | for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4) |
610 | { |
611 | |
612 | /* Get j neighbor index, and coordinate index */ |
613 | jnrA = jjnr[jidx]; |
614 | jnrB = jjnr[jidx+1]; |
615 | jnrC = jjnr[jidx+2]; |
616 | jnrD = jjnr[jidx+3]; |
617 | j_coord_offsetA = DIM3*jnrA; |
618 | j_coord_offsetB = DIM3*jnrB; |
619 | j_coord_offsetC = DIM3*jnrC; |
620 | j_coord_offsetD = DIM3*jnrD; |
621 | |
622 | /* load j atom coordinates */ |
623 | gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB, |
624 | x+j_coord_offsetC,x+j_coord_offsetD, |
625 | &jx0,&jy0,&jz0); |
626 | |
627 | /* Calculate displacement vector */ |
628 | dx00 = _mm_sub_ps(ix0,jx0); |
629 | dy00 = _mm_sub_ps(iy0,jy0); |
630 | dz00 = _mm_sub_ps(iz0,jz0); |
631 | |
632 | /* Calculate squared distance and things based on it */ |
633 | rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00); |
634 | |
635 | rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00); |
636 | |
637 | rinvsq00 = _mm_mul_ps(rinv00,rinv00); |
638 | |
639 | /* Load parameters for j particles */ |
640 | jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0, |
641 | charge+jnrC+0,charge+jnrD+0); |
642 | vdwjidx0A = 2*vdwtype[jnrA+0]; |
643 | vdwjidx0B = 2*vdwtype[jnrB+0]; |
644 | vdwjidx0C = 2*vdwtype[jnrC+0]; |
645 | vdwjidx0D = 2*vdwtype[jnrD+0]; |
646 | |
647 | /************************** |
648 | * CALCULATE INTERACTIONS * |
649 | **************************/ |
650 | |
651 | if (gmx_mm_any_lt(rsq00,rcutoff2)) |
652 | { |
653 | |
654 | r00 = _mm_mul_ps(rsq00,rinv00); |
655 | |
656 | /* Compute parameters for interactions between i and j atoms */ |
657 | qq00 = _mm_mul_ps(iq0,jq0); |
658 | gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A, |
659 | vdwparam+vdwioffset0+vdwjidx0B, |
660 | vdwparam+vdwioffset0+vdwjidx0C, |
661 | vdwparam+vdwioffset0+vdwjidx0D, |
662 | &c6_00,&c12_00); |
663 | |
664 | c6grid_00 = gmx_mm_load_4real_swizzle_ps(vdwgridparam+vdwioffset0+vdwjidx0A, |
665 | vdwgridparam+vdwioffset0+vdwjidx0B, |
666 | vdwgridparam+vdwioffset0+vdwjidx0C, |
667 | vdwgridparam+vdwioffset0+vdwjidx0D); |
668 | |
669 | /* EWALD ELECTROSTATICS */ |
670 | |
671 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
672 | ewrt = _mm_mul_ps(r00,ewtabscale); |
673 | ewitab = _mm_cvttps_epi32(ewrt); |
674 | eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps ((__v4sf)__X, ((0x00 | 0x01))); })); |
675 | gmx_mm_load_4pair_swizzle_ps(ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) & 3];})),ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) & 3];})), |
676 | ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) & 3];})),ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) & 3];})), |
677 | &ewtabF,&ewtabFn); |
678 | felec = _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one,eweps),ewtabF),_mm_mul_ps(eweps,ewtabFn)); |
679 | felec = _mm_mul_ps(_mm_mul_ps(qq00,rinv00),_mm_sub_ps(rinvsq00,felec)); |
680 | |
681 | /* Analytical LJ-PME */ |
682 | rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00); |
683 | ewcljrsq = _mm_mul_ps(ewclj2,rsq00); |
684 | ewclj6 = _mm_mul_ps(ewclj2,_mm_mul_ps(ewclj2,ewclj2)); |
685 | exponent = gmx_simd_exp_rgmx_simd_exp_f(ewcljrsq); |
686 | /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */ |
687 | poly = _mm_mul_ps(exponent,_mm_add_ps(_mm_sub_ps(one,ewcljrsq),_mm_mul_ps(_mm_mul_ps(ewcljrsq,ewcljrsq),one_half))); |
688 | /* f6A = 6 * C6grid * (1 - poly) */ |
689 | f6A = _mm_mul_ps(c6grid_00,_mm_sub_ps(one,poly)); |
690 | /* f6B = C6grid * exponent * beta^6 */ |
691 | f6B = _mm_mul_ps(_mm_mul_ps(c6grid_00,one_sixth),_mm_mul_ps(exponent,ewclj6)); |
692 | /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */ |
693 | fvdw = _mm_mul_ps(_mm_add_ps(_mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00,rinvsix),_mm_sub_ps(c6_00,f6A)),rinvsix),f6B),rinvsq00); |
694 | |
695 | cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2); |
696 | |
697 | fscal = _mm_add_ps(felec,fvdw); |
698 | |
699 | fscal = _mm_and_ps(fscal,cutoff_mask); |
700 | |
701 | /* Calculate temporary vectorial force */ |
702 | tx = _mm_mul_ps(fscal,dx00); |
703 | ty = _mm_mul_ps(fscal,dy00); |
704 | tz = _mm_mul_ps(fscal,dz00); |
705 | |
706 | /* Update vectorial force */ |
707 | fix0 = _mm_add_ps(fix0,tx); |
708 | fiy0 = _mm_add_ps(fiy0,ty); |
709 | fiz0 = _mm_add_ps(fiz0,tz); |
710 | |
711 | fjptrA = f+j_coord_offsetA; |
712 | fjptrB = f+j_coord_offsetB; |
713 | fjptrC = f+j_coord_offsetC; |
714 | fjptrD = f+j_coord_offsetD; |
715 | gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz); |
716 | |
717 | } |
718 | |
719 | /* Inner loop uses 62 flops */ |
720 | } |
721 | |
722 | if(jidx<j_index_end) |
723 | { |
724 | |
725 | /* Get j neighbor index, and coordinate index */ |
726 | jnrlistA = jjnr[jidx]; |
727 | jnrlistB = jjnr[jidx+1]; |
728 | jnrlistC = jjnr[jidx+2]; |
729 | jnrlistD = jjnr[jidx+3]; |
730 | /* Sign of each element will be negative for non-real atoms. |
731 | * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones, |
732 | * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries. |
733 | */ |
734 | dummy_mask = gmx_mm_castsi128_ps_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128())); |
735 | jnrA = (jnrlistA>=0) ? jnrlistA : 0; |
736 | jnrB = (jnrlistB>=0) ? jnrlistB : 0; |
737 | jnrC = (jnrlistC>=0) ? jnrlistC : 0; |
738 | jnrD = (jnrlistD>=0) ? jnrlistD : 0; |
739 | j_coord_offsetA = DIM3*jnrA; |
740 | j_coord_offsetB = DIM3*jnrB; |
741 | j_coord_offsetC = DIM3*jnrC; |
742 | j_coord_offsetD = DIM3*jnrD; |
743 | |
744 | /* load j atom coordinates */ |
745 | gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB, |
746 | x+j_coord_offsetC,x+j_coord_offsetD, |
747 | &jx0,&jy0,&jz0); |
748 | |
749 | /* Calculate displacement vector */ |
750 | dx00 = _mm_sub_ps(ix0,jx0); |
751 | dy00 = _mm_sub_ps(iy0,jy0); |
752 | dz00 = _mm_sub_ps(iz0,jz0); |
753 | |
754 | /* Calculate squared distance and things based on it */ |
755 | rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00); |
756 | |
757 | rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00); |
758 | |
759 | rinvsq00 = _mm_mul_ps(rinv00,rinv00); |
760 | |
761 | /* Load parameters for j particles */ |
762 | jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0, |
763 | charge+jnrC+0,charge+jnrD+0); |
764 | vdwjidx0A = 2*vdwtype[jnrA+0]; |
765 | vdwjidx0B = 2*vdwtype[jnrB+0]; |
766 | vdwjidx0C = 2*vdwtype[jnrC+0]; |
767 | vdwjidx0D = 2*vdwtype[jnrD+0]; |
768 | |
769 | /************************** |
770 | * CALCULATE INTERACTIONS * |
771 | **************************/ |
772 | |
773 | if (gmx_mm_any_lt(rsq00,rcutoff2)) |
774 | { |
775 | |
776 | r00 = _mm_mul_ps(rsq00,rinv00); |
777 | r00 = _mm_andnot_ps(dummy_mask,r00); |
778 | |
779 | /* Compute parameters for interactions between i and j atoms */ |
780 | qq00 = _mm_mul_ps(iq0,jq0); |
781 | gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A, |
782 | vdwparam+vdwioffset0+vdwjidx0B, |
783 | vdwparam+vdwioffset0+vdwjidx0C, |
784 | vdwparam+vdwioffset0+vdwjidx0D, |
785 | &c6_00,&c12_00); |
786 | |
787 | c6grid_00 = gmx_mm_load_4real_swizzle_ps(vdwgridparam+vdwioffset0+vdwjidx0A, |
788 | vdwgridparam+vdwioffset0+vdwjidx0B, |
789 | vdwgridparam+vdwioffset0+vdwjidx0C, |
790 | vdwgridparam+vdwioffset0+vdwjidx0D); |
791 | |
792 | /* EWALD ELECTROSTATICS */ |
793 | |
794 | /* Calculate Ewald table index by multiplying r with scale and truncate to integer */ |
795 | ewrt = _mm_mul_ps(r00,ewtabscale); |
796 | ewitab = _mm_cvttps_epi32(ewrt); |
797 | eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps ((__v4sf)__X, ((0x00 | 0x01))); })); |
798 | gmx_mm_load_4pair_swizzle_ps(ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) & 3];})),ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) & 3];})), |
799 | ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) & 3];})),ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) & 3];})), |
800 | &ewtabF,&ewtabFn); |
801 | felec = _mm_add_ps(_mm_mul_ps( _mm_sub_ps(one,eweps),ewtabF),_mm_mul_ps(eweps,ewtabFn)); |
802 | felec = _mm_mul_ps(_mm_mul_ps(qq00,rinv00),_mm_sub_ps(rinvsq00,felec)); |
803 | |
804 | /* Analytical LJ-PME */ |
805 | rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00); |
806 | ewcljrsq = _mm_mul_ps(ewclj2,rsq00); |
807 | ewclj6 = _mm_mul_ps(ewclj2,_mm_mul_ps(ewclj2,ewclj2)); |
808 | exponent = gmx_simd_exp_rgmx_simd_exp_f(ewcljrsq); |
809 | /* poly = exp(-(beta*r)^2) * (1 + (beta*r)^2 + (beta*r)^4 /2) */ |
810 | poly = _mm_mul_ps(exponent,_mm_add_ps(_mm_sub_ps(one,ewcljrsq),_mm_mul_ps(_mm_mul_ps(ewcljrsq,ewcljrsq),one_half))); |
811 | /* f6A = 6 * C6grid * (1 - poly) */ |
812 | f6A = _mm_mul_ps(c6grid_00,_mm_sub_ps(one,poly)); |
813 | /* f6B = C6grid * exponent * beta^6 */ |
814 | f6B = _mm_mul_ps(_mm_mul_ps(c6grid_00,one_sixth),_mm_mul_ps(exponent,ewclj6)); |
815 | /* fvdw = 12*C12/r13 - ((6*C6 - f6A)/r6 + f6B)/r */ |
816 | fvdw = _mm_mul_ps(_mm_add_ps(_mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00,rinvsix),_mm_sub_ps(c6_00,f6A)),rinvsix),f6B),rinvsq00); |
817 | |
818 | cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2); |
819 | |
820 | fscal = _mm_add_ps(felec,fvdw); |
821 | |
822 | fscal = _mm_and_ps(fscal,cutoff_mask); |
823 | |
824 | fscal = _mm_andnot_ps(dummy_mask,fscal); |
825 | |
826 | /* Calculate temporary vectorial force */ |
827 | tx = _mm_mul_ps(fscal,dx00); |
828 | ty = _mm_mul_ps(fscal,dy00); |
829 | tz = _mm_mul_ps(fscal,dz00); |
830 | |
831 | /* Update vectorial force */ |
832 | fix0 = _mm_add_ps(fix0,tx); |
833 | fiy0 = _mm_add_ps(fiy0,ty); |
834 | fiz0 = _mm_add_ps(fiz0,tz); |
835 | |
836 | fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch; |
837 | fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch; |
838 | fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch; |
839 | fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch; |
840 | gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz); |
841 | |
842 | } |
843 | |
844 | /* Inner loop uses 63 flops */ |
845 | } |
846 | |
847 | /* End of innermost loop */ |
848 | |
849 | gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0, |
850 | f+i_coord_offset,fshift+i_shift_offset); |
851 | |
852 | /* Increment number of inner iterations */ |
853 | inneriter += j_index_end - j_index_start; |
854 | |
855 | /* Outer loop uses 7 flops */ |
856 | } |
857 | |
858 | /* Increment number of outer iterations */ |
859 | outeriter += nri; |
860 | |
861 | /* Update outer/inner flops */ |
862 | |
863 | inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*63)(nrnb)->n[eNR_NBKERNEL_ELEC_VDW_F] += outeriter*7 + inneriter *63; |
864 | } |