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

Implement split element orders #2799

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 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
7 changes: 4 additions & 3 deletions doc/user_guide/psyclone_kern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
.. POSSIBILITY OF SUCH DAMAGE.
.. -----------------------------------------------------------------------------
.. Written by R. W. Ford and A. R. Porter, STFC Daresbury Lab
.. Modified by I. Kavcic and L. Turner, Met Office
.. Modified by I. Kavcic, L. Turner and J. Dendy, Met Office

PSyclone Kernel Tools
=====================
Expand Down Expand Up @@ -558,14 +558,15 @@ gives the following algorithm layer code:
use mesh_mod, only : mesh_type
use simple_mod, only : simple_type
use constants_mod, only : i_def, r_def
integer(kind=i_def), parameter :: element_order = 1_i_def
integer(kind=i_def), parameter :: element_order_h = 1_i_def
integer(kind=i_def), parameter :: element_order_v = 1_i_def
type(mesh_type), pointer, intent(in) :: mesh
type(field_type), dimension(3), intent(in), optional :: chi
type(field_type), intent(in), optional :: panel_id
TYPE(function_space_type), POINTER :: vector_space_w1_ptr
type(field_type) :: field_1

vector_space_w1_ptr => function_space_collection % get_fs(mesh, element_order, w1)
vector_space_w1_ptr => function_space_collection % get_fs(mesh, element_order_h, element_order_v, w1)
call field_1 % initialise(vector_space=vector_space_w1_ptr, name='field_1')
call invoke(setval_c(field_1, 1.0_r_def), simple_type(field_1))

Expand Down
10 changes: 5 additions & 5 deletions doc/user_guide/transformations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ process, optional parameters for the transformation are also
provided this way. A simple example::

kctrans = Dynamo0p3KernelConstTrans()
kctrans.apply(kernel, {"element_order": 0, "quadrature": True})
kctrans.apply(kernel, {"element_order_h": 0, "element_order_v": 0, "quadrature": True})

The same ``options`` dictionary will be used when calling ``validate``.

Expand Down Expand Up @@ -287,19 +287,19 @@ can be found in the API-specific sections).
.. autoclass:: psyclone.psyir.transformations.AllArrayAccess2LoopTrans
:members: apply
:noindex:

####

.. autoclass:: psyclone.psyir.transformations.ArrayAccess2LoopTrans
:members: apply
:noindex:

####

.. autoclass:: psyclone.psyir.transformations.ArrayAssignment2LoopsTrans
:members: apply
:noindex:

####

.. autoclass:: psyclone.psyir.transformations.ChunkLoopTrans
Expand Down Expand Up @@ -802,7 +802,7 @@ PSyclone supports OpenMP Tasking, through the `OMPTaskloopTrans` and
transformations can be applied to loops, whilst the `OMPTaskwaitTrans`
operator is applied to an OpenMP Parallel Region, and computes the dependencies
caused by Taskloops, and adds OpenMP Taskwait statements to satisfy those
dependencies. An example of using OpenMP tasking is available in
dependencies. An example of using OpenMP tasking is available in
`PSyclone/examples/nemo/eg1/openmp_taskloop_trans.py`.

OpenCL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
! -----------------------------------------------------------------------------
! Modified by I. Kavcic, Met Office
! Modified by R. W. Ford, STFC Daresbury Lab
! Modified by J. Dendy, Met Office

!>@brief Preconditioner for the gravity-wave system
module gw_mixed_schur_preconditioner_alg_mod
Expand Down Expand Up @@ -125,7 +126,6 @@ contains
result(self)

use function_space_mod, only: function_space_type
use finite_element_config_mod, only: element_order
use quadrature_xyoz_mod, only: quadrature_xyoz_type
use quadrature_rule_gaussian_mod, only: quadrature_rule_gaussian_type
use matrix_vector_kernel_mod, only: matrix_vector_kernel_type
Expand Down
9 changes: 6 additions & 3 deletions examples/lfric/eg13/kernel_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
# Authors: R. W. Ford, N. Nobre and S. Siso, STFC Daresbury Lab
# Modified by: J. Dendy, Met Office


