Fix compile with Intel oneAPI 2021.2
authorRoland Schulz <roland.schulz@intel.com>
Sun, 11 Apr 2021 01:15:33 +0000 (01:15 +0000)
committerAndrey Alekseenko <al42and@gmail.com>
Sun, 11 Apr 2021 01:15:33 +0000 (01:15 +0000)
CMakeLists.txt
cmake/TestIntelLLVM.cpp [new file with mode: 0644]
cmake/gmxCFlags.cmake
cmake/gmxManageFFTLibraries.cmake
cmake/gmxTestIntelLLVM.cmake [moved from cmake/gmxTestICCNextGen.cmake with 70% similarity]
docs/release-notes/2021/2021.2.rst

index e4b6ffd4fb812240d2cdb231c165366184f34d2d..32a6621dfd30c2cb92a320d64c8cbf3d36569405 100644 (file)
@@ -298,6 +298,7 @@ include(gmxManageOpenMP)
 # These need to be done early (before further tests).
 #####################################################################
 
+include(gmxTestIntelLLVM)
 include(gmxCFlags)
 gmx_c_flags()
 
diff --git a/cmake/TestIntelLLVM.cpp b/cmake/TestIntelLLVM.cpp
new file mode 100644 (file)
index 0000000..637bf46
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef __INTEL_LLVM_COMPILER
+#error
+#endif
+#define VALUE_TO_STRING(x) #x
+#define VALUE(x) VALUE_TO_STRING(x)
+#pragma message(VALUE(__INTEL_LLVM_COMPILER))
+int main() {}
index 287c56bbddf6eba764a69d9c9166b74c918438f1..97d095eec6833e1df6386cc61015cee6c3a9dafb 100644 (file)
@@ -3,7 +3,7 @@
 #
 # Copyright (c) 2009,2010,2011,2012,2013 by the GROMACS development team.
 # Copyright (c) 2014,2015,2016,2017,2018 by the GROMACS development team.
-# Copyright (c) 2019,2020, by the GROMACS development team, led by
+# Copyright (c) 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.
@@ -444,6 +444,10 @@ GMX_TEST_CFLAG(CFLAGS_WARN "/W3;/wd161;/wd177;/wd411;/wd593;/wd981;/wd1418;/wd14
             GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CXXFLAGS)
         endif()
         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()
     endif()
 
     # Apple bastardized version of Clang
index f59e011ecc86f7f72d27d668424ce369b5c0e6ec..bc310470b1523572c0f09057800813d4d0167d5e 100644 (file)
@@ -2,7 +2,7 @@
 # This file is part of the GROMACS molecular simulation package.
 #
 # Copyright (c) 2012,2013,2014,2015,2016 by the GROMACS development team.
-# Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+# Copyright (c) 2017,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.
@@ -33,8 +33,6 @@
 # To help us fund GROMACS development, we humbly ask that you cite
 # the research papers on the package. Check out http://www.gromacs.org.
 
-include(gmxTestICCNextGen)
-
 # Manage setup of the different FFT libraries we can use in Gromacs.
 set(PKG_FFT "")
 set(PKG_FFT_LIBS "")
@@ -44,7 +42,7 @@ set(PKG_FFT_LIBS "")
 set(MKL_MANUALLY FALSE)
 if (GMX_FFT_LIBRARY STREQUAL "MKL" AND
     NOT ((CMAKE_C_COMPILER_ID MATCHES "Intel" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "11")
-         OR GMX_ICC_NEXTGEN))
+         OR GMX_INTEL_LLVM))
     # The user will have to provide the set of magic libraries in
     # MKL_LIBRARIES (see below), which we cache (non-advanced), so that they
     # don't have to keep specifying it, and can easily see that
@@ -138,6 +136,8 @@ elseif(${GMX_FFT_LIBRARY} STREQUAL "MKL")
             # docs, but on Jenkins Win2k8, icl tries to interpret it
             # as a file. Shrug.
             set(FFT_LINKER_FLAGS "/Qmkl:sequential")
+        elseif(GMX_INTEL_LLVM AND GMX_INTEL_LLVM_VERSION GREATER_EQUAL 2021020)
+            set(FFT_LINKER_FLAGS "-qmkl=sequential")
         else()
             set(FFT_LINKER_FLAGS "-mkl=sequential")
         endif()
similarity index 70%
rename from cmake/gmxTestICCNextGen.cmake
rename to cmake/gmxTestIntelLLVM.cmake
index 06af4aee3c6d912725ff5ecad4ef357c0f1d79e4..75d499181da66501b094a9c08929c030f2fb954b 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2020, by the GROMACS development team, led by
+# Copyright (c) 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.
 # To help us fund GROMACS development, we humbly ask that you cite
 # the research papers on the package. Check out http://www.gromacs.org.
 
-# CMake detects ICC NextGen (based on LLVM) as Clang
-if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-    include(CheckCXXSourceCompiles)
-    check_cxx_source_compiles(
-        "int main() { return __INTEL_LLVM_COMPILER; }"
-        GMX_ICC_NEXTGEN)
+# CMake detects Intel compiler (based on LLVM) as Clang
+# Was fixed in Cmake 3.20. When we require 3.20 this can be deleted.
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
+  try_compile(GMX_INTEL_LLVM "${CMAKE_BINARY_DIR}" SOURCES "${CMAKE_SOURCE_DIR}/cmake/TestIntelLLVM.cpp" OUTPUT_VARIABLE GMX_INTEL_LLVM_VERSION)
+  if (GMX_INTEL_LLVM)
+    if(GMX_INTEL_LLVM_VERSION MATCHES ": ([0-9]+) ")
+      set(GMX_INTEL_LLVM_VERSION ${CMAKE_MATCH_1})
+    else()
+      message(WARNING "Intel LLVM version detection failed. Output: ${GMX_INTEL_LLVM_VERSION}")
+    endif()
+  endif()
 endif()
index 1cdba12e3ac1ba5c228524ea9f709a90cb19d3b4..bd97fdbaa828d9caf14ac77c50688e3f94f6411b 100644 (file)
@@ -38,6 +38,11 @@ code incorrectly tried to construct a string from nullptr.
 Fixes that affect portability
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+Support for Intel oneAPI compiler 2021.2
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+Fixed compiler infinity math and MKL flags.
+
 Miscellaneous
 ^^^^^^^^^^^^^