Skip to content

Commit

Permalink
Merge branch 'master' into feature/acc-wait-directive
Browse files Browse the repository at this point in the history
  • Loading branch information
svalat committed Sep 8, 2023
2 parents 03d337b + da05804 commit 303b105
Show file tree
Hide file tree
Showing 166 changed files with 5,028 additions and 1,770 deletions.
67 changes: 60 additions & 7 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,24 @@
# Modified by N. M. Nobre, STFC Daresbury Lab

# This workflow will use a self-hosted runner to perform the more expensive
# integrations tests that are not run on GHA systems. At the moment it only
# runs the test suite with compilation enabled (using gfortran).
# compilation tests that are not run on GHA systems. At the moment it:
#
# * Runs the test suite with compilation with gfortran and nvfortran;
# * Builds the examples with gfortran and nvfortran (the latter with
# OpenACC enabled).
# * Builds the tutorials with gfortran and nvfortran.

name: Compilation tests

on:
push

env:
PYTHON_VERSION: 3.11.4
GFORTRAN_VERSION: 13.2.0
NVFORTRAN_VERSION: 23.7
CUDA_VERSION: 12.2

jobs:
run_if_on_mirror:
# Only PSyclone-mirror has the necessary self-hosted runner.
Expand All @@ -66,17 +76,60 @@ jobs:
commit-filter: '[skip ci]'
- name: Install dependencies
run: |
module load python/3.11.3
module load python/${PYTHON_VERSION}
python -m venv .runner_venv
. .runner_venv/bin/activate
python -m pip install --upgrade pip
# If you wish to install the version of fparser pointed to by the
# submodule instead of the released version (from PyPI) then
# uncomment the following line:
pip install external/fparser
pip install .[test]
- name: Test with pytest and compilation
pip install .[test,psydata]
- name: Unit tests with compilation - gfortran
run: |
module load python/${PYTHON_VERSION}
. .runner_venv/bin/activate
module load gcc/${GFORTRAN_VERSION} openmpi netcdf_fortran
pytest -n 2 --f90=gfortran --compile --compileopencl src/psyclone/tests
module rm netcdf_fortran gcc
- name: Unit tests with compilation - nvfortran
run: |
module load python/${PYTHON_VERSION}
. .runner_venv/bin/activate
module load nvidia-hpcsdk/${NVFORTRAN_VERSION} netcdf_fortran
# We have to tell nvfortran where to find the OpenCL library.
pytest -n 2 --f90=nvfortran --f90flags="-L/apps/packages/compilers/nvidia-hpcsdk/Linux_x86_64/${NVFORTRAN_VERSION}/cuda/${CUDA_VERSION}/targets/x86_64-linux/lib" --compile --compileopencl src/psyclone/tests
module rm netcdf_fortran nvidia-hpcsdk
- name: Examples with compilation - gfortran
run: |
module load python/${PYTHON_VERSION}
. .runner_venv/bin/activate
module load gcc/${GFORTRAN_VERSION} openmpi netcdf_fortran
# Although we're using gfortran, we link with the OpenCL lib that comes
# with CUDA.
make -C examples allclean
F90=gfortran F90FLAGS="-L/apps/packages/compilers/nvidia-hpcsdk/Linux_x86_64/${NVFORTRAN_VERSION}/cuda/${CUDA_VERSION}/targets/x86_64-linux/lib" make -C examples compile
- name: Tutorials with compilation - gfortran
run: |
module load python/${PYTHON_VERSION}
. .runner_venv/bin/activate
make -C tutorial/practicals allclean
module load gcc/${GFORTRAN_VERSION} openmpi netcdf_fortran
make -C tutorial/practicals compile
- name: Examples with compilation - nvfortran
run: |
module load python/${PYTHON_VERSION}
. .runner_venv/bin/activate
make -C examples allclean
module load nvidia-hpcsdk/${NVFORTRAN_VERSION} netcdf_fortran
# We have to tell nvfortran where to find the OpenCL library.
F90=nvfortran F90FLAGS="-acc -Minfo=all -L/apps/packages/compilers/nvidia-hpcsdk/Linux_x86_64/${NVFORTRAN_VERSION}/cuda/${CUDA_VERSION}/targets/x86_64-linux/lib" make -C examples compile
- name: Tutorials with compilation - nvfortran
run: |
module load python/3.11.3
module load python/${PYTHON_VERSION}
. .runner_venv/bin/activate
pytest -n 2 --f90=gfortran --compile src/psyclone/tests
make -C tutorial/practicals allclean
module load nvidia-hpcsdk/${NVFORTRAN_VERSION} netcdf_fortran
# TODO #2251. Cannot build the LFRic practicals with 23.5/7 of nvfortran
# because the compilation of nan_test.f90 gives an ICE.
F90=nvfortran F90FLAGS="-acc -Minfo=all" make -C tutorial/practicals/nemo compile
113 changes: 113 additions & 0 deletions .github/workflows/lfric_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# -----------------------------------------------------------------------------
# BSD 3-Clause License
#
# Copyright (c) 2023, Science and Technology Facilities Council.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
# Author S. Siso, STFC Daresbury Lab

