-
Notifications
You must be signed in to change notification settings - Fork 8
Enables building mam4xx on Intel GPUs with SYCL #445
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
Changes from 5 commits
2580826
8faa76d
af2720c
b3e7df8
2612a8f
829d12e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,17 +23,10 @@ PREFIX=$1 | |
| DEVICE=$2 | ||
| PRECISION=$3 | ||
| BUILD_TYPE=$4 | ||
| # Turn off search for yaml libraries. EKAT will build yaml-cpp from submodules. | ||
| DEVICE_ARCH=$5 | ||
| # Turn off search for yaml libraries. EKAT will build yaml-cpp from submodules. | ||
| SKIP_FIND_YAML_CPP=ON | ||
|
|
||
| # Default compilers (can be overridden by environment variables) | ||
| if [[ -z $CC ]]; then | ||
| CC=cc | ||
| fi | ||
| if [[ -z $CXX ]]; then | ||
| CXX=c++ | ||
| fi | ||
|
|
||
| if [[ "$PREFIX" == "" ]]; then | ||
| echo "Haero installation prefix was not specified!" | ||
| echo "Usage: $0 <prefix> <device> <precision> <build_type>" | ||
|
|
@@ -75,34 +68,51 @@ fi | |
| echo "Cloning Haero repository into $(pwd)/.haero..." | ||
| git clone [email protected]:eagles-project/haero.git .haero || exit | ||
| cd .haero || exit | ||
| git checkout main | ||
| git submodule update --init --recursive || exit | ||
|
|
||
| # Are we on a special machine? | ||
| cd machines | ||
| echo $(pwd) | ||
| for MACHINE_FILE in $(ls) | ||
| do | ||
| MACHINE=${MACHINE_FILE/\.sh/} | ||
| echo $MACHINE | ||
| echo `hostname` | grep -q "$MACHINE" | ||
| host_match=$? | ||
| echo $SYSTEM_NAME | grep -q "$MACHINE" | ||
| sys_match=$? | ||
| if [ $host_match -eq 0 ] || [ $sys_match -eq 0 ]; then | ||
| echo "Found machine file $MACHINE_FILE. Setting up environment for $MACHINE..." | ||
| source ./$MACHINE.sh | ||
| fi | ||
| done | ||
|
|
||
| cd ../.. | ||
|
|
||
| # Configure Haero with the given selections. | ||
| if [[ "$DEVICE" == "gpu" ]]; then | ||
| cd .. | ||
|
|
||
| # these are (at least close to) the standard compiler choices for gpu builds | ||
| # to use one, uncomment or replace in the if [] blocks below | ||
|
|
||
| # NVIDIA GPU + gcc | ||
| # NOTE: if CXX is set to nvcc_wrapper, then this must be the same path used | ||
| # in the `sed` command below | ||
| # This happens by default via the $nvcw variable | ||
| CXX="$(pwd)/.haero/ext/ekat/extern/kokkos/bin/nvcc_wrapper" | ||
|
||
| nvcw=$CXX | ||
| CC=gcc | ||
|
|
||
| if [[ "$DEVICE" == "gpu" && ! -z "$nvcw" ]]; then | ||
mjschmidt271 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ENABLE_GPU=ON | ||
| # nvcw="$(pwd)/.haero/ext/ekat/extern/kokkos/bin/nvcc_wrapper" | ||
| CUDA_GEN=${DEVICE_ARCH:(-2)} | ||
| # FIXME: this assumes a default value in nvcc_wrapper | ||
| sed -i s/default_arch=\"sm_70\"/default_arch=\"sm_"$CUDA_GEN"\"/g "${nvcw}" | ||
| echo "====================================" | ||
| grep -i "default_arch=" "${nvcw}" | ||
| echo "====================================" | ||
| else | ||
| ENABLE_GPU=OFF | ||
| fi | ||
|
|
||
| # AMD GPU | ||
| # CXX=hipcc | ||
| # CC=amdclang | ||
|
|
||
| # Intel GPU | ||
| # CXX=icpx | ||
| # CC=icx | ||
|
|
||
| # Default compilers (can be overridden by environment variables) | ||
| if [[ -z $CC ]]; then | ||
| CC=cc | ||
| fi | ||
| if [[ -z $CXX ]]; then | ||
| CXX=c++ | ||
| fi | ||
|
|
||
| echo "Configuring Haero with the given selections (WITHOUT MPI)..." | ||
| cmake -S ./.haero -B ./.haero/build \ | ||
| -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ | ||
|
|
@@ -113,11 +123,13 @@ cmake -S ./.haero -B ./.haero/build \ | |
| -DHAERO_ENABLE_MPI=OFF \ | ||
| -DHAERO_ENABLE_GPU=$ENABLE_GPU \ | ||
| -DHAERO_PRECISION=$PRECISION \ | ||
| -DKokkos_ARCH_$DEVICE_ARCH:BOOL=ON \ | ||
| -DHAERO_DEVICE_ARCH=$DEVICE_ARCH \ | ||
| || exit | ||
|
|
||
| echo "Building and installing Haero in $PREFIX..." | ||
| cd .haero/build || exit | ||
| make -j8 install | ||
| make -j8 install || exit | ||
|
|
||
| cd ../../ | ||
| echo "Haero has been installed in $PREFIX. Set HAERO_DIR to this directory in" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -251,10 +251,28 @@ KOKKOS_INLINE_FUNCTION Real saturation_mixing_ratio_hardy(Real T, Real P) { | |
| /// the temperature. If not supplied, | ||
| /// @ref saturation_mixing_ratio_hardy is used. | ||
| /// @return relative humidity [1] | ||
| KOKKOS_INLINE_FUNCTION Real relative_humidity_from_vapor_mixing_ratio( | ||
| Real w, Real T, Real p, | ||
| Real (*wsat)(Real, Real) = saturation_mixing_ratio_hardy) { | ||
| const auto ws = wsat(T, p); | ||
| // KOKKOS_INLINE_FUNCTION Real relative_humidity_from_vapor_mixing_ratio( | ||
odiazib marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Real w, Real T, Real p, | ||
| // Real (*wsat)(Real, Real) = saturation_mixing_ratio_hardy) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also noted a compilation error in Aurora because of this function. However, we have compiled MAM4xx in EAMxx with SYCL, and this error did not show up. Thus, I wonder if we are only using relative_humidity_from_vapor_mixing_ratio in MAM4xx.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would make sense to me. However, unless we have reason for the flexibility to be available, I think we're ok without it. @singhbalwinder - do you know if this calculation would ever need a different calculation for saturation mixing ratio?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's just keep this commented out until we find out that we need it. |
||
| // const auto ws = wsat(T, p); | ||
| // return w / ws; | ||
| // } | ||
|
|
||
| /// Computes the relative humidity from the water vapor mixing ratio and the | ||
| /// pressure and temperature, given the relationship between temperature and | ||
| /// the water vapor saturation pressure. | ||
| /// | ||
| /// Use this formula with parameterizations that are defined with respect to | ||
| /// air air (and note that mixing ratio is defined with respect to dry air). | ||
| /// | ||
| /// @param [in] w water vapor mixing ratio [kg vapor / kg dry air] | ||
| /// @param [in] p total pressure [Pa] | ||
| /// @param [in] T temperature [K] | ||
| /// @return relative humidity [1] | ||
| KOKKOS_INLINE_FUNCTION Real relative_humidity_from_vapor_mixing_ratio(Real w, | ||
| Real T, | ||
| Real p) { | ||
| const auto ws = saturation_mixing_ratio_hardy(T, p); | ||
| return w / ws; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.