Merge pull request #851 from paulromano/gcc-o2

Change default optimization level for gcc
This commit is contained in:
Will Boyd 2017-04-11 07:44:15 -04:00 committed by GitHub
commit 8f405d8107
3 changed files with 20 additions and 10 deletions

View file

@ -25,14 +25,13 @@ endif()
# Command line options
#===============================================================================
option(openmp "Enable shared-memory parallelism with OpenMP" OFF)
option(openmp "Enable shared-memory parallelism with OpenMP" ON)
option(profile "Compile with profiling flags" OFF)
option(debug "Compile with debug flags" OFF)
option(optimize "Turn on all compiler optimization flags" OFF)
option(coverage "Compile with coverage analysis flags" OFF)
option(mpif08 "Use Fortran 2008 MPI interface" OFF)
# Maximum number of nested coordinates levels
set(maxcoord 10 CACHE STRING "Maximum number of nested coordinate levels")
add_definitions(-DMAX_COORD=${maxcoord})
@ -108,9 +107,11 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
endif()
# GCC compiler options
list(APPEND f90flags -cpp -std=f2008 -fbacktrace)
list(APPEND cflags -cpp -std=c99)
list(APPEND f90flags -cpp -std=f2008 -fbacktrace -O2)
list(APPEND cflags -cpp -std=c99 -O2)
if(debug)
list(REMOVE_ITEM f90flags -O2)
list(REMOVE_ITEM cflags -O2)
list(APPEND f90flags -g -Wall -pedantic -fbounds-check
-ffpe-trap=invalid,overflow,underflow)
list(APPEND cflags -g -Wall -pedantic -fbounds-check)
@ -122,6 +123,8 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
list(APPEND ldflags -pg)
endif()
if(optimize)
list(REMOVE_ITEM f90flags -O2)
list(REMOVE_ITEM cflags -O2)
list(APPEND f90flags -O3)
list(APPEND cflags -O3)
endif()
@ -142,8 +145,8 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
list(APPEND cflags -std=c99)
if(debug)
list(APPEND f90flags -g -warn -ftrapuv -fp-stack-check
"-check all" -fpe0)
list(APPEND cflags -g -w3 -ftrapuv -fp-stack-check)
"-check all" -fpe0 -O0)
list(APPEND cflags -g -w3 -ftrapuv -fp-stack-check -O0)
list(APPEND ldflags -g)
endif()
if(profile)
@ -182,7 +185,8 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL XL)
list(APPEND f90flags -O2)
add_definitions(-DNO_F2008)
if(debug)
list(APPEND f90flags -g -C -qflag=i:i -u)
list(REMOVE_ITEM f90flags -O2)
list(APPEND f90flags -g -C -qflag=i:i -u -O0)
list(APPEND ldflags -g)
endif()
if(profile)
@ -190,6 +194,7 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL XL)
list(APPEND ldflags -p)
endif()
if(optimize)
list(REMOVE_ITEM f90flags -O2)
list(APPEND f90flags -O3)
endif()
if(openmp)
@ -207,6 +212,11 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Cray)
endif()
# Show flags being used
message(STATUS "Fortran flags: ${f90flags}")
message(STATUS "C flags: ${cflags}")
message(STATUS "Linker flags: ${ldflags}")
#===============================================================================
# git SHA1 hash
#===============================================================================

View file

@ -231,7 +231,7 @@ optimize
openmp
Enables shared-memory parallelism using the OpenMP API. The Fortran compiler
being used must support OpenMP.
being used must support OpenMP. (Default: on)
coverage
Compile and link code instrumented for coverage analysis. This is typically

View file

@ -184,8 +184,8 @@ class Test(object):
build_str += "-Ddebug=ON "
if self.optimize:
build_str += "-Doptimize=ON "
if self.openmp:
build_str += "-Dopenmp=ON "
if not self.openmp:
build_str += "-Dopenmp=OFF "
if self.coverage:
build_str += "-Dcoverage=ON "
self.build_opts = build_str