Remove/replace many mentions of Jenkins
[alexxy/gromacs.git] / cmake / gmxManageFFTLibraries.cmake
index 2f72efcae7ba3b0a66d01bd169c690e3aa8a56e2..77e931a3e3b4834d9f0fac24a0f81ef5795f22b3 100644 (file)
@@ -1,7 +1,8 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+# Copyright (c) 2012,2013,2014,2015,2016 by the GROMACS development team.
+# 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.
@@ -39,8 +40,7 @@ set(PKG_FFT_LIBS "")
 # all their stuff. It's not easy if you only want some of their
 # stuff...
 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"))
+if (GMX_FFT_LIBRARY STREQUAL "MKL" AND NOT 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
@@ -75,7 +75,7 @@ if(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
             message(FATAL_ERROR "Cannot build FFTW3 automatically (GMX_BUILD_OWN_FFTW=ON) with ninja")
         endif()
 
-        add_subdirectory(src/contrib/fftw)
+        add_subdirectory(src/external/build-fftw)
         include_directories(BEFORE ${${FFTW}_INCLUDE_DIRS})
         # libgmxfftw is always built static, so libgromacs does not
         # have a dependency on anything, so PKG_FFT should be empty
@@ -92,38 +92,54 @@ if(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
         set(PKG_FFT "${${FFTW}_PKG}")
         include_directories(SYSTEM ${${FFTW}_INCLUDE_DIRS})
 
-        if ((${GMX_SIMD_ACTIVE} MATCHES "SSE" OR ${GMX_SIMD_ACTIVE} MATCHES "AVX") AND NOT ${FFTW}_HAVE_SIMD)
-            set(FFT_WARNING_MESSAGE "The fftw library found is compiled without SIMD support, which makes it slow. Consider recompiling it or contact your admin")
+        if(NOT WIN32) # Detection doesn't work on Windows
+          if ((${GMX_SIMD_ACTIVE} MATCHES "SSE" OR ${GMX_SIMD_ACTIVE} MATCHES "AVX") AND NOT ${FFTW}_HAVE_SIMD)
+              set(FFT_WARNING_MESSAGE "The fftw library found is compiled without SIMD support, which makes it slow. Consider recompiling it or contact your admin")
+          else()
+              if(${GMX_SIMD_ACTIVE} MATCHES "AVX" AND NOT (${FFTW}_HAVE_SSE OR ${FFTW}_HAVE_SSE2))
+                  # If we end up here we have an AVX Gromacs build, and
+                  # FFTW with SIMD.
+                  set(FFT_WARNING_MESSAGE "The FFTW library was compiled with neither --enable-sse nor --enable-sse2; those would have enabled SSE(2) SIMD instructions. This will give suboptimal performance. You should (re)compile the FFTW library with --enable-sse2 and --enable-avx (and --enable-avx2 or --enable-avx512 if supported).")
+              endif()
+          endif()
+        endif()
+
+        find_path(ARMPL_INCLUDE_DIR "armpl.h" HINTS ${${FFTW}_INCLUDE_DIRS}
+            NO_DEFAULT_PATH
+            NO_CMAKE_ENVIRONMENT_PATH
+            NO_CMAKE_PATH
+            NO_SYSTEM_ENVIRONMENT_PATH
+            NO_CMAKE_SYSTEM_PATH)
+        mark_as_advanced(ARMPL_INCLUDE_DIR)
+        if (ARMPL_INCLUDE_DIR)
+            set(GMX_FFT_ARMPL_FFTW3 1)
+            set(FFT_STATUS_MESSAGE "Using external FFT library - ARM Performance Library (FFTW3 compatibility mode)")
         else()
-            if(${GMX_SIMD_ACTIVE} MATCHES "AVX" AND NOT (${FFTW}_HAVE_SSE OR ${FFTW}_HAVE_SSE2))
-                # If we end up here we have an AVX Gromacs build, and
-                # FFTW with SIMD.
-                set(FFT_WARNING_MESSAGE "The FFTW library was compiled with neither --enable-sse nor --enable-sse2; those would have enabled SSE(2) SIMD instructions. This will give suboptimal performance. You should (re)compile the FFTW library with --enable-sse2 and --enable-avx (and --enable-avx2 or --enable-avx512 if supported).")
-            endif()
+            set(FFT_STATUS_MESSAGE "Using external FFT library - FFTW3")
         endif()
-        set(FFT_STATUS_MESSAGE "Using external FFT library - FFTW3")
+    endif()
+    if (NOT GMX_FFT_ARMPL_FFTW3)
+        set(GMX_FFT_FFTW3 1)
     endif()
 
     set(FFT_LIBRARIES ${${FFTW}_LIBRARIES})
-    set(GMX_FFT_FFTW3 1)
 elseif(${GMX_FFT_LIBRARY} STREQUAL "MKL")
-    # Intel 11 and up makes life somewhat easy if you just want to use
+    # Intel compilers make life somewhat easy if you just want to use
     # all their stuff. It's not easy if you only want some of their
     # stuff...
     if (NOT MKL_MANUALLY)
         # The next line takes care of everything for MKL
         if (WIN32)
-            # This works according to the Intel MKL 10.3 for Windows
-            # 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()
         # Some versions of icc require this in order that mkl.h can be
         # found at compile time.
-        set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} ${FFT_LINKER_FLAGS}")
-        set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} ${FFT_LINKER_FLAGS}")
+        list(APPEND EXTRA_C_FLAGS ${FFT_LINKER_FLAGS})
+        list(APPEND EXTRA_CXX_FLAGS ${FFT_LINKER_FLAGS})
 
         set(MKL_ERROR_MESSAGE "Make sure you have configured your compiler so that ${FFT_LINKER_FLAGS} will work.")
     else()