CMAKE, MAKE: Add support for OpenMP.
Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
parent
e1fa68b54f
commit
2c336a4d74
@ -64,6 +64,16 @@ if(ENABLE_MPI)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(ENABLE_OMP "Enable OpenMP support" ON)
|
||||
if(ENABLE_OMP)
|
||||
find_package(OpenMP COMPONENTS Fortran)
|
||||
if(OpenMP_Fortran_FOUND)
|
||||
include_directories(${OpenMP_Fortran_INCLUDE_DIRS})
|
||||
target_compile_options(amun.x PRIVATE "${OpenMP_Fortran_FLAGS}")
|
||||
target_link_libraries(amun.x ${OpenMP_Fortran_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(ENABLE_SIGNALS "Enables signal handler support" ON)
|
||||
if(ENABLE_SIGNALS)
|
||||
target_compile_definitions(amun.x PRIVATE SIGNALS)
|
||||
|
@ -27,6 +27,9 @@ FFLAGS = -Og -g -DDEBUG -fcheck=all
|
||||
else
|
||||
FFLAGS = -O2 -march=native -pipe
|
||||
endif
|
||||
ifeq ($(OPENMP),Y)
|
||||
FFLAGS += -fopenmp
|
||||
endif
|
||||
LDFLAGS = $(FFLAGS)
|
||||
ifeq ($(STATIC),Y)
|
||||
LDFLAGS += -static
|
||||
@ -56,6 +59,9 @@ FFLAGS = -O0 -g -Mbounds -Mchkptr -Mcache_align -Mnovintr -Mchkstk -DDEBUG
|
||||
else
|
||||
FFLAGS = -fast -O3
|
||||
endif
|
||||
ifeq ($(OPENMP),Y)
|
||||
FFLAGS += -mp
|
||||
endif
|
||||
LDFLAGS = $(FFLAGS)
|
||||
ifeq ($(STATIC),Y)
|
||||
LDFLAGS += -Bstatic
|
||||
@ -85,6 +91,9 @@ FFLAGS = -O -g -DDEBUG
|
||||
else
|
||||
FFLAGS = -fast
|
||||
endif
|
||||
ifeq ($(OPENMP),Y)
|
||||
FFLAGS += -mp
|
||||
endif
|
||||
LDFLAGS = $(FFLAGS)
|
||||
ifeq ($(STATIC),Y)
|
||||
LDFLAGS += -Bstatic
|
||||
@ -114,6 +123,9 @@ FFLAGS = -O -g -DDEBUG
|
||||
else
|
||||
FFLAGS = -O2 -xHost
|
||||
endif
|
||||
ifeq ($(OPENMP),Y)
|
||||
FFLAGS += -openmp
|
||||
endif
|
||||
LDFLAGS = $(FFLAGS)
|
||||
ifeq ($(STATIC),Y)
|
||||
LDFLAGS += -static
|
||||
|
@ -15,8 +15,10 @@ SIGNALS = N
|
||||
# parallelization flags:
|
||||
#
|
||||
# MPI - enable or disable MPI parallelization
|
||||
# OPENMP - enable or disable OpenMP parallelization
|
||||
#
|
||||
MPI = N
|
||||
OPENMP = N
|
||||
|
||||
# output data format:
|
||||
#
|
||||
|
@ -65,6 +65,11 @@ program amun
|
||||
integer :: iin, iev, itm
|
||||
integer :: ed, eh, em, es
|
||||
|
||||
! OpenMP
|
||||
!
|
||||
integer :: nthreads = 1
|
||||
!$ integer :: omp_get_num_threads
|
||||
|
||||
! the format string
|
||||
!
|
||||
character(len=80) :: sfmt
|
||||
@ -131,8 +136,16 @@ program amun
|
||||
call print_welcome(verbose)
|
||||
#ifdef MPI
|
||||
call print_section(verbose, "Parallelization")
|
||||
call print_parameter(verbose, "MPI processes", nprocs)
|
||||
call print_parameter(verbose, "MPI processes" , nprocs)
|
||||
#else /* MPI */
|
||||
!$ call print_section(verbose, "Parallelization")
|
||||
#endif /* MPI */
|
||||
!$omp parallel
|
||||
!$omp master
|
||||
!$ nthreads = omp_get_num_threads()
|
||||
!$ call print_parameter(verbose, "OpenMP threads", nthreads)
|
||||
!$omp end master
|
||||
!$omp end parallel
|
||||
|
||||
! read parameters
|
||||
!
|
||||
|
Loading…
x
Reference in New Issue
Block a user