diff --git a/src/compartment.hpp b/src/compartment.hpp index db548fa39b7f4958b6575449a3734004d10ae687..10c26fd1652a655e91bc4f8836be5e24690135e7 100644 --- a/src/compartment.hpp +++ b/src/compartment.hpp @@ -5,11 +5,12 @@ #include <common_types.hpp> #include <math.hpp> +#include <util/compat.hpp> #include <util/counter.hpp> #include <util/iterutil.hpp> #include <util/partition.hpp> #include <util/span.hpp> -#include "util/rangeutil.hpp" +#include <util/rangeutil.hpp> #include <util/transform.hpp> namespace nest { @@ -184,6 +185,8 @@ public: using namespace util; segs_ = make_partition(offsets_, lengths); + compat::sink_if_icc_leq(20160415u, segs_.bounds()); + nseg_ = size(segs_); scale_ = segs_.bounds().second/n; assign(radii_, radii); diff --git a/src/util/compat.hpp b/src/util/compat.hpp index c288effefd8c50593ed82750714691b2dc409ba4..a10e8cc1f6d1e8b79b06cdc3ff8f6ce40de2d8ed 100644 --- a/src/util/compat.hpp +++ b/src/util/compat.hpp @@ -34,4 +34,27 @@ inline void compiler_barrier_if_xlc_leq(unsigned ver) { template <typename X> inline constexpr bool isinf(X x) { return std::isinf(x); } +// Work around a bad inlining-related optimization with icpc 16.0.3 and -xMIC-AVX512, +// by forcing a computation. + +template <typename X> +inline void sink(const X& x) { + char buf[sizeof x]; + volatile char* bufptr = buf; + const char* xptr = reinterpret_cast<const char*>(&x); + + for (std::size_t i = 0; i<sizeof buf; ++i) { + *bufptr++ = *xptr++; + } +} + +template <typename X> +inline void sink_if_icc_leq(unsigned ver, const X& x) { +#if defined(__INTEL_COMPILER_BUILD_DATE) + if (__INTEL_COMPILER_BUILD_DATE<=ver) { + sink(x); + } +#endif } + +} // namespace compat