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

Create PSyIR kernel arguments from new metadata classes (closes #2078) #2079

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
db6aa70
issue #2078. Added initial partial implementation.
rupertford Mar 20, 2023
02eeb5a
pr #2079 Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
rupertford Apr 18, 2023
b508aaf
pr #2079. Improved implementation and got tests working.
rupertford Apr 20, 2023
b511c12
pr #2079 Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
rupertford May 16, 2023
0611ea5
pr #2079. Add test for reference_element method and fix implementation.
rupertford May 17, 2023
6a9cfe5
pr #2079 Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
rupertford May 17, 2023
681de03
pr #2079. Fixed meta_mesh code and added tests.
rupertford May 18, 2023
a819ec7
pr #2079 Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
rupertford Jun 24, 2023
41d97cd
pr #2079. Added more tests and assocaited fixes.
rupertford Jun 26, 2023
79eba5f
pr #2079 Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
rupertford Jun 29, 2023
9f8d837
pr #2079. Added support and tests for _fs_intergrid method.
rupertford Jun 30, 2023
e3f97c7
pr #2079. Adding support for basis and diff basis functions.
rupertford Jul 3, 2023
918aefb
Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
arporter Jul 8, 2024
e2c09e0
#2078 some tidying for linter [skip ci]
arporter Jul 8, 2024
d1d3db4
Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
arporter Jul 9, 2024
cefca9c
#2078 update gen_kernel_stub.py to use new functionality [skip ci]
arporter Jul 9, 2024
1d32002
#2078 extend fortran frontend to raise ValueError on parser failure
arporter Jul 9, 2024
dc20beb
#2078 ensure parse error caught and propagated
arporter Jul 9, 2024
8699838
#2078 get various stub-gen tests working
arporter Jul 9, 2024
54609cf
#2078 WIP adding CMA-related arg support
arporter Jul 9, 2024
34329a6
Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
arporter Jul 11, 2024
845ba20
#2078 WIP fixing tests [skip ci]
arporter Jul 11, 2024
0414212
#2078 add validation step to metadata creation [skip ci]
arporter Jul 11, 2024
c30574d
Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
arporter Jul 23, 2024
4b8e33e
#2078 make test metadata valid
arporter Jul 23, 2024
aa9abd4
#2078 add test for _intialise() [skip ci]
arporter Jul 23, 2024
8bfb951
Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
arporter Jul 23, 2024
7ecb5c1
#2078 WIP fixing tests [skip ci]
arporter Jul 25, 2024
d88b6fd
#2078 start changing CMA test to use PSyIR rather than text [skip ci]
arporter Jul 25, 2024
09b0bda
Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
arporter Nov 27, 2024
2c6e4db
Merge branch 'master' into 2078_lfric_kernel_psyir_arguments
arporter Jan 6, 2025
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
Prev Previous commit
Next Next commit
#2078 WIP fixing tests [skip ci]
  • Loading branch information
arporter committed Jul 25, 2024
commit 7ecb5c1179cbae6d5c0d1fea04b70fb806c6502a
155 changes: 84 additions & 71 deletions src/psyclone/tests/dynamo0p3_cma_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
from fparser import api as fpapi

from psyclone.tests.lfric_build import LFRicBuild
from psyclone.tests.utilities import print_diffs

from psyclone.configuration import Config
from psyclone.core.access_type import AccessType
from psyclone.domain.lfric import (LFRicArgDescriptor, LFRicConstants,
Expand Down Expand Up @@ -1306,91 +1308,102 @@ def test_cma_multi_kernel(tmpdir, dist_mem):


# Tests for the kernel-stub generator
def test_cma_asm_stub_gen():
def test_cma_asm_stub_gen(fortran_writer):
''' Test the kernel-stub generator for CMA operator assembly.

'''

path = os.path.join(BASE_PATH, "columnwise_op_asm_kernel_mod.F90")
result = generate(path, api=TEST_API)

expected = (
" MODULE columnwise_op_asm_kernel_mod\n"
" IMPLICIT NONE\n"
" CONTAINS\n"
" SUBROUTINE columnwise_op_asm_kernel_code(cell, nlayers, "
"ncell_2d, op_1_ncell_3d, op_1, cma_op_2, cma_op_2_nrow, "
"cma_op_2_ncol, cma_op_2_bandwidth, cma_op_2_alpha, cma_op_2_beta, "
"cma_op_2_gamma_m, cma_op_2_gamma_p, ndf_adspc1_op_1, "
"cbanded_map_adspc1_op_1, ndf_adspc2_op_1, cbanded_map_adspc2_op_1)\n"
" USE constants_mod\n"
" IMPLICIT NONE\n"
" INTEGER(KIND=i_def), intent(in) :: nlayers\n"
" INTEGER(KIND=i_def), intent(in) :: ndf_adspc1_op_1\n"
" INTEGER(KIND=i_def), intent(in), dimension("
"ndf_adspc1_op_1,nlayers) :: cbanded_map_adspc1_op_1\n"
" INTEGER(KIND=i_def), intent(in) :: ndf_adspc2_op_1\n"
" INTEGER(KIND=i_def), intent(in), dimension("
"ndf_adspc2_op_1,nlayers) :: cbanded_map_adspc2_op_1\n"
" INTEGER(KIND=i_def), intent(in) :: cell, ncell_2d\n"
" INTEGER(KIND=i_def), intent(in) :: cma_op_2_nrow, "
"cma_op_2_ncol, cma_op_2_bandwidth, cma_op_2_alpha, cma_op_2_beta, "
"cma_op_2_gamma_m, cma_op_2_gamma_p\n"
" REAL(KIND=r_solver), intent(inout), dimension("
"cma_op_2_bandwidth,cma_op_2_nrow,ncell_2d) :: cma_op_2\n"
" INTEGER(KIND=i_def), intent(in) :: op_1_ncell_3d\n"
" REAL(KIND=r_def), intent(in), dimension(ndf_adspc1_op_1,"
"ndf_adspc2_op_1,op_1_ncell_3d) :: op_1\n"
" END SUBROUTINE columnwise_op_asm_kernel_code\n"
" END MODULE columnwise_op_asm_kernel_mod")
assert expected in str(result)


def test_cma_asm_with_field_stub_gen():
psyir = generate(path, api=TEST_API)
result = fortran_writer(psyir)
expected1 = (
"subroutine columnwise_op_asm_kernel_code(cell, nlayers, "
"ncell_2d, op_1_ncell_3d, op_1, cma_op_2, nrow_cma_op_2, "
"ncol_cma_op_2, bandwidth_cma_op_2, alpha_cma_op_2, beta_cma_op_2, "
"gamma_m_cma_op_2, gamma_p_cma_op_2, ndf_adspc1, "
"cbanded_map_adspc1_cma_op_2, ndf_adspc2, "
"cbanded_map_adspc2_cma_op_2)\n")
assert expected1 in result
expected2 = (
" use constants_mod, only : i_def, r_def\n"
" integer(kind=i_def), intent(in) :: cell\n"
" integer(kind=i_def), intent(in) :: nlayers\n"
" integer(kind=i_def), intent(in) :: ncell_2d\n"
" integer(kind=i_def), intent(in) :: op_1_ncell_3d\n"
" integer(kind=i_def), intent(in) :: ndf_adspc1\n"
" integer(kind=i_def), intent(in) :: ndf_adspc2\n"
" real(kind=r_def), dimension(ndf_adspc1,"
"ndf_adspc2,op_1_ncell_3d), intent(in) :: op_1\n"
" integer(kind=i_def), intent(in) :: bandwidth_cma_op_2\n"
" integer(kind=i_def), intent(in) :: nrow_cma_op_2\n"
# Should be r_solver TODO
" real(kind=r_def), dimension(bandwidth_cma_op_2,"
"nrow_cma_op_2,ncell_2d), intent(out) :: cma_op_2\n"
" integer(kind=i_def), intent(in) :: ncol_cma_op_2\n"
" integer(kind=i_def), intent(in) :: alpha_cma_op_2\n"
" integer(kind=i_def), intent(in) :: beta_cma_op_2\n"
" integer(kind=i_def), intent(in) :: gamma_m_cma_op_2\n"
" integer(kind=i_def), intent(in) :: gamma_p_cma_op_2\n"
" integer(kind=i_def), dimension(ndf_adspc1,nlayers), intent(in) "
":: cbanded_map_adspc1_cma_op_2\n"
" integer(kind=i_def), dimension(ndf_adspc2,nlayers), intent(in) "
":: cbanded_map_adspc2_cma_op_2\n\n\n"
" end subroutine columnwise_op_asm_kernel_code\n")
if expected2 not in result:
print_diffs(expected2, result)
assert 0


def test_cma_asm_with_field_stub_gen(fortran_writer):
''' Test the kernel-stub generator for CMA operator assembly when a
field is involved.

'''
result = generate(os.path.join(BASE_PATH,
"columnwise_op_asm_field_kernel_mod.F90"),
api=TEST_API)
psyir = generate(os.path.join(BASE_PATH,
"columnwise_op_asm_field_kernel_mod.F90"),
api=TEST_API)
result = fortran_writer(psyir)

expected = (
" MODULE columnwise_op_asm_field_kernel_mod\n"
" IMPLICIT NONE\n"
" CONTAINS\n"
" SUBROUTINE columnwise_op_asm_field_kernel_code(cell, nlayers, "
" subroutine columnwise_op_asm_field_kernel_code(cell, nlayers, "
"ncell_2d, field_1_aspc1_field_1, op_2_ncell_3d, op_2, cma_op_3, "
"cma_op_3_nrow, cma_op_3_ncol, cma_op_3_bandwidth, cma_op_3_alpha, "
"cma_op_3_beta, cma_op_3_gamma_m, cma_op_3_gamma_p, "
"nrow_cma_op_3, ncol_cma_op_3, bandwidth_cma_op_3, alpha_cma_op_3, "
"beta_cma_op_3, gamma_m_cma_op_3, gamma_p_cma_op_3, "
"ndf_aspc1_field_1, undf_aspc1_field_1, map_aspc1_field_1, "
"cbanded_map_aspc1_field_1, ndf_aspc2_op_2, cbanded_map_aspc2_op_2)\n"
" USE constants_mod\n"
" IMPLICIT NONE\n"
" INTEGER(KIND=i_def), intent(in) :: nlayers\n"
" INTEGER(KIND=i_def), intent(in) :: ndf_aspc1_field_1\n"
" INTEGER(KIND=i_def), intent(in), "
"dimension(ndf_aspc1_field_1) :: map_aspc1_field_1\n"
" INTEGER(KIND=i_def), intent(in), "
"dimension(ndf_aspc1_field_1,nlayers) :: cbanded_map_aspc1_field_1\n"
" INTEGER(KIND=i_def), intent(in) :: ndf_aspc2_op_2\n"
" INTEGER(KIND=i_def), intent(in), "
"dimension(ndf_aspc2_op_2,nlayers) :: cbanded_map_aspc2_op_2\n"
" INTEGER(KIND=i_def), intent(in) :: undf_aspc1_field_1\n"
" INTEGER(KIND=i_def), intent(in) :: cell, ncell_2d\n"
" INTEGER(KIND=i_def), intent(in) :: cma_op_3_nrow, "
"cma_op_3_ncol, cma_op_3_bandwidth, cma_op_3_alpha, cma_op_3_beta, "
"cma_op_3_gamma_m, cma_op_3_gamma_p\n"
" REAL(KIND=r_solver), intent(inout), dimension("
"cma_op_3_bandwidth,cma_op_3_nrow,ncell_2d) :: cma_op_3\n"
" REAL(KIND=r_def), intent(in), dimension(undf_aspc1_field_1) :: "
"field_1_aspc1_field_1\n"
" INTEGER(KIND=i_def), intent(in) :: op_2_ncell_3d\n"
" REAL(KIND=r_def), intent(in), dimension("
"ndf_aspc1_field_1,ndf_aspc2_op_2,op_2_ncell_3d) :: op_2\n"
" END SUBROUTINE columnwise_op_asm_field_kernel_code\n"
" END MODULE columnwise_op_asm_field_kernel_mod")
assert expected in str(result)
" use constants_mod, only : i_def, r_def\n"
" integer(kind=i_def), intent(in) :: cell\n"
" integer(kind=i_def), intent(in) :: nlayers\n"
" integer(kind=i_def), intent(in) :: ncell_2d\n"
" integer(kind=i_def), intent(in) :: undf_aspc1\n"
" real(kind=r_def), dimension(undf_aspc1), intent(in) :: "
"rfield_1_aspc1\n"
" integer(kind=i_def), intent(in) :: op_2_ncell_3d\n"
" integer(kind=i_def), intent(in) :: ndf_aspc1\n"
" integer(kind=i_def), intent(in) :: ndf_aspc2\n"
" real(kind=r_def), dimension(ndf_aspc1,ndf_aspc2,op_2_ncell_3d), "
"intent(in) :: op_2\n"
" integer(kind=i_def), intent(in) :: bandwidth_cma_op_3\n"
" integer(kind=i_def), intent(in) :: nrow_cma_op_3\n"
# TODO was r_solver and (inout) before?
" real(kind=r_def), dimension("
"bandwidth_cma_op_3,nrow_cma_op_3,ncell_2d), intent(out) :: cma_op_3\n"
" integer(kind=i_def), intent(in) :: ncol_cma_op_3\n"
" integer(kind=i_def), intent(in) :: alpha_cma_op_3\n"
" integer(kind=i_def), intent(in) :: beta_cma_op_3\n"
" integer(kind=i_def), intent(in) :: gamma_m_cma_op_3\n"
" integer(kind=i_def), intent(in) :: gamma_p_cma_op_3\n"
" integer(kind=i_def), dimension(ndf_aspc1), intent(in) :: "
"dofmap_aspc1\n"
" integer(kind=i_def), dimension(ndf_aspc1,nlayers), intent(in) :: "
"cbanded_map_aspc1_cma_op_3\n"
" integer(kind=i_def), dimension(ndf_aspc2,nlayers), intent(in) :: "
"cbanded_map_aspc2_cma_op_3\n"
" end subroutine columnwise_op_asm_field_kernel_code\n"
)
if expected not in result:
print_diffs(expected, result)
assert 0


def test_cma_asm_same_fs_stub_gen():
Expand Down