Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with new Scheduler #14

Merged
merged 6 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions arch/github/ubuntu/gnu/9.4.0/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Source me to get the correct configure/build/run environment

export CC=gcc-9
export CXX=g++-9
export FC=gfortran-9
export F77=gfortran-9
export F90=gfortran-9

export ECBUILD_TOOLCHAIN="./toolchain.cmake"
1 change: 1 addition & 0 deletions arch/github/ubuntu/gnu/9.4.0/toolchain.cmake
28 changes: 28 additions & 0 deletions arch/toolchains/github-ubuntu-gnu.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# (C) Copyright 1988- 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.

####################################################################
# COMPILER
####################################################################

set( ECBUILD_FIND_MPI ON )
set( ENABLE_ACC OFF CACHE STRING "" )

####################################################################
# Compiler FLAGS
####################################################################

# General Flags (add to default)
set(ECBUILD_Fortran_FLAGS "${ECBUILD_Fortran_FLAGS} -ffpe-trap=invalid,zero,overflow")
set(ECBUILD_Fortran_FLAGS "${ECBUILD_Fortran_FLAGS} -fstack-arrays")
set(ECBUILD_Fortran_FLAGS "${ECBUILD_Fortran_FLAGS} -fconvert=big-endian")
set(ECBUILD_Fortran_FLAGS "${ECBUILD_Fortran_FLAGS} -fbacktrace")
set(ECBUILD_Fortran_FLAGS "${ECBUILD_Fortran_FLAGS} -fno-second-underscore")
set(ECBUILD_Fortran_FLAGS "${ECBUILD_Fortran_FLAGS} -ffast-math")
set(ECBUILD_Fortran_FLAGS "${ECBUILD_Fortran_FLAGS} -fno-unsafe-math-optimizations")
set(ECBUILD_Fortran_FLAGS "${ECBUILD_Fortran_FLAGS} -foffload=disable")
8 changes: 2 additions & 6 deletions bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ cmake : >
projects :

- ecbuild :
git : https://github.com/ecmwf/ecbuild
version : 3.7.0
git : https://github.com/ecmwf/ecbuild
version : 3.7.0
bundle : false

- loki :
Expand Down Expand Up @@ -52,10 +52,6 @@ options :
help : Frontend parser to use for Loki transformations
cmake : LOKI_FRONTEND={{value}}

- cloudsc-fortran :
help : Build the new Fortran version of CLOUDSC [ON|OFF]
cmake : ENABLE_CLOUDSC_FORTRAN={{value}}

- cloudsc2-nl-loki :
help : Build the optimized Loki-based GPU version CLOUDSC2-NL [ON|OFF]
cmake : ENABLE_CLOUDSC2_NL_LOKI={{value}}
Expand Down
17 changes: 11 additions & 6 deletions cloudsc-bundle
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/usr/bin/env bash

# (C) Copyright 1988- 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.


# BOOTSTRAP ecbundle-build or ecbundle-create,
# and pass arguments to it.

