Skip to content

Commit

Permalink
Merge pull request #62 from twhite-cray/cray
Browse files Browse the repository at this point in the history
Added support for HPE Cray Fortran.
  • Loading branch information
domcharrier authored Sep 1, 2021
2 parents c854323 + d34a938 commit 0db4858
Show file tree
Hide file tree
Showing 6 changed files with 867 additions and 12 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,16 @@ ENDIF(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F08)
#OPTION(USE_MPI "Use the MPI library for parallelization" OFF)
#OPTION(USE_OPENMP "Use OpenMP for parallelization" OFF)

IF(CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${HIPFORT_COMPILER_FLAGS}")
ELSE(CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
IF(CMAKE_Fortran_COMPILER_SUPPORTS_F08)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${HIPFORT_COMPILER_FLAGS} -std=f2008")
ELSE(CMAKE_Fortran_COMPILER_SUPPORTS_F08)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${HIPFORT_COMPILER_FLAGS} -std=f2003")
ENDIF(CMAKE_Fortran_COMPILER_SUPPORTS_F08)

ENDIF(CMAKE_Fortran_COMPILER_ID MATCHES "Cray")

# Set compile flags for DEBUG, # RELEASE, or TESTING.
INCLUDE(${CMAKE_MODULE_PATH}/SetFortranFlags.cmake)
message("-- Done setting FortranFlags")
Expand Down
7 changes: 6 additions & 1 deletion bin/hipfc
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,12 @@ if [ "$UNAMEP" == "ppc64le" ] ; then
HOST_TARGET="ppc64le-linux-gnu"
fi

FCARGS="-cpp -I$HIPFORT/include/$TARGET_ARCH"
if [[ "$HIPFORT_COMPILER" == *"ftn" ]] ; then
FCARGS="-eT -J$HIPFORT/include/$TARGET_ARCH"
else
FCARGS="-cpp -I$HIPFORT/include/$TARGET_ARCH"
fi

if [ $GEN_OBJECT_ONLY ] ; then
FCARGS=" -c $FCARGS"
HIPCC_OPTS=" -c $HIPCC_OPTS"
Expand Down
12 changes: 12 additions & 0 deletions cmake/Modules/SetFortranFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ ENDIF(CMAKE_Fortran_FLAGS_RELEASE AND CMAKE_Fortran_FLAGS_TESTING AND CMAKE_Fort
### GENERAL FLAGS ###
#####################

IF(NOT CMAKE_Fortran_COMPILER_ID MATCHES "Cray")

# Don't add underscores in symbols for C-compatability
SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}"
Fortran "-fno-underscoring")
Expand All @@ -69,6 +71,8 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}"
"-ta=host" # Portland Group
)

ENDIF(NOT CMAKE_Fortran_COMPILER_ID MATCHES "Cray")

###################
### DEBUG FLAGS ###
###################
Expand All @@ -84,22 +88,26 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}"
# Turn on all warnings
SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}"
Fortran "-warn all" # Intel
"-m2" # HPE Cray
"/warn:all" # Intel Windows
"-Wall" # GNU
# Portland Group (on by default)
)

# Traceback
IF(NOT CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}"
Fortran "-traceback" # Intel/Portland Group
"/traceback" # Intel Windows
"-fbacktrace" # GNU (gfortran)
"-ftrace=full" # GNU (g95)
)
ENDIF(NOT CMAKE_Fortran_COMPILER_ID MATCHES "Cray")

# Check array bounds
SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}"
Fortran "-check bounds" # Intel
"-hbounds" # HPE Cray
"/check:bounds" # Intel Windows
"-fcheck=bounds" # GNU (New style)
"-fbounds-check" # GNU (Old style)
Expand All @@ -122,6 +130,8 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_TESTING "${CMAKE_Fortran_FLAGS_TESTING}"

# NOTE: agressive optimizations (-O3) are already turned on by default

IF(NOT CMAKE_Fortran_COMPILER_ID MATCHES "Cray")

# Unroll loops
SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}"
Fortran "-funroll-loops" # GNU
Expand Down Expand Up @@ -158,3 +168,5 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}"
"/Qvec-report0" # Intel Windows
"-Mvect" # Portland Group
)

ENDIF(NOT CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
2 changes: 2 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

IF(NOT CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-underscoring")
ENDIF(NOT CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
file(GLOB HIPFORT_SRC_HIP "${CMAKE_CURRENT_SOURCE_DIR}/hipfort/*.f*")
#file(GLOB HIPFORT_SRC_amdgcn "${CMAKE_CURRENT_SOURCE_DIR}/modules-amdgcn/*.f*")
#file(GLOB HIPFORT_SRC_nvptx "${CMAKE_CURRENT_SOURCE_DIR}/modules-nvptx/*.f*")
Expand Down
Loading

0 comments on commit 0db4858

Please sign in to comment.