forked from lijiext/lammps
Merge pull request #2396 from akohlmey/openmp-compat-auto
Autodetect OpenMP compatibility setting for known compiler signatures
This commit is contained in:
commit
e0e4e516fc
|
@ -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.
|
||||
|
||||
----------
|
||||
|
||||
|
|
|
@ -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__ >= 9
|
||||
# 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue