Skip to content

Commit a52c5c9

Browse files
adding new compiler flags for IntelLLVM compilers (e.g., ifx)
1 parent 78b96be commit a52c5c9

File tree

2 files changed

+74
-11
lines changed

2 files changed

+74
-11
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
####################################################################
2+
# FLAGS COMMON TO ALL BUILD TYPES
3+
####################################################################
4+
5+
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl" )
6+
7+
if( HAVE_AUTOPROFILE )
8+
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -finstrument-functions" )
9+
endif()
10+
11+
####################################################################
12+
# RELEASE FLAGS
13+
####################################################################
14+
15+
set( CMAKE_Fortran_FLAGS_RELEASE
16+
"-O3 -unroll -inline-forceinline -no-heap-arrays -assume byterecl -qopenmp" )
17+
18+
####################################################################
19+
# DEBUG FLAGS
20+
####################################################################
21+
22+
set( CMAKE_Fortran_FLAGS_DEBUG
23+
"-O0 -g -check bounds -traceback -warn all -no-heap-arrays -fpe0 -ftz -check all -assume byterecl -qopenmp" )
24+
25+
####################################################################
26+
# RELWITHDEBINFO FLAGS
27+
####################################################################
28+
29+
set( CMAKE_Fortran_FLAGS_RELWITHDEBINFO
30+
"-g -O0 -traceback -fno-openmp" )
31+
# "-O2 -g -DNDEBUG -check bounds -traceback -no-heap-arrays -assume byterecl -qopenmp" )
32+
33+
####################################################################
34+
# BIT REPRODUCIBLE FLAGS
35+
####################################################################
36+
37+
set( CMAKE_Fortran_FLAGS_BIT
38+
"-O2 -no-heap-arrays -fp-model strict -assume byterecl -qopenmp" )
39+
40+
####################################################################
41+
# LINK FLAGS
42+
####################################################################
43+
44+
set( CMAKE_Fortran_LINK_FLAGS )
45+
46+
####################################################################
47+
# Notes:
48+
# - `-qopenmp` enables OpenMP for `ifx`, including linking the necessary runtime
49+
# - For GPU offload: Add `-fopenmp-targets=spir64` (Intel GPU) or `-fopenmp-targets=nvptx64-nvidia-cuda` (NVIDIA)
50+
# - Reproducibility: `-fp-model strict` ensures bitwise results but may hurt perf
51+
# - Consider `-diag-disable=10448` if `ifx` emits unnecessary diagnostic noise

cmake/crtm_compiler_flags.cmake

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
1-
# (C) Copyright 2009-2016 ECMWF.
2-
#
3-
# This software is licensed under the terms of the Apache Licence Version 2.0
4-
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5-
# In applying this licence, ECMWF does not waive the privileges and immunities
6-
# granted to it by virtue of its status as an intergovernmental organisation nor
7-
# does it submit to any jurisdiction.
81

92
if( NOT CMAKE_BUILD_TYPE MATCHES "Debug" )
103
add_definitions( -DNDEBUG )
11-
endif( )
4+
endif()
125

136
#######################################################################################
147
# Fortran
158
#######################################################################################
169

10+
message(STATUS "Compiler ID: ${CMAKE_Fortran_COMPILER_ID}")
11+
message(STATUS "Compiler: ${CMAKE_Fortran_COMPILER}")
12+
13+
set(CMAKE_FORTRAN_STANDARD 08)
14+
set(CMAKE_FORTRAN_STANDARD_REQUIRED ON)
15+
set(CMAKE_FORTRAN_EXTENSIONS OFF)
16+
1717
if( CMAKE_Fortran_COMPILER_ID MATCHES "GNU" )
1818
include( compiler_flags_GNU_Fortran )
19+
1920
elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
20-
include( compiler_flags_Intel_Fortran )
21+
if( CMAKE_Fortran_COMPILER MATCHES ".*ifx.*" )
22+
message(STATUS "Detected Intel ifx (LLVM-based) Fortran compiler")
23+
include( compiler_flags_IntelLLVM_Fortran ) # <-- new file for ifx
24+
else()
25+
message(STATUS "Detected Intel ifort (classic) Fortran compiler")
26+
include( compiler_flags_Intel_Fortran )
27+
endif()
28+
29+
elseif( CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC" )
30+
include( compiler_flags_NVHPC_Fortran )
31+
2132
elseif( CMAKE_Fortran_COMPILER_ID MATCHES "XL" )
2233
include( compiler_flags_XL_Fortran )
34+
2335
elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Cray" )
2436
include( compiler_flags_Cray_Fortran )
37+
2538
else()
26-
message( STATUS "Fortran compiler with ID ${CMAKE_CXX_COMPILER_ID} will be used with CMake default options")
39+
message( STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options")
2740
endif()
28-

0 commit comments

Comments
 (0)