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