Skip to content

Commit

Permalink
Merge pull request #403 from GEOS-ESM/develop
Browse files Browse the repository at this point in the history
GitFlow: Merge develop to main for release
  • Loading branch information
mathomp4 authored Sep 5, 2024
2 parents 0d6e65c + d99a1dc commit e735539
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Deprecated

## [4.6.0] - 2024-09-05

### Added

- Add `FindJeMalloc.cmake` for use with builds of GEOSgcm
- Add preliminary LLVMFlang support

## [4.5.0] - 2024-08-12

### Changed
Expand Down
97 changes: 97 additions & 0 deletions compiler/flags/LLVMFlang_Fortran.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 20)
message(FATAL_ERROR "${CMAKE_Fortran_COMPILER_ID} version must be at least 20!")
endif()

set (FOPT0 "-O0")
set (FOPT1 "-O1")
set (FOPT2 "-O2")
set (FOPT3 "-O3")
set (FOPT4 "-O4")
set (DEBINFO "-g")

set (FPE0 "")
set (FPE3 "")
set (FP_MODEL_SOURCE "")
set (FP_MODEL_STRICT "")
set (FP_MODEL_CONSISTENT "")

set (OPTREPORT0 "")
set (OPTREPORT5 "")

set (FREAL8 "-fdefault-real-8 -fdefault-double-8")
set (FINT8 "-fdefault-integer-8")
set (UNUSED_DUMMY "")
set (PP "-cpp")

#set (BIG_ENDIAN "-fconvert=swap") # This doesn't seem to work at the moment
#set (LITTLE_ENDIAN "") # Not sure
set (EXTENDED_SOURCE "-ffixed-line-length-132")
set (FIXED_SOURCE "-ffixed-form")
set (MCMODEL "")
set (TRACEBACK "")
set (NOOLD_MAXMINLOC "")
set (REALLOC_LHS "")
set (ARCH_CONSISTENCY "")
set (FTZ "")
set (ALIGN_ALL "")
set (NO_ALIAS "")

set (NO_RANGE_CHECK "")

cmake_host_system_information(RESULT proc_description QUERY PROCESSOR_DESCRIPTION)

# NOT SURE ABOUT ANY OF THIS...
if ( ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL aarch64 )
set (FLANG_TARGET_ARCH "-mcpu=armv8.2-a+crypto+crc+fp16+rcpc+dotprod")
elseif (${proc_description} MATCHES "Apple M")
set (FLANG_TARGET_ARCH "-mcpu=apple-m1")
elseif (${proc_description} MATCHES "EPYC")
set (FLANG_TARGET_ARCH "-mcpu=znver2")
elseif (${proc_description} MATCHES "Intel")
set (FLANG_TARGET_ARCH "-mcpu=haswell")
elseif ( ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64" )
message(WARNING "Unknown processor type. Defaulting to a generic x86_64 processor. Performance may be suboptimal.")
set (FLANG_TARGET_ARCH "x86-64")
else ()
message(FATAL_ERROR "Unknown processor. Please file an issue at https://github.com/GEOS-ESM/ESMA_cmake")
endif ()

# ...SO WE JUST TURN OFF FLANG_TARGET_ARCH FOR NOW
set (FLANG_TARGET_ARCH "")

####################################################

# Common Fortran Flags
# --------------------
set (common_Fortran_flags "${NO_RANGE_CHECK} ${TRACEBACK} ${UNUSED_DUMMY}" )
set (common_Fortran_fpe_flags "${TRACEBACK}")

# GEOS Debug
# ----------
set (GEOS_Fortran_Debug_Flags "${FOPT0} ${DEBINFO}")
set (GEOS_Fortran_Debug_FPE_Flags "${common_Fortran_fpe_flags}")

# GEOS Release
# ------------
set (GEOS_Fortran_Release_Flags "${FOPT3} ${FLANG_TARGET_ARCH} ${DEBINFO}")
set (GEOS_Fortran_Release_FPE_Flags "${common_Fortran_fpe_flags}")

# Create a NoVectorize version for consistency. No difference from Release for GNU

# GEOS NoVectorize
# ----------------
set (GEOS_Fortran_NoVect_Flags "${GEOS_Fortran_Release_Flags}")
set (GEOS_Fortran_NoVect_FPE_Flags "${GEOS_Fortran_Release_FPE_Flags}")

# GEOS Vectorize
# --------------

# Until good options can be found, make vectorize equal common flags
set (GEOS_Fortran_Vect_Flags ${GEOS_Fortran_Release_Flags})
set (GEOS_Fortran_Vect_FPE_Flags ${GEOS_Fortran_Release_FPE_Flags})

set (GEOS_Fortran_Aggressive_Flags "${GEOS_Fortran_Release_Flags}")
set (GEOS_Fortran_Aggressive_FPE_Flags "${GEOS_Fortran_Release_FPE_Flags}")

# Common variables for every compiler
include(Generic_Fortran)
29 changes: 29 additions & 0 deletions external_libraries/FindJeMalloc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# - Find JeMalloc library
# Find the native JeMalloc includes and library
#
# JeMalloc_INCLUDE_DIRS - where to find jemalloc.h, etc.
# JeMalloc_LIBRARIES - List of libraries when using jemalloc.
# JeMalloc_FOUND - True if jemalloc found.

find_path(JeMalloc_INCLUDE_DIRS
NAMES jemalloc/jemalloc.h
HINTS ${JEMALLOC_ROOT_DIR}/include ENV JEMALLOC_INCLUDE_DIR)

find_library(JeMalloc_LIBRARIES
NAMES jemalloc
HINTS ${JEMALLOC_ROOT_DIR}/lib ENV JEMALLOC_LIB_DIR)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(JeMalloc DEFAULT_MSG JeMalloc_LIBRARIES JeMalloc_INCLUDE_DIRS)

mark_as_advanced(
JeMalloc_LIBRARIES
JeMalloc_INCLUDE_DIRS)

if(JeMalloc_FOUND AND NOT (TARGET JeMalloc::JeMalloc))
add_library (JeMalloc::JeMalloc UNKNOWN IMPORTED)
set_target_properties(JeMalloc::JeMalloc
PROPERTIES
IMPORTED_LOCATION ${JeMalloc_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${JeMalloc_INCLUDE_DIRS})
endif()

0 comments on commit e735539

Please sign in to comment.