'''An example PSyclone transformation script which makes ndofs, nqp*
Expand Down Expand Up @@ -62,10 +63,11 @@
# associated kernel value constant (rather than passing it in by
# argument).
NUMBER_OF_LAYERS = 20
# The element order to use when modifying a kernel to make the
# The element orders to use when modifying a kernel to make the
# associated degrees of freedom values constant (rather than passing
# them in by argument).
ELEMENT_ORDER = 0
ELEMENT_ORDER_H = 0
ELEMENT_ORDER_V = 0
# Whether or not to make the number of quadrature points constant in a
# kernel (rather than passing them in by argument).
CONSTANT_QUADRATURE = True
Expand All @@ -86,7 +88,8 @@ def trans(psyir):
try:
const_trans.apply(kernel,
{"number_of_layers": NUMBER_OF_LAYERS,
"element_order": ELEMENT_ORDER,
"element_order_h": ELEMENT_ORDER_H,
"element_order_v": ELEMENT_ORDER_V,
"quadrature": CONSTANT_QUADRATURE})
except TransformationError:
print(f" Failed to modify kernel '{kernel.name}'")
11 changes: 7 additions & 4 deletions examples/lfric/eg14/main.x90
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
! -----------------------------------------------------------------------------
! Author: J. Henrichs, Bureau of Meteorology
! Modifications: A. R. Porter, STFC Daresbury Laboratory
! J. Dendy, Met Office

program main

Expand Down Expand Up @@ -57,7 +58,8 @@ program main
procedure (partitioner_interface), pointer :: partitioner_ptr
type(field_type) :: field1, field2
integer(kind=i_def) :: lfric_fs = W0 ! W0
integer(kind=i_def) :: element_order = 1
integer(kind=i_def) :: element_order_h = 1
integer(kind=i_def) :: element_order_v = 1
integer(kind=i_def) :: ndata_sz, istp
real(kind=r_def) :: chksm

Expand All @@ -84,9 +86,10 @@ program main
mesh = mesh_type(global_mesh_ptr, partition, extrusion_ptr)
write (*,*) "Mesh has", mesh%get_nlayers(), "layers."
ndata_sz = 1
vector_space = function_space_type( mesh, &
element_order, &
lfric_fs, &
vector_space = function_space_type( mesh, &
element_order_h, &
element_order_v, &
lfric_fs, &
ndata_sz)
vector_space_ptr => vector_space
call field1%initialise( vector_space = vector_space_ptr, name="field1" )
Expand Down
9 changes: 5 additions & 4 deletions examples/lfric/eg17/full_example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The following steps are required for this (using simplified code examples):
```fortran
global_mesh = global_mesh_type()
```
2) A 1x1 planar partition for one process is created:
```fortran
partitioner_ptr => partitioner_planar
Expand All @@ -34,9 +34,10 @@ The following steps are required for this (using simplified code examples):
5) Create a function/vector space:
```fortran
vector_space = function_space_type( mesh, &
element_order, &
lfric_fs, &
vector_space = function_space_type( mesh, &
element_order_h, &
element_order_v, &
lfric_fs, &
ndata_sz)
```
Expand Down
10 changes: 6 additions & 4 deletions examples/lfric/eg17/full_example/main.x90
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ program main
procedure (partitioner_interface), pointer :: partitioner_ptr
type(field_type) :: field1, field2
integer(kind=i_def) :: lfric_fs = W0 ! W0
integer(kind=i_def) :: element_order = 1
integer(kind=i_def) :: element_order_h = 1
integer(kind=i_def) :: element_order_v = 1
integer(kind=i_def) :: ndata_sz

! Use the unit-testing constructor:
Expand All @@ -81,9 +82,10 @@ program main
mesh = mesh_type(global_mesh_ptr, partition, extrusion_ptr)
write (*,*) "Mesh has", mesh%get_nlayers(), "layers."
ndata_sz = 1
vector_space = function_space_type( mesh, &
element_order, &
lfric_fs, &
vector_space = function_space_type( mesh, &
element_order_h, &
element_order_v, &
lfric_fs, &
ndata_sz)
vector_space_ptr => vector_space
call field1%initialise( vector_space = vector_space_ptr, name="field1" )
Expand Down
10 changes: 6 additions & 4 deletions examples/lfric/eg17/full_example_extract/main.X90
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ program main
type(field_type) :: field1, field2
type(field_type) :: chi(3)
integer(kind=i_def) :: lfric_fs = W0 ! W0
integer(kind=i_def) :: element_order = 1
integer(kind=i_def) :: element_order_h = 1
integer(kind=i_def) :: element_order_v = 1
integer(kind=i_def) :: ndata_sz
real(kind=r_def) :: one
logical(kind=l_def) :: some_logical
Expand Down Expand Up @@ -101,9 +102,10 @@ program main
mesh = mesh_type(global_mesh_ptr, partition, extrusion_ptr)
write (*,*) "Mesh has", mesh%get_nlayers(), "layers."
ndata_sz = 1
vector_space = function_space_type( mesh, &
element_order, &
lfric_fs, &
vector_space = function_space_type( mesh, &
element_order_h, &
element_order_v, &
lfric_fs, &
ndata_sz)
vector_space_ptr => vector_space
do i=1, 3
Expand Down
11 changes: 6 additions & 5 deletions examples/lfric/eg17/full_example_netcdf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ steps are required for this (using simplified code examples):
```fortran
global_mesh = global_mesh_type("mesh_BiP128x16-400x100.nc", "dynamics")
```

2) A 1x1 planar partition for one process is created:
```fortran
partitioner_ptr => partitioner_planar
Expand All @@ -34,9 +34,10 @@ steps are required for this (using simplified code examples):

5) Create a function/vector space:
```fortran
vector_space = function_space_type( mesh, &
element_order, &
lfric_fs, &
vector_space = function_space_type( mesh, &
element_order_h, &
element_order_v, &
lfric_fs, &
ndata_sz)
```

Expand All @@ -61,7 +62,7 @@ steps are required for this (using simplified code examples):

## Compilation

A simple makefile is provided to compile the example. It needs
A simple makefile is provided to compile the example. It needs
a full installation of NetCDF, since it is using ``nf-config`` to
query the required compiler and linker flags, and the
infrastructure library ``liblfric_netcdf.a`` provided in
Expand Down
11 changes: 7 additions & 4 deletions examples/lfric/eg17/full_example_netcdf/main.x90
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
! -----------------------------------------------------------------------------
! Author: J. Henrichs, Bureau of Meteorology
! Modifications: A. R. Porter, STFC Daresbury Laboratory
! J. Dendy, Met Office

program main

Expand Down Expand Up @@ -58,7 +59,8 @@ program main
procedure (partitioner_interface), pointer :: partitioner_ptr
type(field_type) :: field1, field2
integer(kind=i_def) :: lfric_fs = W0 ! W0
integer(kind=i_def) :: element_order = 1
integer(kind=i_def) :: element_order_h = 1
integer(kind=i_def) :: element_order_v = 1
integer(kind=i_def) :: ndata_sz

! Use the unit-testing constructor:
Expand All @@ -82,9 +84,10 @@ program main
mesh = mesh_type(global_mesh_ptr, partition, extrusion_ptr)
write (*,*) "Mesh has", mesh%get_nlayers(), "layers."
ndata_sz = 1
vector_space = function_space_type( mesh, &
element_order, &
lfric_fs, &
vector_space = function_space_type( mesh, &
element_order_h, &
element_order_v, &
lfric_fs, &
ndata_sz)
vector_space_ptr => vector_space
call field1%initialise( vector_space = vector_space_ptr, name="field1" )
Expand Down
8 changes: 5 additions & 3 deletions examples/lfric/eg4/solver_mod.x90
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
! -----------------------------------------------------------------------------
! Modified by A. Porter, STFC Daresbury Lab
! Modified by I. Kavcic, Met Office
! J. Dendy, Met Office
!
!> @brief Contains methods and algorithms for solving a system A.x = b for known
!! input field b and matrix A and returns field x
Expand All @@ -51,7 +52,7 @@ module solver_mod
use constants_mod, only : r_def, str_def, i_def
use function_space_collection_mod, only : function_space_collection
use field_mod, only : field_type
use finite_element_config_mod, only : element_order
use finite_element_config_mod, only : element_order_h, element_order_v
use fs_continuity_mod, only : W3
use function_space_mod, only : function_space_type
use log_mod, only : log_event, &
Expand Down Expand Up @@ -121,8 +122,9 @@ subroutine jacobi_solver_algorithm(lhs, rhs, mm, mesh, n_iter)

flag_obj%rflag = 0.0_r_def

rhs_fs => function_space_collection%get_fs( mesh, &
element_order, &
rhs_fs => function_space_collection%get_fs( mesh, &
element_order_h, &
element_order_v, &
rhs%which_function_space() )

diagonal = field_type( vector_space = rhs_fs )
Expand Down
4 changes: 3 additions & 1 deletion examples/lfric/eg5/alg.f90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
! POSSIBILITY OF SUCH DAMAGE.
!------------------------------------------------------------------------------
! Modified by I. Kavcic, Met Office
! J. Dendy, Met Office

module oned_conservative_flux_alg_mod

Expand Down Expand Up @@ -81,7 +82,8 @@ subroutine oned_conservative_flux_alg( direction, &

type(function_space_type), pointer :: rho_fs => null()

rho_fs => function_space_collection%get_fs( mesh_id, element_order, &
rho_fs => function_space_collection%get_fs( mesh_id, element_order_h, &
element_order_v, &
rho_in%which_function_space() )

a0 = field_type( vector_space = rho_fs )
Expand Down
7 changes: 5 additions & 2 deletions examples/lfric/eg9/advective_inc_alg_mod.x90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
! -----------------------------------------------------------------------------
! Modified by: I. Kavcic, Met Office
! A. R. Porter, STFC Daresbury Laboratory
! J. Dendy, Met Office

!>@brief Computes the advective increment of the prognostic equations
module advective_inc_alg_mod
Expand All @@ -47,7 +48,8 @@ module advective_inc_alg_mod
use constants_mod, only: r_def, i_def

! Configuration and restart/checkpoint options
use finite_element_config_mod, only: element_order, wtheta_on
use finite_element_config_mod, only: element_order_h, element_order_v, &
wtheta_on
use runtime_constants_mod, only: get_coordinates, &
get_inverse_lumped_mass_matrix, &
theta_space_id
Expand Down Expand Up @@ -113,7 +115,8 @@ contains

case(transport_operators_fem)
! Use project u.grad(theta) into the theta function space
qr = quadrature_xyoz_type(element_order+3, quadrature_rule)
qr = quadrature_xyoz_type(MAX(element_order_h, element_order_v)+3, &
quadrature_rule)
! Quadrature rule on lateral faces only
qrf = quadrature_face_type(nqp_exact, .true., .false., &
reference_element, quadrature_rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ stretching_method='linear',

&finite_element
cellshape = 'quadrilateral'
element_order = 0
element_order_h = 0
element_order_v = 0
rehabilitate = .true.
vorticity_in_w1 = .false.
coord_order = 1
Expand Down
Loading
Loading