diff --git a/doc/src/Build_basics.txt b/doc/src/Build_basics.txt index 90a91db60f..fa4ef12586 100644 --- a/doc/src/Build_basics.txt +++ b/doc/src/Build_basics.txt @@ -116,6 +116,18 @@ enables OpenMP. For GNU compilers it is -fopenmp. For (recent) Intel compilers it is -qopenmp. If you are using a different compiler, please refer to its documentation. +[OpenMP Compiler compatibility info]: :link(default-none-issues) + +Some compilers do not fully support the 'default(none)' directive +and others (e.g. GCC version 9 and beyond) may implement OpenMP 4.0 +semantics, which are incompatible with the OpenMP 3.1 directives used +in LAMMPS (for maximal compatibility with compiler versions in use). +In those case, all 'default(none)' directives (which aid in detecting +incorrect and unwanted sharing) can be replaced with 'default(shared)' +while dropping all 'shared()' directives. The script +'src/USER-OMP/hack_openmp_for_pgi_gcc9.sh' can be used to automate +this conversion. + :line Choice of compiler and compile/link options :h4,link(compile) diff --git a/doc/src/Build_extras.txt b/doc/src/Build_extras.txt index 23773651d6..09841bd9d4 100644 --- a/doc/src/Build_extras.txt +++ b/doc/src/Build_extras.txt @@ -932,7 +932,9 @@ LINKFLAGS: -fopenmp # for GNU Compilers LINKFLAGS: -qopenmp # for Intel compilers on Linux :pre For other platforms and compilers, please consult the documentation -about OpenMP support for your compiler. +about OpenMP support for your compiler. Please see the note about +how to address compatibility "issues with the 'default(none)' +directive"_Build_basics.html#default-none-issues of some compilers. :line diff --git a/src/USER-OMP/hack_openmp_for_pgi.sh b/src/USER-OMP/hack_openmp_for_pgi.sh deleted file mode 100755 index a076fd1fcb..0000000000 --- a/src/USER-OMP/hack_openmp_for_pgi.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -for f in *.h *.cpp -do \ - sed -e '/#pragma omp/s/^\(.*default\)(none)\(.*\)$/\1(shared)\2/' \ - -e '/#pragma omp/s/shared([a-z0-9,_]\+)//' \ - -i.bak $f -done diff --git a/src/USER-OMP/hack_openmp_for_pgi_gcc9.sh b/src/USER-OMP/hack_openmp_for_pgi_gcc9.sh new file mode 100755 index 0000000000..6f9f30cedd --- /dev/null +++ b/src/USER-OMP/hack_openmp_for_pgi_gcc9.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# convert default(none) directives for OpenMP pragmas to default(shared) and remove shared() directive +# this allows compiling OpenMP pragmas in LAMMPS with compilers that don't support default(none) properly +# or require backward incompatible OpenMP 4 and OpenMP 5 semantics + +for f in *.h *.cpp +do \ + sed -e '/#pragma omp/s/^\(.*default\)(none)\(.*\)$/\1(shared)\2/' \ + -e '/#pragma omp/s/shared([a-z0-9,_]\+)//' \ + -i.bak $f +done