# This workflow will use a self-hosted runner to perform the more expensive
# integrations tests that are not run on GHA systems.

name: LFRic Integration Tests

on:
push

jobs:
run_if_on_mirror:
if: ${{ github.repository == 'stfc/PSyclone-mirror' }}
runs-on: self-hosted

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
# This is required to get the commit history for merge commits for
# the ci-skip check below.
fetch-depth: '0'
- name: Check for [skip ci] in commit message
uses: mstachniuk/ci-skip@v1
with:
# This setting causes the tests to 'fail' if [skip ci] is specified
fail-fast: true
commit-filter: '[skip ci]'
- name: Install dependencies
run: |
python -m venv .runner_venv
. .runner_venv/bin/activate
python -m pip install --upgrade pip
# If you wish to install the version of fparser pointed to by the
# submodule instead of the released version (from PyPI) then
# uncomment the following line:
pip install external/fparser
pip install .[test]
pip install jinja2
# PSyclone, compile and run MetOffice LFRic with 6 MPI ranks
- name: LFRic passthrough (with DistributedMemory)
run: |
. .runner_venv/bin/activate
export PSYCLONE_LFRIC_DIR=${GITHUB_WORKSPACE}/examples/lfric/scripts
export MINIAPP_DIR=${HOME}/LFRic/miniapps/gungho_model
cd ${MINIAPP_DIR}
# Compile
module load lfric_env
export PSYCLONE_CONFIG=${HOME}/lfric_psyclone_config.cfg
make clean
make -j 6 build
# Run
cd example
cp ${HOME}/lfric_gunho_configuration.nml configuration.nml
mpirun -n 6 ../bin/gungho_model configuration.nml
tail PET0.gungho_model.Log
cat timer.txt
# PSyclone, compile and run MetOffice LFRic with all optimisations and 6 OpenMP threads
- name: LFRic with all transformations
run: |
. .runner_venv/bin/activate
export PSYCLONE_LFRIC_DIR=${GITHUB_WORKSPACE}/examples/lfric/scripts
export MINIAPP_DIR=${HOME}/LFRic/miniapps/gungho_model
cd ${MINIAPP_DIR}
# Prepare script (LFRics expects a folder with a global.py)
mkdir -p psyclone-test
cp ${PSYCLONE_LFRIC_DIR}/everything_everywhere_all_at_once.py psyclone-test/global.py
# Compile
module load lfric_env
export PSYCLONE_CONFIG=${HOME}/lfric_psyclone_config.cfg
make clean
make OPTIMISATION_PATH=${MINIAPP_DIR}/psyclone-test -j 6 build
# Run
cd example
cp ${HOME}/lfric_gunho_configuration.nml configuration.nml
export OMP_NUM_THREADS=6
mpirun -n 1 ../bin/gungho_model configuration.nml
cat timer.txt
25 changes: 23 additions & 2 deletions .github/workflows/nemo_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,28 @@ jobs:
tail -n 1 output.txt | grep -q "S_min: 0.482686"
tail -n 1 output.txt | grep -q "S_max: 0.407622"
grep -A 1 "Elapsed Time" output.txt
echo $GITHUB_REF_NAME $GITHUB_SHA $(grep -A 1 "Elapsed Time" output.txt | head -n 2 | tail -n 1) >> ${NEMO_DIR}/performance_history
echo $GITHUB_REF_NAME $GITHUB_SHA $(grep -A 1 "Elapsed Time" output.txt | head -n 2 | tail -n 1) >> ${NEMO_DIR}/performance_history_openmp_gpu
# PSyclone, compile and run MetOffice NEMO with OpenACC kernels for GPUs
- name: NEMO MetOffice OpenACC kernels for GPU
run: |
. .runner_venv/bin/activate
export PSYCLONE_NEMO_DIR=${GITHUB_WORKSPACE}/examples/nemo/scripts
export NEMO_DIR=${HOME}/NEMO
cd examples/nemo/scripts
make -j 4 openacc_kernels
module load nvidia-hpcsdk netcdf_fortran
COMPILER_ARCH=linux_nvidia_acc_gpu make -j 4 compile-openacc_kernels
export NV_ACC_POOL_THRESHOLD=75
make run-openacc_kernels | tee output.txt
# Check the output is as expected for the first 6 digits
tail -n 1 output.txt | grep -q " it : 10"
tail -n 1 output.txt | grep -q "|ssh|_max: 0.259483"
tail -n 1 output.txt | grep -q "|U|_max: 0.458515"
tail -n 1 output.txt | grep -q "S_min: 0.482686"
tail -n 1 output.txt | grep -q "S_max: 0.407622"
grep -A 1 "Elapsed Time" output.txt
echo $GITHUB_REF_NAME $GITHUB_SHA $(grep -A 1 "Elapsed Time" output.txt | head -n 2 | tail -n 1) >> ${NEMO_DIR}/performance_history_openacc_kernels_gpu
# PSyclone, compile and run ECMWF NEMO with OpenMP for CPUs
- name: NEMO ECMWF OpenMP for CPU
Expand Down Expand Up @@ -129,4 +150,4 @@ jobs:
tail -n 1 output.txt | grep -q "S_min: 0.108530"
tail -n 1 output.txt | grep -q "S_max: 0.404045"
grep -A 1 "Elapsed Time" output.txt
echo $GITHUB_REF_NAME $GITHUB_SHA $(grep -A 1 "Elapsed Time" output.txt | head -n 2 | tail -n 1) >> ${NEMO_DIR}/performance_history
echo $GITHUB_REF_NAME $GITHUB_SHA $(grep -A 1 "Elapsed Time" output.txt | head -n 2 | tail -n 1) >> ${NEMO_DIR}/performance_history_openmp_cpu
9 changes: 8 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ jobs:
- uses: actions/setup-python@v4
- run: python -m pip install --upgrade pip
- run: pip install .[doc]
- run: cd doc/developer_guide; make doctest
# Sphinx since version 7.2 (7.2.0/1/2) aborts with
# exec('from sympy import *', global_dict)
# File "<string>", line 1, in <module>
# AttributeError: module 'sympy' has no attribute 'external'
# when it is run without creating the documentation first.
# So till this is fixed in Sphinx, we trigger the creation
# of the html documents before actually running doctest
- run: cd doc/developer_guide; make html; make doctest
build:
if: ${{ github.repository != 'stfc/PSyclone-mirror' }}
runs-on: ubuntu-latest
Expand Down
73 changes: 73 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,79 @@
172) PR #2163 for #1537. Support array-slicing notation in SymPy
comparisons.

173) PR #2221 for #2214. Fix names of invokes containing a single
kernel in the PSyIR of the LFRic Alg layer.

174) PR #2225 for #2224. Fix erroneous CI link check error by
omitting test for the particular link.

175) PR #2172 for #1833. Fixes the LFRic tutorials so that they
build correctly.

176) PR #2227 for #2226. Adds new Node.path_from(ancestor) method.

177) PR #2158 for #81. Ensures all example/test Fortran code for
LFRic follows the LFRic naming convention.

178) PR #2218 towards #2132. Adds LFRic integration tests and
new, associated optimisation scripts. Includes bug fixes for
matmul inlining transformation.

179) PR #2230 for #2228. Improve reporting of errors due to kernel
functors not explicitly included in algorithm use statements.

180) PR #2207 for #1419. Split the DataSymbol constant_value attribute
into is_constant (bool) and initial_value (PSyIR Node). This allows
parsing Fortran declarations with initial_value that are not constant.

181) PR #2231 for #2213. The Fortran frontend and backend now also
consider that UnresolvedInterface symbols can come from the body of
a Fortran Interface.

182) PR #2240 for #2234. Fix WhileLoop issue in the NEMO OpenACC kernels
script.

183) PR #2182 for #2179. Fix LFRic eg14 nvfortran compilation and add
nvfortran examples and tutorials steps in the Integration tests.

