Skip to content

Commit

Permalink
Merge branch 'azamat/oneapi/update-linker-flags' (PR #6104)
Browse files Browse the repository at this point in the history
Update OneAPI linker flags

Update OneAPI linker flags to fix build issues.

[BFB]
  • Loading branch information
amametjanov committed Dec 21, 2023
2 parents d080e69 + a06b48c commit 09491ec
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions cime_config/machines/Depends.oneapi-ifx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# compile mpas_seaice_core_interface.f90 with ifort, not ifx
e3sm_add_flags("${CMAKE_BINARY_DIR}/core_seaice/model_forward/mpas_seaice_core_interface.f90" "-fc=ifort")
3 changes: 3 additions & 0 deletions cime_config/machines/Depends.oneapi-ifxgpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ list(APPEND MPAS_ADD_ACC_FLAGS
foreach(ITEM IN LISTS MPAS_ADD_ACC_FLAGS)
e3sm_add_flags("${ITEM}" "-fiopenmp -fopenmp-targets=spir64")
endforeach()

# compile mpas_seaice_core_interface.f90 with ifort, not ifx
e3sm_add_flags("${CMAKE_BINARY_DIR}/core_seaice/model_forward/mpas_seaice_core_interface.f90" "-fc=ifort")
5 changes: 3 additions & 2 deletions cime_config/machines/cmake_macros/oneapi-ifx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2")
string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created")
string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g")
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g")
string(APPEND CMAKE_C_FLAGS " -traceback -fp-model precise -std=gnu99")
string(APPEND CMAKE_CXX_FLAGS " -traceback -fp-model precise")
string(APPEND CMAKE_C_FLAGS " -fp-model precise -std=gnu99")
string(APPEND CMAKE_CXX_FLAGS " -fp-model precise")
string(APPEND CMAKE_Fortran_FLAGS " -traceback -convert big_endian -assume byterecl -assume realloc_lhs -fp-model precise")
string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRINTEL -DHAVE_SLASHPROC -DHIDE_MPI")
string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -fixed -132")
Expand All @@ -23,3 +23,4 @@ set(MPICXX "mpicxx")
set(SCC "icx")
set(SCXX "icpx")
set(SFC "ifx")
set(E3SM_LINK_WITH_FORTRAN "TRUE")
4 changes: 2 additions & 2 deletions cime_config/machines/cmake_macros/oneapi-ifxgpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2")
string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created")
string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -g")
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0 -g")
string(APPEND CMAKE_C_FLAGS " -traceback -fp-model precise -std=gnu99")
string(APPEND CMAKE_CXX_FLAGS " -traceback -fp-model precise")
string(APPEND CMAKE_C_FLAGS " -fp-model precise -std=gnu99")
string(APPEND CMAKE_CXX_FLAGS " -fp-model precise")
string(APPEND CMAKE_Fortran_FLAGS " -traceback -convert big_endian -assume byterecl -assume realloc_lhs -fp-model precise")
string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRINTEL -DHAVE_SLASHPROC -DHIDE_MPI")
string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -fixed -132")
Expand Down
7 changes: 6 additions & 1 deletion components/cmake/build_model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,17 @@ macro(build_model COMP_CLASS COMP_NAME)
set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE Fortran)

# A bit hacky, some platforms need help with the fortran linker
if (COMPILER STREQUAL "intel")
if (COMPILER STREQUAL "intel" OR COMPILER STREQUAL "oneapi-ifx")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -cxxlib")
endif()

else()
set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX)

if (COMPILER STREQUAL "oneapi-ifxgpu")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-\-defsym,main=MAIN_\_ -lifcore -\-intel -fsycl -lsycl -Xsycl-target-backend \"-device 12.60.7\" ")
endif()

endif()

else()
Expand Down

0 comments on commit 09491ec

Please sign in to comment.