Skip to content

Commit

Permalink
Update PDAF optimization flag setting (#23)
Browse files Browse the repository at this point in the history
Adapt flags according to

1. `CMAKE_CXX_COMPILER_ID` (`Intel` or `GNU`)
2. `CMAKE_BUILD_TYPE` (`RELEASE` or `DEBUG`)

Flags are taken from TSMP1
`bldsva/intf_DA/pdaf/arch/build_interface_pdaf.ksh`
  • Loading branch information
jjokella authored Aug 27, 2024
1 parent b0f85c3 commit 7ea08d8
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions cmake/BuildPDAF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,48 @@ list(JOIN PDAF_LINK_LIBS " " PDAF_LINK_LIBS)

# Set PDAF_OPTIM for Makefile header
# ----------------------------------
list(APPEND PDAF_OPTIM "-O2")
list(APPEND PDAF_OPTIM "-xHost")
list(APPEND PDAF_OPTIM "-r8")

# For Gnu-compiler
# list(APPEND PDAF_OPTIM "-O2 -xHost -fbacktrace -fdefault-real-8 -falign-commons -fno-automatic -finit-local-zero -mcmodel=large")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")

# using Intel Compiler
if (CMAKE_BUILD_TYPE STREQUAL "RELEASE")
# Release optimization flags
list(APPEND PDAF_OPTIM "-O2")
elseif (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
# Debug optimization flags
list(APPEND PDAF_OPTIM "-O0")
list(APPEND PDAF_OPTIM "-g")
list(APPEND PDAF_OPTIM "-traceback")
else()
message(FATAL_ERROR "Unsupported CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
endif()

list(APPEND PDAF_OPTIM "-xHost")
list(APPEND PDAF_OPTIM "-r8")

elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

# using GCC (experimental)
if (CMAKE_BUILD_TYPE STREQUAL "RELEASE")
# Release optimization flags
list(APPEND PDAF_OPTIM "-O2")
elseif (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
# Debug optimization flags
list(APPEND PDAF_OPTIM "-O0")
list(APPEND PDAF_OPTIM "-g")
list(APPEND PDAF_OPTIM "-fbacktrace")
else()
message(FATAL_ERROR "Unsupported CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
endif()

list(APPEND PDAF_OPTIM "-fdefault-real-8")
list(APPEND PDAF_OPTIM "-falign-commons")
list(APPEND PDAF_OPTIM "-fno-automatic")
list(APPEND PDAF_OPTIM "-finit-local-zero")
list(APPEND PDAF_OPTIM "-mcmodel=large")

else()
message(FATAL_ERROR "Unsupported CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
endif()

# Join list
list(JOIN PDAF_OPTIM " " PDAF_OPTIM)
Expand Down

0 comments on commit 7ea08d8

Please sign in to comment.