Commit 064731d
committed
PathMSDBase: drop four omp simd pragmas that cannot vectorize
Building with clang and OpenMP emits, four times:
PathMSDBase.cpp:160:19: warning: loop not vectorized: the optimizer was
unable to perform the requested transformation ... [-Wpass-failed=transform-warning]
All four remarks are attributed to calculate()'s opening line, which hides which
loops are at fault. Isolating them by keeping one pragma at a time shows exactly
four contributors, and two pragmas that are fine:
line 176 imgVec[i].property = ... ; imgVec[i].index = i; 1 warning
line 234 tmp_derivs2[i*nat+j] = tmp_derivs[j]; 1 warning
line 244 (the same loop again) 1 warning
line 266 (the same loop again) 1 warning
line 335 derivs_s[i] += tmp*it.distder[i]; 0 - vectorizes
line 340 derivs_z[i] += ...; 0 - vectorizes
Neither failing case can be vectorized, and asking for it is misleading:
- Line 176 is not merely hard to vectorize, it is meaningless. ImagePath::property
is a std::vector<double>, so `imgVec[i].property = indexvec[i]` is a vector
copy-assignment that ALLOCATES. There is no SIMD work in that loop.
- The other three are the same contiguous copy of Vector elements written out by
hand. std::copy_n says what is meant, and lets the compiler emit a memmove
instead of an element loop the vectorizer then declines to transform.
Fixing the source rather than silencing the diagnostic means the warning is gone
for every compiler, and a build using -Werror no longer fails here. Behaviour is
unchanged: std::copy_n over [0,nat) is exactly the loop it replaces, and the
remaining two pragmas, which do vectorize, are untouched.
Verified with clang 20.1.1:
clang++ -std=c++17 -O3 -fopenmp -march=skylake-avx512 -Wall \
-c colvar/PathMSDBase.cpp -I.
4 warnings before, 0 after. GCC is unaffected either way (its 17 warnings here
are pre-existing -Wunknown-pragmas from `#pragma acc` in headers, which PLUMED's
own build silences).1 parent bc65c35 commit 064731d
1 file changed
Lines changed: 7 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
176 | | - | |
| 178 | + | |
| 179 | + | |
177 | 180 | | |
178 | 181 | | |
179 | 182 | | |
| |||
231 | 234 | | |
232 | 235 | | |
233 | 236 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
| 237 | + | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
| 244 | + | |
248 | 245 | | |
249 | 246 | | |
250 | 247 | | |
| |||
263 | 260 | | |
264 | 261 | | |
265 | 262 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
| 263 | + | |
270 | 264 | | |
271 | 265 | | |
272 | 266 | | |
| |||
0 commit comments