diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 87bdce937f..efff21417e 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -69,14 +69,6 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") endif() endif() -if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - set(CMAKE_TUNE_DEFAULT "-march=native") -endif() - -if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") - set(CMAKE_TUNE_DEFAULT "-march=native") -endif() - # we require C++11 without extensions set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -366,7 +358,7 @@ foreach(PKG_WITH_INCL KSPACE PYTHON VORONOI USER-COLVARS USER-MOLFILE USER-NETCD endif() endforeach() -set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler specific optimization or instrumentation") +set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler and machine specific optimization flags (compilation only)") separate_arguments(CMAKE_TUNE_FLAGS) foreach(_FLAG ${CMAKE_TUNE_FLAGS}) target_compile_options(lammps PRIVATE ${_FLAG}) diff --git a/doc/src/Build_basics.rst b/doc/src/Build_basics.rst index 815ff583cc..0ddf65ab46 100644 --- a/doc/src/Build_basics.rst +++ b/doc/src/Build_basics.rst @@ -193,14 +193,17 @@ compiler and any :doc:`accelerator packages ` you have included in the build. You can tell CMake to look for a specific compiler with setting CMake -variable during configuration. For a few common choices, there are also -presets in the ``cmake/presets`` folder. For convenience, there is a -``CMAKE_TUNE_FLAGS`` variable that can be set to apply global compiler -options. More on that below, but you can also specify the corresponding -``CMAKE_*_FLAGS`` variables individually if you want to experiment with -alternate optimization flags. You should specify all 3 compilers, so -that the (few) LAMMPS source files written in C or Fortran are built -with a compiler consistent with the one used for the C++ files: +variables (listed below) during configuration. For a few common +choices, there are also presets in the ``cmake/presets`` folder. For +convenience, there is a ``CMAKE_TUNE_FLAGS`` variable that can be set to +apply global compiler options (applied to compilation only), to be used +for adding compiler or host specific optimization flags in addition to +the "flags" variables listed below. You may also specify the +corresponding ``CMAKE_*_FLAGS`` variables individually, if you want to +experiment with alternate optimization flags. You should specify all 3 +compilers, so that the (few) LAMMPS source files written in C or Fortran +are built with a compiler consistent with the one used for the C++ +files: .. code-block:: bash @@ -229,11 +232,7 @@ can be loaded with `-C ../cmake/presets/clang.cmake`. Similarly, In addition you can set ``CMAKE_TUNE_FLAGS`` to specifically add compiler flags to tune for optimal performance on given hosts. By -default these are initialized to some compiler specific flags, to -optimize the LAMMPS executable with optimizations and instructions -available on the host where LAMMPS is compiled. For example, for Intel -compilers this would be ``-xHost`` and for GNU compilers this would be -``-march=native``. To turn these flags off, do ``-D CMAKE_TUNE_FLAGS=``. +default this variable is empty. .. note:: diff --git a/doc/src/Howto_cmake.rst b/doc/src/Howto_cmake.rst index 490de635b5..89d9901918 100644 --- a/doc/src/Howto_cmake.rst +++ b/doc/src/Howto_cmake.rst @@ -331,7 +331,7 @@ Some common LAMMPS specific variables * - ``BUILD_DOC`` - include building the HTML format documentation for packaging/installing (default: ``off``) * - ``CMAKE_TUNE_FLAGS`` - - common compiler flags, for optimization or instrumentation (default: compiler specific) + - common compiler flags, for optimization or instrumentation (default:) * - ``LAMMPS_MACHINE`` - when set to ``name`` the LAMMPS executable and library will be called ``lmp_name`` and ``liblammps_name.a`` * - ``LAMMPS_EXCEPTIONS``