Skip to content

Commit

Permalink
Loki: Remove CLAW from CMake and install script
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange05 committed Jan 18, 2025
1 parent 6843879 commit c6fac30
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 156 deletions.
17 changes: 1 addition & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# :NO_INSTALL: Do not install Loki itself but make the CMake configuration
# available (Default: ``OFF``)
# :EDITABLE: Install Loki as an editable package (Default: ``OFF``)
# :CLAW: Install CLAW and OMNI Compiler (Default: ``OFF``)
#
# Installation procedure
# ----------------------
Expand Down Expand Up @@ -69,16 +68,10 @@ ecbuild_add_option(
DEFAULT OFF
DESCRIPTION "Install Loki as an editable Python package"
)
ecbuild_add_option(
FEATURE CLAW
DEFAULT OFF
DESCRIPTION "Build OMNI compiler and CLAW compiler"
)
ecbuild_add_option(
FEATURE OMNI
DEFAULT OFF
DESCRIPTION "Build OMNI compiler as Loki frontend"
CONDITION NOT HAVE_CLAW
)

include( loki_transform )
Expand All @@ -99,11 +92,6 @@ endforeach()
# Install Loki and dependencies
if( NOT HAVE_NO_INSTALL )

if( HAVE_CLAW )
include( claw_compiler )
install_claw_compiler( mlange-dev )
endif()

if( HAVE_OMNI )
include( omni_compiler )
install_omni_compiler( master )
Expand All @@ -119,10 +107,7 @@ if( NOT HAVE_NO_INSTALL )
# Enable Pytest tests as ecbuild/ctest targets
if( HAVE_TESTS )

if( HAVE_CLAW )
set( _TEST_SELECTOR "not ofp" )
set( _TEST_PATH "${CLAW_DIR}/bin:$ENV{PATH}" )
elseif( HAVE_OMNI )
if( HAVE_OMNI )
set( _TEST_SELECTOR "not ofp" )
set( _TEST_PATH "${OMNI_DIR}/bin:$ENV{PATH}" )
else()
Expand Down
84 changes: 2 additions & 82 deletions cmake/loki_transform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function( loki_transform_target )
# Mark the generated stuff as build-time generated
set_source_files_properties( ${LOKI_SOURCES_TO_APPEND} PROPERTIES GENERATED TRUE )

# Add the Loki-generated sources to our target (CLAW is not called)
# Add the Loki-generated sources to our target
target_sources( ${_PAR_T_TARGET} PRIVATE ${LOKI_SOURCES_TO_APPEND} )
endif()

Expand All @@ -350,79 +350,6 @@ function( loki_transform_target )

endfunction()

##############################################################################
# .rst:
#
# claw_compile
# ============
#
# Call the CLAW on a file.::
#
# claw_compile(
# OUTPUT <outfile>
# SOURCE <source>
# MODEL_CONFIG <config>
# TARGET <cpu|gpu>
# DIRECTIVE <openmp|openacc|none>
# [INCLUDE <include1> [<include2> ...]]
# [XMOD <xmod-dir1> [<xmod-dir2> ...]]
# [DEPENDS <dependency1> [<dependency2> ...]]
# )
#
##############################################################################
function( claw_compile )

set( options )
set( oneValueArgs MODEL_CONFIG TARGET DIRECTIVE SOURCE OUTPUT )
set( multiValueArgs INCLUDE XMOD DEPENDS )

cmake_parse_arguments( _PAR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )

if( NOT _PAR_SOURCE )
ecbuild_critical( "No SOURCE given for claw_compile()" )
endif()

if( NOT _PAR_OUTPUT )
ecbuild_critical( "No OUTPUT given for claw_compile()" )
endif()

set( _ARGS )

if( _PAR_MODEL_CONFIG )
list( APPEND _ARGS --model-config=${_PAR_MODEL_CONFIG})
endif()

if( NOT _PAR_TARGET )
ecbuild_critical( "No TARGET given for claw_compile()" )
endif()
list( APPEND _ARGS --target=${_PAR_TARGET})

if( NOT _PAR_DIRECTIVE )
ecbuild_critical( "No TARGET given for claw_compile()" )
endif()
list( APPEND _ARGS --directive=${_PAR_DIRECTIVE})

if( _PAR_INCLUDE )
foreach( INCLUDE ${_PAR_INCLUDE} )
list( APPEND _ARGS -I ${INCLUDE} )
endforeach()
endif()

if( _PAR_XMOD )
foreach( XMOD ${_PAR_XMOD} )
list( APPEND _ARGS -J ${XMOD} )
endforeach()
endif()

add_custom_command(
OUTPUT ${_PAR_OUTPUT}
COMMAND clawfc -w 132 ${_ARGS} -o ${_PAR_OUTPUT} ${_PAR_SOURCE}
DEPENDS ${_PAR_SOURCE} ${_PAR_DEPENDS}
COMMENT "[clawfc] Pre-processing: target=${_PAR_TARGET} directive=${_PAR_DIRECTIVE}"
)

endfunction()


##############################################################################
# .rst:
Expand Down Expand Up @@ -468,14 +395,7 @@ function( generate_xmod )
endforeach()
endif()

