Commit eb8a6512 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

rename and document script to automatically convert 'default(none)' to...

rename and document script to automatically convert 'default(none)' to 'default(shared)' OpenMP pragmas
parent ac7d74f2
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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)
+3 −1
Original line number Diff line number Diff line
@@ -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

+12 −0
Original line number Diff line number Diff line
#!/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/' \