Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
12dd036
WIP: added lam gpu sources
ddegrauwe Jun 16, 2025
162449b
WIP lam library now compiles; removed adjoint code for GPU
ddegrauwe Jun 16, 2025
8cfa23b
WIP. Fixed CMakeLists.txt to fix gpu compilation. Modified hicfft to …
ddegrauwe Jun 17, 2025
1f1eb19
fixes
ddegrauwe Jun 18, 2025
b8be65c
WIP: CRASHES WITH SIGSEGV. Using constant-address arrays for fft (nec…
ddegrauwe Jun 20, 2025
a8256ba
in-place fft in eftdir. Works when cuda graphs are disabled.
ddegrauwe Jun 23, 2025
d937912
in-place fft in eledir; optimized buffered allocation in eltdir
ddegrauwe Jun 23, 2025
5bd5bea
in-place fft in eleinv
ddegrauwe Jun 23, 2025
7c68b91
in-place fft in eftinv
ddegrauwe Jun 23, 2025
d2bd7e6
Disable combination of ETRANS and GPU_GRAPHS_FFT, which doesn't work
ddegrauwe Jun 23, 2025
d19a1e1
created common (single/double, cpu/gpu) folder for LAM transforms.
ddegrauwe Jun 23, 2025
163de4e
small fix for single-precision
ddegrauwe Jun 24, 2025
d23dd7f
Merge branch 'develop' into lam_gpu
ddegrauwe Jun 24, 2025
5f73b25
restore compilation options
ddegrauwe Jun 24, 2025
a295ca0
Update src/programs/CMakeLists.txt
ddegrauwe Jun 24, 2025
62b6d04
removed tabs
ddegrauwe Jun 24, 2025
3d0d329
removed tabs
ddegrauwe Jun 24, 2025
51f884b
more cosmetics
ddegrauwe Jun 24, 2025
1146a8f
Apply suggestions from code review
ddegrauwe Jul 2, 2025
df3fd51
Merge remote-tracking branch 'origin/develop' into tmp
ddegrauwe Jul 2, 2025
3b37fd9
include etrans in transi private libs
ddegrauwe Jul 2, 2025
d606ec1
Apply more suggestions from code review
ddegrauwe Jul 2, 2025
8f05fe7
Even more suggestions from review
ddegrauwe Jul 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,15 @@ ecbuild_add_option( FEATURE GPU_STATIC
DEFAULT ${GPU_STATIC_DEFAULT}
DESCRIPTION "Compile GPU library as static library")

# Note: ETRANS GPU does not support OpenMP yet or FFT graphs yet
ecbuild_add_option( FEATURE ETRANS
DEFAULT OFF
CONDITION NOT HAVE_GPU OR ( HAVE_ACC AND NOT HAVE_GPU_GRAPHS_FFT)
DESCRIPTION "Include Limited-Area-Model Transforms" )



ecbuild_add_option( FEATURE ECTRANS4PY
DEFAULT OFF
CONDITION HAVE_ETRANS AND HAVE_DOUBLE_PRECISION
CONDITION HAVE_ETRANS AND HAVE_DOUBLE_PRECISION
DESCRIPTION "Compile ectrans4py interface routines for python binding w/ ctypesForFortran" )


Expand Down
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

add_subdirectory( trans )
add_subdirectory( programs )
if( HAVE_TRANSI )
add_subdirectory(transi)
endif()
if( HAVE_ETRANS )
add_subdirectory(etrans)
endif()
if( HAVE_TRANSI )
add_subdirectory(transi)
endif()
if(HAVE_ECTRANS4PY)
add_subdirectory(ectrans4py)
endif()
60 changes: 5 additions & 55 deletions src/etrans/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# (C) Copyright 2020- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
Expand Down Expand Up @@ -66,7 +64,7 @@ function(generate_backend_includes)
get_filename_component(outfile_name_we ${file_i} NAME_WE)
get_filename_component(outfile_ext ${file_i} EXT)
get_filename_component(outfile_dir ${file_i} DIRECTORY)
if (${file_i} IN_LIST ectrans_common_includes)
if (${file_i} IN_LIST ectrans_lam_common_includes)
configure_file(${_PAR_INCLUDE_DIRECTORY}/${file_i} ${destination}/${outfile_name})
else()
set(outfile "${destination}/${outfile_name_we}_${backend}${outfile_ext}")
Expand Down Expand Up @@ -94,61 +92,13 @@ function(generate_backend_includes)
target_include_directories(${_PAR_TARGET} INTERFACE $<BUILD_INTERFACE:${destination}>)
endfunction(generate_backend_includes)





# TODO: move precision-independent files to common
#add_subdirectory( common )
add_subdirectory( common )

if( HAVE_CPU)
add_subdirectory( cpu )
endif()

# placeholder
#if( HAVE_GPU )
# add_subdirectory( gpu )
#endif()


if (FALSE)
# original cmake file for etrans; keeping it for reference, but should be cleaned later
message(FATAL_ERROR "Hold it right there!")

# build list of sources to add to trans library
# (using CMAKE_CURRENT_SOURCE_DIR is necessary because sources are in a different directory than the target library (trans_${prec})
ecbuild_list_add_pattern( LIST etrans_src
GLOB
${CMAKE_CURRENT_SOURCE_DIR}/biper/internal/*
${CMAKE_CURRENT_SOURCE_DIR}/biper/external/*
${CMAKE_CURRENT_SOURCE_DIR}/etrans/internal/*
${CMAKE_CURRENT_SOURCE_DIR}/etrans/external/*
QUIET
)

# dummies to be able to loop over precisions
set( HAVE_dp ${HAVE_DOUBLE_PRECISION} )
set( HAVE_sp ${HAVE_SINGLE_PRECISION} )

# loop over precisions
foreach( prec sp dp )
if( HAVE_${prec} )
# add sources
target_sources(trans_${prec} PRIVATE ${etrans_src})
# add include directories
target_include_directories(trans_${prec}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/biper/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/etrans/include>
)
endif()
endforeach()

# install headers
file( GLOB etrans_interface biper/include/* etrans/include/*)
install(
FILES ${etrans_interface}
DESTINATION include/ectrans
)

endif()
if( HAVE_GPU )
add_subdirectory( gpu )
endif()
44 changes: 44 additions & 0 deletions src/etrans/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# (C) Copyright 2020- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

## Sources which are precision independent can go into a common library
list( APPEND ectrans_lam_common_src
internal/tpmald_distr.F90
internal/tpmald_dim.F90
internal/esetup_dims_mod.F90
internal/esetup_geom_mod.F90
internal/suemplat_mod.F90
internal/suemplatb_mod.F90
internal/ellips.F90
)
list( APPEND ectrans_lam_common_includes
)

ecbuild_add_library(
TARGET ectrans_lam_common
LINKER_LANGUAGE Fortran
SOURCES ${ectrans_lam_common_src}
PUBLIC_LIBS fiat ectrans_common
PRIVATE_LIBS ${LAPACK_LIBRARIES}
PUBLIC_INCLUDES $<INSTALL_INTERFACE:include/ectrans>
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/trans/include/ectrans>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/trans/include>
)
ectrans_target_fortran_module_directory(
TARGET ectrans_lam_common
MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/module/ectrans
INSTALL_DIRECTORY module/ectrans
)

if( HAVE_OMP )
ecbuild_debug("target_link_libraries( ectrans_common PRIVATE OpenMP::OpenMP_Fortran )")
target_link_libraries( ectrans_lam_common PRIVATE OpenMP::OpenMP_Fortran )
endif()

set( ectrans_lam_common_includes ${ectrans_lam_common_includes} PARENT_SCOPE )
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

! Jan-2011 P. Marguinaud Interface to thread-safe FA
SUBROUTINE ELLIPS (KSMAX,KMSMAX,KNTMP,KMTMP)
USE PARKIND1, ONLY : JPRD, JPIM
USE EC_PARKIND, ONLY : JPRD, JPIM
USE YOMHOOK , ONLY : LHOOK, DR_HOOK, JPHOOK
IMPLICIT NONE
!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MODULE ESETUP_DIMS_MOD
CONTAINS
SUBROUTINE ESETUP_DIMS

USE PARKIND1 ,ONLY : JPIM ,JPRB
USE EC_PARKIND ,ONLY : JPIM
USE YOMHOOK ,ONLY : LHOOK, DR_HOOK, JPHOOK

USE TPM_DIM ,ONLY : R
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MODULE ESETUP_GEOM_MOD
CONTAINS
SUBROUTINE ESETUP_GEOM

USE PARKIND1 ,ONLY : JPIM ,JPRB
USE EC_PARKIND ,ONLY : JPIM
USE YOMHOOK ,ONLY : LHOOK, DR_HOOK, JPHOOK

USE TPM_GEN ,ONLY : NOUT, NPRINTLEV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ SUBROUTINE SUEMPLAT(KDGL,KPROC,KPROCA,KMYSETA,LDSPLIT,LDEQ_REGIONS,&
! R. El Khatib 09-Aug-2013 Allow LEQ_REGIONS
! ------------------------------------------------------------------

USE PARKIND1 ,ONLY : JPIM ,JPRB, JPRD
USE EC_PARKIND ,ONLY : JPIM ,JPRD
USE YOMHOOK ,ONLY : LHOOK, DR_HOOK, JPHOOK

USE TPM_GEN ,ONLY : NOUT, NPRINTLEV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ SUBROUTINE SUEMPLATB(KDGSA,KDGL,KPROCA,KLOENG,LDSPLIT,&
! A.Bogatchev 21-Sep-2010 phasing CY37
! ------------------------------------------------------------------

USE PARKIND1 ,ONLY : JPIM ,JPRB, JPRD
USE EC_PARKIND ,ONLY : JPIM, JPRD
USE YOMHOOK ,ONLY : LHOOK, DR_HOOK, JPHOOK

USE ABORT_TRANS_MOD ,ONLY : ABORT_TRANS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MODULE TPMALD_DIM

! Module for dimensions.

USE PARKIND1 ,ONLY : JPIM ,JPRB
USE EC_PARKIND ,ONLY : JPIM, JPIB

IMPLICIT NONE

Expand All @@ -26,6 +26,13 @@ MODULE TPMALD_DIM
INTEGER(KIND=JPIM) :: NDGLSUR ! Number of rows of latitudes+...
INTEGER(KIND=JPIM) :: NMSMAX ! Zonal truncation
INTEGER(KIND=JPIM) :: NDGUX ! Number of rows in zone C+I

! arguments to pass to EXECUTE_FFT: kept here to make sure their addresses are constant (necessary for cuda graphs)
INTEGER(KIND=JPIM) :: NLOENS_LON(1)
INTEGER(KIND=JPIB) :: NOFFSETS_LON(2)
INTEGER(KIND=JPIM) :: NLOENS_LAT(1)
INTEGER(KIND=JPIB) :: NOFFSETS_LAT(2)

END TYPE ALDDIM_TYPE

TYPE(ALDDIM_TYPE),ALLOCATABLE,TARGET :: ALDDIM_RESOL(:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MODULE TPMALD_DISTR

! Module for distributed memory environment.

USE PARKIND1 ,ONLY : JPIM ,JPRB
USE EC_PARKIND ,ONLY : JPIM

IMPLICIT NONE

Expand Down
24 changes: 12 additions & 12 deletions src/etrans/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function(generate_backend_sources)
internal/*.F90
external/*.F90
biper/internal/*.F90
biper/external/*.F90
biper/external/*.F90
QUIET
)

Expand All @@ -50,20 +50,20 @@ set( BUILD_INTERFACE_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include/ectrans )
foreach( prec dp sp )
if( HAVE_${prec} )

generate_backend_includes(BACKEND ${prec} TARGET ectrans_etrans_${prec}_includes DESTINATION ${BUILD_INTERFACE_INCLUDE_DIR} INCLUDE_DIRECTORY ${PROJECT_SOURCE_DIR}/src/etrans/include )
generate_backend_sources( BACKEND ${prec} OUTPUT ectrans_etrans_${prec}_src DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/generated/ectrans_etrans_${prec})
generate_backend_includes(BACKEND ${prec} TARGET ectrans_lam_${prec}_includes DESTINATION ${BUILD_INTERFACE_INCLUDE_DIR} INCLUDE_DIRECTORY ${PROJECT_SOURCE_DIR}/src/etrans/include )
generate_backend_sources( BACKEND ${prec} OUTPUT ectrans_lam_${prec}_src DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/generated/ectrans_lam_${prec})
ecbuild_add_library(
TARGET ectrans_etrans_${prec}
TARGET ectrans_lam_${prec}
LINKER_LANGUAGE Fortran
SOURCES ${ectrans_etrans_${prec}_src}
SOURCES ${ectrans_lam_${prec}_src}
PUBLIC_INCLUDES $<INSTALL_INTERFACE:include/ectrans>
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${BUILD_INTERFACE_INCLUDE_DIR}>
PUBLIC_LIBS fiat ectrans_common ectrans_${prec}_includes ectrans_${prec} ectrans_etrans_${prec}_includes
PUBLIC_LIBS fiat ectrans_common ectrans_${prec}_includes ectrans_${prec} ectrans_lam_common ectrans_lam_${prec}_includes
)

ectrans_target_fortran_module_directory(
TARGET ectrans_etrans_${prec}
TARGET ectrans_lam_${prec}
MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/module/ectrans
INSTALL_DIRECTORY module/ectrans
)
Expand All @@ -75,23 +75,23 @@ foreach( prec dp sp )
set( FFTW_LINK PUBLIC ) # Attempt anyway to give FFTW precedence
endif()
ecbuild_debug("target_link_libraries( trans_${prec} ${FFTW_LINK} ${FFTW_LIBRARIES} )")
target_link_libraries( ectrans_etrans_${prec} ${FFTW_LINK} ${FFTW_LIBRARIES} )
target_include_directories( ectrans_etrans_${prec} PRIVATE ${FFTW_INCLUDE_DIRS} )
target_compile_definitions( ectrans_etrans_${prec} PRIVATE WITH_FFTW )
target_link_libraries( ectrans_lam_${prec} ${FFTW_LINK} ${FFTW_LIBRARIES} )
target_include_directories( ectrans_lam_${prec} PRIVATE ${FFTW_INCLUDE_DIRS} )
target_compile_definitions( ectrans_lam_${prec} PRIVATE WITH_FFTW )
# daand: lam transforms don't need lapack
#ecbuild_debug("target_link_libraries( ectrans_etrans_${prec} PRIVATE ${LAPACK_LIBRARIES} )")
#target_link_libraries( ectrans_${prec} PRIVATE ${LAPACK_LIBRARIES} )

if( HAVE_OMP )
ecbuild_debug("target_link_libraries( ectrans_${prec} PRIVATE OpenMP::OpenMP_Fortran )")
target_link_libraries( ectrans_${prec} PRIVATE OpenMP::OpenMP_Fortran )
target_link_libraries( ectrans_lam_${prec} PRIVATE OpenMP::OpenMP_Fortran )
endif()

# This interface library is for backward compatibility, and provides the older includes
ecbuild_add_library( TARGET etrans_${prec} TYPE INTERFACE )
target_include_directories( etrans_${prec} INTERFACE $<BUILD_INTERFACE:${BUILD_INTERFACE_INCLUDE_DIR}/etrans_${prec}> )
target_include_directories( etrans_${prec} INTERFACE $<INSTALL_INTERFACE:include/ectrans/etrans_${prec}> )
target_link_libraries( trans_${prec} INTERFACE fiat etrans_${prec} ectrans_etrans_${prec} parkind_${prec})
target_link_libraries( etrans_${prec} INTERFACE ectrans_lam_${prec}) # seems ok to omit fiat, parkind, trans here.
endif()
endforeach()

Expand Down
14 changes: 0 additions & 14 deletions src/etrans/cpu/internal/edist_spec_control_mod.F90

This file was deleted.

14 changes: 0 additions & 14 deletions src/etrans/cpu/internal/espnormc_mod.F90

This file was deleted.

Loading
Loading