if( TARGET clawfc AND NOT TARGET F_Front )
get_target_property( _CLAWFC_EXECUTABLE clawfc IMPORTED_LOCATION )
get_filename_component( _CLAWFC_LOCATION ${_CLAWFC_EXECUTABLE} DIRECTORY )
set( _F_FRONT_EXECUTABLE ${_CLAWFC_LOCATION}/F_Front )
list( APPEND _PAR_DEPENDS clawfc )
else()
set( _F_FRONT_EXECUTABLE F_Front )
endif()
set( _F_FRONT_EXECUTABLE F_Front )

add_custom_command(
OUTPUT ${_PAR_OUTPUT}
Expand Down
59 changes: 1 addition & 58 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ jdk_certificate=""
venv_path=
with_jdk=false
with_ant=false
with_claw=false
claw_install_env=""
with_omni=false
with_ofp=false
with_docs=false
Expand All @@ -61,14 +59,12 @@ print_usage_with_options() {
echo " --use-venv[=]<path> Use existing virtual environment at <path>"
echo " --with[out]-jdk Install JDK instead of using system version (default: use system version)"
echo " --with[out]-ant Install ant instead of using system version (default: use system version)"
echo " --with[out]-claw Install CLAW and OMNI Compiler (default: disabled)"
echo " --with[out]-omni Install OMNI Compiler; cannot be combined with --with-claw (default: disabled)"
echo " --with[out]-omni Install OMNI Compiler (default: disabled)"
echo " --with[out]-ofp Install Open Fortran Parser (default: disabled)"
echo " --with[out]-dace Install DaCe (default: enabled)"
echo " --with[out]-tests Install dependencies to run tests (default: enabled)"
echo " --with[out]-docs Install dependencies to generate documentation (default: disabled)"
echo " --with[out]-examples Install dependencies to run the example notebooks (default: enabled)"
echo " --claw-install-env[=]<...> Specify environmental variables for CLAW build and install"
}

print_step() {
Expand Down Expand Up @@ -98,13 +94,6 @@ while getopts "$optspec" optchar; do
jdk-certificate=*)
jdk_certificate=$(realpath "${!OPTARG#*=}")
;;
claw-install-env) # Provide custom environment variables for CLAW build
claw_install_env="${!OPTIND}"
OPTIND=$(( OPTIND + 1 ))
;;
claw-install-env=*) # Provide custom environment variables for CLAW build
claw_install_env="${!OPTARG#*=}"
;;
hpc2020) # Load ECMWF HPC2020 (Atos) specific modules and settings
is_hpc2020=true
;;
Expand Down Expand Up @@ -133,12 +122,6 @@ while getopts "$optspec" optchar; do
without-ofp) # Disable installation of OFP
with_ofp=false
;;
with-claw) # Enable installation of OMNI+CLAW
with_claw=true
;;
without-claw) # Disable installation of OMNI+CLAW
with_claw=false
;;
with-omni) # Enable installation of OMNI
with_omni=true
;;
Expand Down Expand Up @@ -197,12 +180,6 @@ while getopts "$optspec" optchar; do
esac
done

if [ "$with_omni" == true ]; then
if [ "$with_claw" == true ]; then
echo "ERROR: Cannot combine --with-claw and --with-omni"
exit 1
fi
fi

# Print configuration
if [ "$verbose" == true ]; then
Expand All @@ -212,7 +189,6 @@ if [ "$verbose" == true ]; then
[[ "$venv_path" != "" ]] && echo " --use-venv='$venv_path'"
[[ "$with_jdk" == true ]] && echo " --with-jdk"
[[ "$with_ant" == true ]] && echo " --with-ant"
[[ "$with_claw" == true ]] && echo " --with-claw"
[[ "$with_omni" == true ]] && echo " --with-omni"
[[ "$with_ofp" == false ]] && echo " --without-ofp"
[[ "$with_dace" == false ]] && echo " --without-dace"
Expand Down Expand Up @@ -383,34 +359,6 @@ if [ "$with_ant" == true ]; then
ant -f "${ANT_HOME}/fetch.xml" -Ddest=optional
fi

#
# Install CLAW+OMNI
#

if [ "$with_claw" == true ]; then
print_step "Downloading and installing CLAW and OMNI Compiler"

CLAW_INSTALL_DIR=${venv_path}/opt/claw
mkdir -p "${CLAW_INSTALL_DIR}"
cd "${CLAW_INSTALL_DIR}"
rm -rf claw-compiler
# git clone --recursive --single-branch https://github.com/claw-project/claw-compiler.git claw-compiler

# Note that the deprecated CLAW variants in CLOUDSC will fail due to faulty offload
# directives with current CLAW-master. The fixes exist in this pinned branch:
# However, this branch fails to build with recent GNU versions (GNU 10+)
git clone --recursive --single-branch --branch=mlange-dev https://github.com/mlange05/claw-compiler.git claw-compiler
cd claw-compiler

(
set -a
eval ${claw_install_env}
cmake -S . -B build -DCMAKE_INSTALL_PREFIX="${CLAW_INSTALL_DIR}"
cmake --build build
cmake --install build
)
fi

#
# Install OMNI
#
Expand Down Expand Up @@ -533,11 +481,6 @@ export JAVA_HOME=\"\${JAVA_HOME}\"
path_var=${JAVA_HOME}/bin:$path_var
fi

# Inject CLAW into env
if [ "$with_claw" == true ]; then
path_var=${CLAW_INSTALL_DIR}/bin:$path_var
fi

# Inject OMNI into env
if [ "$with_omni" == true ]; then
path_var=${OMNI_INSTALL_DIR}/bin:$path_var
Expand Down

0 comments on commit c6fac30

Please sign in to comment.