Expand All @@ -9,7 +18,7 @@ if [[ $# -eq 0 ]]; then
exit 1
fi

export ecbundle_VERSION=develop
export ecbundle_VERSION=2.0.0

# Which script do we run?
# Partial matches are accepted, e.g. "$0 cr"
Expand All @@ -25,15 +34,11 @@ shift

BUNDLE_DIR="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"

if [[ -z "${BITBUCKET}" ]]; then
export BITBUCKET=ssh://[email protected]
fi

# Download ecbundle scripts if not already available
command_exists () { type "$1" &> /dev/null ; }
if ! command_exists ${BOOTSTRAPPED} ; then
if [[ ! -d ${BUNDLE_DIR}/ecbundle ]]; then
git clone ${BITBUCKET}/escape/ecbundle.git ${BUNDLE_DIR}/ecbundle
git clone https://github.com/ecmwf/ecbundle.git ${BUNDLE_DIR}/ecbundle
( cd ${BUNDLE_DIR}/ecbundle && git checkout ${ecbundle_VERSION} )
fi
export PATH=${BUNDLE_DIR}/ecbundle/bin:${PATH}
Expand Down
118 changes: 74 additions & 44 deletions src/cloudsc2_ad_loki/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,27 @@ if( HAVE_CLOUDSC2_AD_LOKI )
## * Internal "do-nothing" mode for Loki debug ##
####################################################


loki_transform_convert(
MODE idem FRONTEND ${LOKI_FRONTEND}
CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/cloudsc_loki.config
PATH ${CMAKE_CURRENT_SOURCE_DIR}
HEADERS ${COMMON_MODULE}/yomphyder.F90
INCLUDES ${COMMON_INCLUDE}
OUTPATH ${CMAKE_CURRENT_BINARY_DIR}/loki-idem
loki_transform(
COMMAND convert
OUTPUT
loki-idem/satur.idem.F90
loki-idem/cloudsc2ad.idem.F90
loki-idem/cloudsc2tl.idem.F90
loki-idem/cloudsc_driver_ad_loki_mod.idem.F90
DEPENDS satur.F90 cloudsc2ad.F90 cloudsc2tl.F90 cloudsc_driver_ad_loki_mod.F90
loki-idem/satur.idem.F90
loki-idem/cloudsc2ad.idem.F90
loki-idem/cloudsc2tl.idem.F90
loki-idem/cloudsc_driver_ad_loki_mod.idem.F90
BUILDDIR ${CMAKE_CURRENT_BINARY_DIR}/loki-idem
DEPENDS
satur.F90
cloudsc2ad.F90
cloudsc2tl.F90
cloudsc_driver_ad_loki_mod.F90
MODE idem
CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/cloudsc_loki.config
FRONTEND ${LOKI_FRONTEND}
SOURCES
${CMAKE_CURRENT_SOURCE_DIR}
${COMMON_MODULE}
INCLUDES
${COMMON_INCLUDE}
)

ecbuild_add_executable( TARGET dwarf-cloudsc2-ad-loki-idem
Expand All @@ -52,7 +59,7 @@ if( HAVE_CLOUDSC2_AD_LOKI )
ecbuild_add_test(
TARGET dwarf-cloudsc2-ad-loki-idem-serial
COMMAND bin/dwarf-cloudsc2-ad-loki-idem
ARGS
ARGS
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../..
OMP 1
)
Expand All @@ -63,24 +70,35 @@ if( HAVE_CLOUDSC2_AD_LOKI )
## * Invokes compute kernel as `!$acc vector` ##
####################################################

loki_transform(
COMMAND convert
OUTPUT
loki-scc/satur.scc.F90
loki-scc/cloudsc2ad.scc.F90
loki-scc/cloudsc2tl.scc.F90
loki-scc/cloudsc_driver_ad_loki_mod.scc.F90
BUILDDIR ${CMAKE_CURRENT_BINARY_DIR}/loki-scc
DEPENDS
satur.F90
cloudsc2ad.F90
cloudsc2tl.F90
cloudsc_driver_ad_loki_mod.F90
MODE scc
CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/cloudsc_loki.config
DATA_OFFLOAD
REMOVE_OPENMP
CPP
DEFINITIONS
${CLOUDSC_DEFINITIONS}
CLOUDSC_GPU_TIMING
FRONTEND ${LOKI_FRONTEND}
SOURCES
${CMAKE_CURRENT_SOURCE_DIR}
${COMMON_MODULE}
INCLUDES
${COMMON_INCLUDE}
)

loki_transform_convert(
MODE scc FRONTEND ${LOKI_FRONTEND} CPP
CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/cloudsc_loki.config
PATH ${CMAKE_CURRENT_SOURCE_DIR}
HEADERS ${COMMON_MODULE}/yomphyder.F90 ${COMMON_MODULE}/yoecldp.F90
INCLUDES ${COMMON_INCLUDE}
DEFINITIONS CLOUDSC_GPU_TIMING
DATA_OFFLOAD REMOVE_OPENMP
OUTPATH ${CMAKE_CURRENT_BINARY_DIR}/loki-scc
OUTPUT
loki-scc/satur.scc.F90
loki-scc/cloudsc2ad.scc.F90
loki-scc/cloudsc2tl.scc.F90
loki-scc/cloudsc_driver_ad_loki_mod.scc.F90
DEPENDS
satur.F90 cloudsc2ad.F90 cloudsc2tl.F90 cloudsc_driver_ad_loki_mod.F90
)
ecbuild_add_executable( TARGET dwarf-cloudsc2-ad-loki-scc
SOURCES
dwarf_cloudsc.F90
Expand All @@ -96,7 +114,7 @@ if( HAVE_CLOUDSC2_AD_LOKI )
ecbuild_add_test(
TARGET dwarf-cloudsc2-ad--loki-scc-serial
COMMAND bin/dwarf-cloudsc2-ad-loki-scc
ARGS
ARGS
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../..
OMP 1
ENVIRONMENT NV_ACC_CUDA_HEAPSIZE=9G
Expand All @@ -108,23 +126,35 @@ if( HAVE_CLOUDSC2_AD_LOKI )
## * Temporary arrays hoisted to driver ##
####################################################

loki_transform_convert(
MODE scc-hoist FRONTEND ${LOKI_FRONTEND} CPP
CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/cloudsc_loki.config
PATH ${CMAKE_CURRENT_SOURCE_DIR}
HEADERS ${COMMON_MODULE}/yomphyder.F90 ${COMMON_MODULE}/yoecldp.F90
INCLUDES ${COMMON_INCLUDE}
DEFINITIONS CLOUDSC_GPU_TIMING
DATA_OFFLOAD REMOVE_OPENMP
OUTPATH ${CMAKE_CURRENT_BINARY_DIR}/loki-scc-hoist
loki_transform(
COMMAND convert
OUTPUT
loki-scc-hoist/satur.scc_hoist.F90
loki-scc-hoist/cloudsc2ad.scc_hoist.F90
loki-scc-hoist/cloudsc2tl.scc_hoist.F90
loki-scc-hoist/cloudsc_driver_ad_loki_mod.scc_hoist.F90
BUILDDIR ${CMAKE_CURRENT_BINARY_DIR}/loki-scc-hoist
DEPENDS
satur.F90 cloudsc2ad.F90 cloudsc2tl.F90 cloudsc_driver_ad_loki_mod.F90
)
satur.F90
cloudsc2ad.F90
cloudsc2tl.F90
cloudsc_driver_ad_loki_mod.F90
MODE scc-hoist
CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/cloudsc_loki.config
DATA_OFFLOAD
REMOVE_OPENMP
CPP
DEFINITIONS
${CLOUDSC_DEFINITIONS}
CLOUDSC_GPU_TIMING
FRONTEND ${LOKI_FRONTEND}
SOURCES
${CMAKE_CURRENT_SOURCE_DIR}
${COMMON_MODULE}
INCLUDES
${COMMON_INCLUDE}
)

ecbuild_add_executable( TARGET dwarf-cloudsc2-ad-loki-scc-hoist
SOURCES
dwarf_cloudsc.F90
Expand All @@ -140,7 +170,7 @@ if( HAVE_CLOUDSC2_AD_LOKI )
ecbuild_add_test(
TARGET dwarf-cloudsc2-ad--loki-scc-hoist-serial
COMMAND bin/dwarf-cloudsc2-ad-loki-scc-hoist
ARGS
ARGS
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../..
OMP 1
ENVIRONMENT NV_ACC_CUDA_HEAPSIZE=9G
Expand Down
58 changes: 20 additions & 38 deletions src/cloudsc2_ad_loki/cloudsc_loki.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,29 @@ demote_locals = true

# Ensure that we are never adding these to the tree, and thus
# do not attempt to look up the source files for these.
# TODO: Add type-bound procedure support and adjust scheduler to it

disable = ['performance_timer%start', 'performance_timer%end', 'performance_timer%thread_start',
'performance_timer%thread_end', 'performance_timer%thread_log',
'performance_timer%thread_log', 'performance_timer%print_performance']
disable = ['timer_mod', 'file_io_mod', 'foe*', 'fes*', 'falfaad']

# Define entry point for call-tree transformation
[[routine]]
name = 'cloudsc_driver_ad'
expand = true
role = 'driver'
[routines]

[[routine]]
name = 'cloudsc2ad'
role = 'kernel'
expand = true
[routines.cloudsc_driver_ad]
role = 'driver'
expand = true

[[routine]]
name = 'cloudsc2tl'
role = 'kernel'
expand = true
# Define indices and bounds for array dimensions
[dimensions]

[[routine]]
name = 'satur'
role = 'kernel'
expand = true
##############################################

[[dimension]]
name = 'horizontal'
size = 'KLON'
index = 'JL'
bounds = ['KIDIA', 'KFDIA']
aliases = ['NPROMA', 'KDIM%KLON']

[[dimension]]
name = 'vertical'
size = 'KLEV'
index = 'JK'

[[dimension]]
name = 'block_dim'
size = 'NGPBLKS'
index = 'IBL'
[dimensions.horizontal]
size = 'KLON'
index = 'JL'
bounds = ['KIDIA', 'KFDIA']
aliases = ['NPROMA', 'KDIM%KLON']

[dimensions.vertical]
size = 'KLEV'
index = 'JK'

[dimensions.block_dim]
size = 'NGPBLKS'
index = 'IBL'
Loading