Fix few issues with open-source Intel LLVM (Clang 13)
authorAndrey Alekseenko <al42and@gmail.com>
Wed, 11 Aug 2021 16:22:05 +0000 (19:22 +0300)
committerAndrey Alekseenko <al42and@gmail.com>
Wed, 11 Aug 2021 16:22:05 +0000 (19:22 +0300)
- Add -Wno-reserved-identifier to avoid false-positive with _real
  user-defined literal (https://bugs.llvm.org/show_bug.cgi?id=50644).
- Change the alignment-checking code to avoid "warning: performing
  pointer subtraction with a null pointer may have undefined behavior".
- Update some comments about SYCL version quirks.

There are some deprecation warnings related to SYCL naming being brought
into agreement with the final SYCL2020 standard, but those will be fixed
once they appear in any official release.

cmake/gmxCFlags.cmake
src/gromacs/fileio/md5.cpp
src/gromacs/gpu_utils/gmxsycl.h

index c4e3fd0b913611c84da51df92423868bb376f19b..bbbcacc39904cdf2feae9121c7c9b6498896a4f7 100644 (file)
@@ -364,12 +364,13 @@ macro (gmx_c_flags)
         if(NOT GMX_OPENMP)
             GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CXXFLAGS)
         endif()
+        GMX_TEST_CXXFLAG(CXXFLAGS_WARN_NO_RESERVED_IDENTIFIER "-Wno-reserved-identifier" GMXC_CXXFLAGS) # LLVM BUG #50644
         GMX_TEST_CXXFLAG(CXXFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS "-Wno-missing-field-initializers" GMXC_CXXFLAGS)
         # Intel LLVM 2021.2 defaults to no-finite-math which isn't OK for GROMACS
         if(GMX_INTEL_LLVM AND GMX_INTEL_LLVM_VERSION GREATER_EQUAL 2021020)
             GMX_TEST_CXXFLAG(CXXFLAGS_FINITE_MATH "-fno-finite-math-only" GMXC_CXXFLAGS)
         endif()
-        # Some versions of Intel ICPX compiler (at least 2021.1.1 to 2021.2.0) fail to unroll a loop
+        # Some versions of Intel ICPX compiler (at least 2021.1.1 to 2021.3.0) fail to unroll a loop
         # in sycl::accessor::__init, and emit -Wpass-failed=transform-warning. This is a useful
         # warning, but mostly noise right now. Probably related to using shared memory accessors.
         # Note: not a typo: ICPX 2021.1.1 has GMX_INTEL_LLVM_VERSION 202110; 2021.2.0 has 20210200.
index eb99ff7f38e8f4a1900c43299903ecf141c85604..a65c5132ba1d6533f6f07ab35ce1f426676494b6 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2009,2010,2011,2012,2014 by the GROMACS development team.
- * Copyright (c) 2015,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2018,2019,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -41,7 +41,9 @@
 
 #include "config.h"
 
+#include <cstdint>
 #include <cstring>
+#include <type_traits>
 
 #if GMX_INTEGER_BIG_ENDIAN
 #    define ARCH_IS_BIG_ENDIAN 1
@@ -207,7 +209,7 @@ static void md5_process(md5_state_t* pms, const md5_byte_t* data /*[64]*/)
              * On little-endian machines, we can process properly aligned
              * data without copying it.
              */
-            if (!((data - reinterpret_cast<const md5_byte_t*>(0)) & 3))
+            if ((reinterpret_cast<std::uintptr_t>(data) % std::alignment_of_v<md5_word_t>) == 0)
             {
                 /* data are properly aligned */
                 X = reinterpret_cast<const md5_word_t*>(data);
index 897b5493d2ba1f1bcfdb86c7edac779ee4478042..353ca45116aaf4fec6e68980b7e9d765853f0593 100644 (file)
@@ -94,8 +94,8 @@
 #endif
 
 /* Exposing Intel-specific extensions in a manner compatible with SYCL2020 provisional spec.
- * Despite ICPX (up to 2021.1.2 at the least) having SYCL_LANGUAGE_VERSION=202001,
- * some parts of the spec are still in custom sycl::ONEAPI namespace (sycl::intel in beta versions),
+ * Despite ICPX (up to 2021.3.0 at the least) having SYCL_LANGUAGE_VERSION=202001,
+ * some parts of the spec are still in custom sycl::ONEAPI namespace (sycl::ext::oneapi in beta versions),
  * and some functions have different names. To make things easier to upgrade
  * in the future, this thin layer is added.
  * */
@@ -104,7 +104,8 @@ namespace sycl_2020
 namespace detail
 {
 #if GMX_SYCL_DPCPP
-// Confirmed to work for 2021.1-beta10 (20201005), 2021.1.1 (20201113), 2021.1.2 (20201214).
+// Confirmed to work for 2021.1-beta10 (20201005) to 2021.3.0 (20210619).
+// Deprecated in favor of sycl::ext::oneapi on 20210717 in https://github.com/intel/llvm/commit/d703f578.
 namespace origin = cl::sycl::ONEAPI;
 #elif GMX_SYCL_HIPSYCL
 namespace origin = cl::sycl;