diff --git a/applications/test/openmp/Make/files b/applications/test/openmp/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..c2749a9419f38c1d43718a57082b666f6e4dbd88 --- /dev/null +++ b/applications/test/openmp/Make/files @@ -0,0 +1,3 @@ +Test-openmp.C + +EXE = $(FOAM_USER_APPBIN)/Test-openmp diff --git a/applications/test/openmp/Make/options b/applications/test/openmp/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..54eed51fb98aec99bde724a061aff18cbc2c3e76 --- /dev/null +++ b/applications/test/openmp/Make/options @@ -0,0 +1,4 @@ +EXE_INC = ${COMP_OPENMP} + +/* Mostly do not need to explicitly link openmp libraries */ +/* EXE_LIBS = ${LINK_OPENMP} */ diff --git a/applications/test/openmp/Test-openmp.C b/applications/test/openmp/Test-openmp.C new file mode 100644 index 0000000000000000000000000000000000000000..acb68e9ed86d6d6d96f131370dfbea08e6c39a27 --- /dev/null +++ b/applications/test/openmp/Test-openmp.C @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Description + Simple test program for compiling/running openmp + +\*---------------------------------------------------------------------------*/ + +#include <cstdio> +#include <cstdlib> +#include <iostream> + +#ifdef USE_OMP +#include <omp.h> +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + int nThreads, threadId; + +// Fork threads with their own copies of variables +#ifdef USE_OMP +#pragma omp parallel private(nThreads, threadId) + { + threadId = omp_get_thread_num(); + nThreads = omp_get_num_threads(); + + // Printf rather than cout to ensure that it emits in one go + printf("Called from thread = %d\n", threadId); + + // Master thread + if (threadId == 0) + { + // Printf rather than cout to ensure that it emits in one go + printf("Number of threads = %d\n", nThreads); + } + } +#else + std::cout << "Compiled without openmp!\n"; +#endif + + return 0; +} + + +// ************************************************************************* // diff --git a/etc/config.sh/kahip b/etc/config.sh/kahip index 21d7a8a84a54df03619a885f0afdb1c4e23f159d..42557831c3463fdccbd51bb2a9b7e07c96f4a590 100644 --- a/etc/config.sh/kahip +++ b/etc/config.sh/kahip @@ -42,18 +42,11 @@ # An Int64 OpenFOAM version can use it, but the mesh size is limited # accordingly. # -# If KaHIP was compiled with openmp, you may need additional -# compile or link flags in KAHIP_COMP_FLAGS KAHIP_LINK_FLAGS -# #------------------------------------------------------------------------------ # USER EDITABLE PART: Changes made here may be lost with the next upgrade KAHIP_VERSION=kahip-2.00 export KAHIP_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$KAHIP_VERSION -# Adjust as required -# export KAHIP_COMP_FLAGS="-fopenmp" -export KAHIP_LINK_FLAGS="-lgomp" - # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake index 39c8f109a504fdf6c3aec4809f23ec0fbdc60568..f3711333487103d6732d1f8f6b22a5864ee12645 100755 --- a/src/parallel/decompose/Allwmake +++ b/src/parallel/decompose/Allwmake @@ -33,7 +33,6 @@ hasKahip() local header label settings unset KAHIP_ARCH_PATH KAHIP_VERSION - unset KAHIP_COMP_FLAGS KAHIP_LINK_FLAGS settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/kahip) || { echo "$warning (no config.sh/kahip settings)" return 1 diff --git a/src/parallel/decompose/kahipDecomp/Make/options b/src/parallel/decompose/kahipDecomp/Make/options index 9c746b309c7f2b795507d0ac3c705fdea9727266..fcd1c5d268a78ceb44ffc5090876d9dc47b52581 100644 --- a/src/parallel/decompose/kahipDecomp/Make/options +++ b/src/parallel/decompose/kahipDecomp/Make/options @@ -1,13 +1,15 @@ EXE_INC = \ -I$(KAHIP_ARCH_PATH)/include \ - -I../decompositionMethods/lnInclude \ - $(KAHIP_COMP_FLAGS) + -I../decompositionMethods/lnInclude /* * The $(KAHIP_ARCH_PATH)/lib$WM_COMPILER_LIB_ARCH path is provided - * to support central, non-thirdparty installations + * to support central, non-thirdparty installations. + * + * KaHIP is often compiled with openmp, but may be missing the + * link dependency for openmp. */ LIB_LIBS = \ -L$(KAHIP_ARCH_PATH)/lib \ -L$(KAHIP_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ - -L$(FOAM_EXT_LIBBIN) $(KAHIP_LINK_FLAGS) -lkahip + -L$(FOAM_EXT_LIBBIN) $(LINK_OPENMP) -lkahip diff --git a/wmake/rules/linux64Clang/general b/wmake/rules/linux64Clang/general index 1002cb169b5ba7215e263d07cced90cd3e8e0308..d83a18b000b3bb3e663ccee8efa77439d863c39d 100644 --- a/wmake/rules/linux64Clang/general +++ b/wmake/rules/linux64Clang/general @@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linux64Clang/openmp b/wmake/rules/linux64Clang/openmp new file mode 100644 index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a --- /dev/null +++ b/wmake/rules/linux64Clang/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64Gcc/general b/wmake/rules/linux64Gcc/general index 1002cb169b5ba7215e263d07cced90cd3e8e0308..d83a18b000b3bb3e663ccee8efa77439d863c39d 100644 --- a/wmake/rules/linux64Gcc/general +++ b/wmake/rules/linux64Gcc/general @@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linux64Gcc/openmp b/wmake/rules/linux64Gcc/openmp new file mode 100644 index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a --- /dev/null +++ b/wmake/rules/linux64Gcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64GccKNL/general b/wmake/rules/linux64GccKNL/general index 1002cb169b5ba7215e263d07cced90cd3e8e0308..d83a18b000b3bb3e663ccee8efa77439d863c39d 100644 --- a/wmake/rules/linux64GccKNL/general +++ b/wmake/rules/linux64GccKNL/general @@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linux64GccKNL/openmp b/wmake/rules/linux64GccKNL/openmp new file mode 100644 index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a --- /dev/null +++ b/wmake/rules/linux64GccKNL/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64Icc/general b/wmake/rules/linux64Icc/general index 52b0e177d7afe6ab60761862ae8b9f966fa18f2f..eb3898f709eb247f990ab1c0911dac0742e3b19d 100644 --- a/wmake/rules/linux64Icc/general +++ b/wmake/rules/linux64Icc/general @@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linux64Icc/openmp b/wmake/rules/linux64Icc/openmp new file mode 100644 index 0000000000000000000000000000000000000000..154c9e5743dae699e2dc6c25111dbe4846113030 --- /dev/null +++ b/wmake/rules/linux64Icc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -qopenmp +LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linux64IccKNL/openmp b/wmake/rules/linux64IccKNL/openmp new file mode 100644 index 0000000000000000000000000000000000000000..154c9e5743dae699e2dc6c25111dbe4846113030 --- /dev/null +++ b/wmake/rules/linux64IccKNL/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -qopenmp +LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linuxARM7Gcc/general b/wmake/rules/linuxARM7Gcc/general index 1e51dcc403ca74c4a15dc7538c09d3bce642bbe5..4fc50267edbaa5c8c846891dc70fe93f09b5944c 100644 --- a/wmake/rules/linuxARM7Gcc/general +++ b/wmake/rules/linuxARM7Gcc/general @@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxARM7Gcc/openmp b/wmake/rules/linuxARM7Gcc/openmp new file mode 100644 index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a --- /dev/null +++ b/wmake/rules/linuxARM7Gcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxClang/general b/wmake/rules/linuxClang/general index e3427c3181a329ec6bf2f64bdefc4f81bf9afde7..eae23e305bdd3331475a0d51ad5fa727144608c0 100644 --- a/wmake/rules/linuxClang/general +++ b/wmake/rules/linuxClang/general @@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxClang/openmp b/wmake/rules/linuxClang/openmp new file mode 100644 index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a --- /dev/null +++ b/wmake/rules/linuxClang/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxGcc/general b/wmake/rules/linuxGcc/general index e3427c3181a329ec6bf2f64bdefc4f81bf9afde7..eae23e305bdd3331475a0d51ad5fa727144608c0 100644 --- a/wmake/rules/linuxGcc/general +++ b/wmake/rules/linuxGcc/general @@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxGcc/openmp b/wmake/rules/linuxGcc/openmp new file mode 100644 index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a --- /dev/null +++ b/wmake/rules/linuxGcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxIA64Gcc/general b/wmake/rules/linuxIA64Gcc/general index 182ee7f9019e4fcffa64e7bf30fef331a656450d..d8fb470836e8d2469fb42414aeecf3dd06c7eda3 100644 --- a/wmake/rules/linuxIA64Gcc/general +++ b/wmake/rules/linuxIA64Gcc/general @@ -4,6 +4,7 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/X include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxIA64Gcc/openmp b/wmake/rules/linuxIA64Gcc/openmp new file mode 100644 index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a --- /dev/null +++ b/wmake/rules/linuxIA64Gcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxIA64Icc/general b/wmake/rules/linuxIA64Icc/general index 09a389665615459359790ebd71c618b28b1eb5bd..c3269860fb89a538b25faeec8ba66c5ea6183a55 100644 --- a/wmake/rules/linuxIA64Icc/general +++ b/wmake/rules/linuxIA64Icc/general @@ -4,6 +4,7 @@ GLIBS = include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/X include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxIA64Icc/openmp b/wmake/rules/linuxIA64Icc/openmp new file mode 100644 index 0000000000000000000000000000000000000000..154c9e5743dae699e2dc6c25111dbe4846113030 --- /dev/null +++ b/wmake/rules/linuxIA64Icc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -qopenmp +LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linuxIcc/general b/wmake/rules/linuxIcc/general index 5c94cad44af0463b5bf104df334ff04867a1065d..85f5be51c0992097b1593c56b86310b260fe0ee8 100644 --- a/wmake/rules/linuxIcc/general +++ b/wmake/rules/linuxIcc/general @@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxPPC64Gcc/general b/wmake/rules/linuxPPC64Gcc/general index a590cc29c8d143674c2070610efb1fff1027b7ca..712516c2681a53c10d1d3ad26614fd65fe20317f 100644 --- a/wmake/rules/linuxPPC64Gcc/general +++ b/wmake/rules/linuxPPC64Gcc/general @@ -5,6 +5,7 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/X include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxPPC64Gcc/openmp b/wmake/rules/linuxPPC64Gcc/openmp new file mode 100644 index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a --- /dev/null +++ b/wmake/rules/linuxPPC64Gcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxPPC64leGcc/general b/wmake/rules/linuxPPC64leGcc/general index 7867cbde8f46661b843fc674bd041809705e8f5b..575cadaeee00313894af62de0bd85a1661cf22db 100644 --- a/wmake/rules/linuxPPC64leGcc/general +++ b/wmake/rules/linuxPPC64leGcc/general @@ -5,6 +5,7 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl include $(GENERAL_RULES)/standard +include $(DEFAULT_RULES)/openmp include $(DEFAULT_RULES)/X include $(DEFAULT_RULES)/c include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linuxPPC64leGcc/openmp b/wmake/rules/linuxPPC64leGcc/openmp new file mode 100644 index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a --- /dev/null +++ b/wmake/rules/linuxPPC64leGcc/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp