From 2e67aa6b478a0a9e2fc52642e006fdb047827a7a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 25 Sep 2020 16:16:06 -0400 Subject: [PATCH 1/3] autodetect OpenMP 4.0 semantic compatibility if not explicitly set --- src/omp_compat.h | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/omp_compat.h b/src/omp_compat.h index d80d6f6f7f..340bbca204 100644 --- a/src/omp_compat.h +++ b/src/omp_compat.h @@ -25,11 +25,30 @@ // so this is what LAMMPS primarily uses. For those compilers // that strictly implement OpenMP 4.0 (such as GCC 9.0 and later // or Clang 10.0 and later), we give up default(none). -#if LAMMPS_OMP_COMPAT == 4 -# define LMP_SHARED(...) -# define LMP_DEFAULT_NONE default(shared) -#else -# define LMP_SHARED(...) shared(__VA_ARGS__) -# define LMP_DEFAULT_NONE default(none) + +// autodetect OpenMP compatibility if not explicitly set + +#ifndef LAMMPS_OMP_COMPAT +# if defined(__INTEL_COMPILER) +# if __INTEL_COMPILER > 18 +# define LAMMPS_OMP_COMPAT 4 +# endif +# elif defined(__clang__) +# if __clang_major__ >= 10 +# define LAMMPS_OMP_COMPAT 4 +# endif +# elif defined(__GNUC__) +# if __GNUC__ >= 0 +# define LAMMPS_OMP_COMPAT 4 +# endif +# endif +#endif + +#if LAMMPS_OMP_COMPAT == 4 +# define LMP_SHARED(...) +# define LMP_DEFAULT_NONE default(shared) +#else +# define LMP_SHARED(...) shared(__VA_ARGS__) +# define LMP_DEFAULT_NONE default(none) #endif From 5e110fe70741c554e8b42120aa0cf981b83197b4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 25 Sep 2020 16:45:39 -0400 Subject: [PATCH 2/3] update docs for autodetected OpenMP compatibility --- doc/src/Build_basics.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/Build_basics.rst b/doc/src/Build_basics.rst index 3b20209e5c..d364382591 100644 --- a/doc/src/Build_basics.rst +++ b/doc/src/Build_basics.rst @@ -159,11 +159,11 @@ others (e.g. GCC version 9 and beyond, Clang version 10 and later) may implement strict OpenMP 4.0 and later semantics, which are incompatible with the OpenMP 3.1 semantics used in LAMMPS for maximal compatibility with compiler versions in use. If compilation with OpenMP enabled fails -because of your compiler requiring strict OpenMP 4.0 semantic, you can +because of your compiler requiring strict OpenMP 4.0 semantics, you can change the behavior by adding ``-D LAMMPS_OMP_COMPAT=4`` to the ``LMP_INC`` variable in your makefile, or add it to the command line -while configuring with CMake. CMake will detect the suitable setting for -the GNU, Clang, and Intel compilers. +while configuring with CMake. LAMMPS will autodetect a suitable setting +for most GNU, Clang, and Intel compilers. ---------- From 25bda86ad0941c294fb66389d2db00bfaed9efc6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 28 Sep 2020 12:52:32 -0400 Subject: [PATCH 3/3] fix typo --- src/omp_compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/omp_compat.h b/src/omp_compat.h index 340bbca204..366dd9371c 100644 --- a/src/omp_compat.h +++ b/src/omp_compat.h @@ -38,7 +38,7 @@ # define LAMMPS_OMP_COMPAT 4 # endif # elif defined(__GNUC__) -# if __GNUC__ >= 0 +# if __GNUC__ >= 9 # define LAMMPS_OMP_COMPAT 4 # endif # endif