184) PR #2250 for #2248 and #1575. Fixes bug in line-length limiter
to prevent it breaking a line before the first non-whitepsace
character.

185) PR #2262 towards #446. Implement reference_access for Call nodes.

186) PR #2184 for #2166. Adds Sympy support for user-defined types.

187) PR #2270 for #1575. Fixes the line-length limiter for code that
has an indent greater than the max. line length.

188) PR #2259 for #1932. Adds support for the 'gang' and 'vector'
clauses on OpenACC Loop directives.

189) PR #2276 for #2274. Small fixes for various complaints
produced by latest version of pycodestyle.

190) PR #2291 for #2290. Bug fix to KernelModuleInlineTrans -
ensures that the new RoutineSymbol added to the Container is given
a DefaultModuleInterface.

191) PR #2238 for #2234. Adds support for a generic interface to
perform variable comparison when the datatype is unknown. (Required
for canonicalising SELECT CASE constructs.)

192) PR #2292 for #2288. Workaround for Sphinx-doctest bug by
building html dev guide before running the doctests.

193) PR #2260 for #2245. Splits LFRicLoopBounds class from
dynamo0.3.py.

194 PR #2241 for #2215. Adds support for Fortran names being the
same as Python keywords when using sympy within PSyclone, e.g. in
comparisons between expressions.

195) PR #2295 for #2294. Extends the PSyData extraction library
to support character variables

release 2.3.1 17th of June 2022

1) PR #1747 for #1720. Adds support for If blocks to PSyAD.
Expand Down
2 changes: 2 additions & 0 deletions doc/developer_guide/psy_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,8 @@ takes the following parameters:
64-bit integer value
``logical``:
32-bit logical value
``char``:
A default string value

Default value is ``real,double,int``.

Expand Down
10 changes: 10 additions & 0 deletions doc/developer_guide/psyir.rst
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,16 @@ var2, var3)` would be represented by a
The PSyIR supports the concept of named arguments for operation
nodes, see the :ref:`named_arguments-label` section for more details.

.. note:: Similar to Fortran, the PSyIR has two comparison operators, one for
booleans (EQV) and one for non-booleans (EQ). These are not
interchangeable because they have different precedence priorities and
some compilers will not compile with the wrong operator. In some cases
we need to insert a comparison of two expressions and we don't know the
datatype of the operands (e.g. in the select-case canonicalisation).
A solution to this is to create an abstract interface with appropriate
implementations for each possible datatype.


IntrinsicCall Nodes
-------------------

Expand Down
Loading

0 comments on commit 303b105

Please sign in to comment.