From 33711580378dba0a1050f90b9563328dc4588982 Mon Sep 17 00:00:00 2001 From: Andrey Alekseenko Date: Thu, 29 Oct 2020 13:25:44 +0000 Subject: [PATCH] Narrow-down Intel-specific #ifdef's Some of the things hidden by `#ifdef __INTEL_COMPILER` does not seem to be relevant as of 2021.1-beta09/10 (ICC 2021.1 Beta 20200827). Also, was getting a false-positive "warning: result of comparison of 0-bit unsigned value != 0 is always false" for line `if (grid_base[g_baseNR - 1] % 4 != 0)`. Replaced it with `static_assert`, because why not. --- src/gromacs/fft/calcgrid.cpp | 14 ++++++-------- src/gromacs/listed_forces/tests/bonded.cpp | 4 ++-- src/gromacs/pulling/pullutil.cpp | 5 +++-- src/gromacs/simd/tests/simd_floatingpoint_util.cpp | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/gromacs/fft/calcgrid.cpp b/src/gromacs/fft/calcgrid.cpp index 8d293464b7..de0bbb1b9a 100644 --- a/src/gromacs/fft/calcgrid.cpp +++ b/src/gromacs/fft/calcgrid.cpp @@ -51,14 +51,14 @@ */ /* Small grid size array */ -#define g_initNR 15 -const int grid_init[g_initNR] = { 6, 8, 10, 12, 14, 16, 20, 24, 25, 28, 32, 36, 40, 42, 44 }; +constexpr int g_initNR = 15; +constexpr int grid_init[g_initNR] = { 6, 8, 10, 12, 14, 16, 20, 24, 25, 28, 32, 36, 40, 42, 44 }; /* For larger grid sizes, a prefactor with any power of 2 can be added. * Only sizes divisible by 4 should be used, 90 is allowed, 140 not. */ -#define g_baseNR 14 -const int grid_base[g_baseNR] = { 45, 48, 50, 52, 54, 56, 60, 64, 70, 72, 75, 80, 81, 84 }; +constexpr int g_baseNR = 14; +constexpr int grid_base[g_baseNR] = { 45, 48, 50, 52, 54, 56, 60, 64, 70, 72, 75, 80, 81, 84 }; real calcFftGrid(FILE* fp, const matrix box, real gridSpacing, int minGridPointsPerDim, int* nx, int* ny, int* nz) { @@ -74,10 +74,8 @@ real calcFftGrid(FILE* fp, const matrix box, real gridSpacing, int minGridPoints gmx_fatal(FARGS, "invalid fourier grid spacing: %g", gridSpacing); } - if (grid_base[g_baseNR - 1] % 4 != 0) - { - gmx_incons("the last entry in grid_base is not a multiple of 4"); - } + static_assert(grid_base[g_baseNR - 1] % 4 == 0, + "the last entry in grid_base is not a multiple of 4"); /* New grid calculation setup: * diff --git a/src/gromacs/listed_forces/tests/bonded.cpp b/src/gromacs/listed_forces/tests/bonded.cpp index 41c74f9294..9cd1273cb9 100644 --- a/src/gromacs/listed_forces/tests/bonded.cpp +++ b/src/gromacs/listed_forces/tests/bonded.cpp @@ -770,8 +770,8 @@ std::vector> c_coordinatesForTestsZeroAngle = { //! PBC values for testing std::vector c_pbcForTests = { PbcType::No, PbcType::XY, PbcType::Xyz }; -// Those tests give errors with the intel compiler and nothing else, so we disable them only there. -#ifndef __INTEL_COMPILER +// Those tests give errors with the Intel compiler (as of October 2019) and nothing else, so we disable them only there. +#if !defined(__INTEL_COMPILER) || (__INTEL_COMPILER >= 2021) INSTANTIATE_TEST_CASE_P(Bond, ListedForcesTest, ::testing::Combine(::testing::ValuesIn(c_InputBonds), diff --git a/src/gromacs/pulling/pullutil.cpp b/src/gromacs/pulling/pullutil.cpp index a1c646c826..875b535560 100644 --- a/src/gromacs/pulling/pullutil.cpp +++ b/src/gromacs/pulling/pullutil.cpp @@ -519,8 +519,9 @@ static void sum_com_part_cosweight(const pull_group_work_t* pgrp, /* calculates center of mass of selection index from all coordinates x */ // Compiler segfault with 2019_update_5 and 2020_initial -#if defined(__INTEL_COMPILER) \ - && ((__INTEL_COMPILER == 1900 && __INTEL_COMPILER_UPDATE >= 5) || __INTEL_COMPILER >= 1910) +#if defined(__INTEL_COMPILER) \ + && ((__INTEL_COMPILER == 1900 && __INTEL_COMPILER_UPDATE >= 5) \ + || (__INTEL_COMPILER >= 1910 && __INTEL_COMPILER < 2021)) # pragma intel optimization_level 2 #endif void pull_calc_coms(const t_commrec* cr, pull_t* pull, const real* masses, t_pbc* pbc, double t, const rvec x[], rvec* xp) diff --git a/src/gromacs/simd/tests/simd_floatingpoint_util.cpp b/src/gromacs/simd/tests/simd_floatingpoint_util.cpp index ee43c3cada..502f5f0961 100644 --- a/src/gromacs/simd/tests/simd_floatingpoint_util.cpp +++ b/src/gromacs/simd/tests/simd_floatingpoint_util.cpp @@ -466,7 +466,7 @@ TEST_F(SimdFloatingpointUtilTest, transposeScatterDecrU3Overlapping) mem0_[j] = refmem[j] = (1000.0 + j) * (1.0 + 100 * GMX_REAL_EPS); } -# ifdef __INTEL_COMPILER // Bug in (at least) 19u1 and 18u5 (03424712) +# if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 2021) // Bug in (at least) 19u1 and 18u5 (03424712) # pragma novector # endif for (std::size_t j = 0; j < GMX_SIMD_REAL_WIDTH; j++) -- 2.22.0