Commit 6de8df50 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: provide openmp compile and link flags.

- the USE_OMP preprocessor symbol is also defined with the openmp
  compile flag to allow conditional compilation of openmp-specific
  code.
parent 4c656217
Test-openmp.C
EXE = $(FOAM_USER_APPBIN)/Test-openmp
EXE_INC = ${COMP_OPENMP}
/* Mostly do not need to explicitly link openmp libraries */
/* EXE_LIBS = ${LINK_OPENMP} */
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //
......@@ -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
#------------------------------------------------------------------------------
......@@ -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
......
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
......@@ -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++
# Flags for compiling/linking openmp
COMP_OPENMP = -DUSE_OMP -fopenmp
LINK_OPENMP = -lgomp
......@@ -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++
# Flags for compiling/linking openmp
COMP_OPENMP = -DUSE_OMP -fopenmp
LINK_OPENMP = -lgomp
......@@ -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++
# Flags for compiling/linking openmp
COMP_OPENMP = -DUSE_OMP -fopenmp
LINK_OPENMP = -lgomp
......@@ -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++
# Flags for compiling/linking openmp
COMP_OPENMP = -DUSE_OMP -qopenmp
LINK_OPENMP = -liomp5
# Flags for compiling/linking openmp
COMP_OPENMP = -DUSE_OMP -qopenmp
LINK_OPENMP = -liomp5
......@@ -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++
# Flags for compiling/linking openmp
COMP_OPENMP = -DUSE_OMP -fopenmp
LINK_OPENMP = -lgomp
......@@ -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++
# Flags for compiling/linking openmp
COMP_OPENMP = -DUSE_OMP -fopenmp
LINK_OPENMP = -lgomp
......@@ -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++
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment