Verified Commit 4115ed94 authored by Rodrigo Tobar 's avatar Rodrigo Tobar
Browse files

Use simd OpenMP pragma only when available



The simd OpenMP pragma was introduced in OpenMP 4.0, but the code
neither checked for the OpenMP version at configure time, nor it checks
for it at build time. This causes compilers with older OpenMP versions
to produce warnings when building the code, which in turn causes
compilation errors when configuring the project by default.

This commit adds a check on the _OPENMP macro value in all places where
the simd OpenMP pragma is used. Alternatively one could do this check at
configure time and disallow compilation altogether if the requirement is
not met.
Signed-off-by: Rodrigo Tobar 's avatarRodrigo Tobar <rtobar@icrar.org>
parent 149abf34
......@@ -225,7 +225,7 @@ INLINE static void gravity_cache_populate(
swift_assume_size(gcount_padded, VEC_SIZE);
/* Fill the input caches */
#ifndef SWIFT_DEBUG_CHECKS
#if !defined(SWIFT_DEBUG_CHECKS) && _OPENMP >= 201307
#pragma omp simd
#endif
for (int i = 0; i < gcount; ++i) {
......@@ -485,7 +485,7 @@ INLINE static void gravity_cache_write_back(const struct gravity_cache *c,
swift_declare_aligned_ptr(int, active, c->active, SWIFT_CACHE_ALIGNMENT);
/* Write stuff back to the particles */
#ifndef SWIFT_DEBUG_CHECKS
#if !defined(SWIFT_DEBUG_CHECKS) && _OPENMP >= 201307
#pragma omp simd
#endif
for (int i = 0; i < gcount; ++i) {
......
......@@ -882,7 +882,7 @@ static INLINE void runner_dopair_grav_pm_full(
const float multi_epsilon = multi_j->max_softening;
/* Loop over all particles in ci... */
#ifndef SWIFT_DEBUG_CHECKS
#if !defined(SWIFT_DEBUG_CHECKS) && _OPENMP >= 201307
#pragma omp simd
#endif
for (int pid = 0; pid < gcount_padded_i; pid++) {
......@@ -1025,7 +1025,7 @@ static INLINE void runner_dopair_grav_pm_truncated(
const float multi_epsilon = multi_j->max_softening;
/* Loop over all particles in ci... */
#ifndef SWIFT_DEBUG_CHECKS
#if !defined(SWIFT_DEBUG_CHECKS) && _OPENMP >= 201307
#pragma omp simd
#endif
for (int pid = 0; pid < gcount_padded_i; pid++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment