Skip to content

Commit

Permalink
#1010 Remove NOT_INITIALISED integer literals
Browse files Browse the repository at this point in the history
  • Loading branch information
sergisiso committed Jan 22, 2025
1 parent 3a18bb3 commit cd18e86
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 40 deletions.
4 changes: 2 additions & 2 deletions doc/user_guide/psyke.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ PSyclone modifies the Schedule of the selected ``invoke_0``:
Schedule[invoke='invoke_0' dm=False]
0: Loop[type='dofs',field_space='any_space_1',it_space='dofs',
upper_bound='ndofs']
Literal[value:'NOT_INITIALISED']
Literal[value:'NOT_INITIALISED']
Reference[name:'loop0_start']
Reference[name:'loop0_stop']
Literal[value:'1']
Schedule[]
0: BuiltIn setval_c(f5,0.0)
Expand Down
8 changes: 4 additions & 4 deletions examples/lfric/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,14 @@ Kernel call 'matrix_vector_code' was found in
InvokeSchedule[invoke='invoke_0', dm=False]
...
Loop[type='', field_space='any_space_1', it_space='cells', upper_bound='ncells']
Literal[value:'NOT_INITIALISED']
Literal[value:'NOT_INITIALISED']
Reference[name:'loop0_start']
Reference[name:'loop0_stop']
Literal[value:'1']
Schedule[]
CodedKern matrix_vector_kernel_code(m_lumped,ones,mb) [module_inline=False]
Loop[type='dofs', field_space='any_space_1', it_space='dofs', upper_bound='ndofs']
Literal[value:'NOT_INITIALISED']
Literal[value:'NOT_INITIALISED']
Reference[name:'loop1_start']
Reference[name:'loop1_stop']
Literal[value:'1']
Schedule[]
BuiltIn x_divideby_y(self_mb_lumped_inv,ones,m_lumped)
Expand Down
2 changes: 1 addition & 1 deletion src/psyclone/psyir/nodes/literal.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Literal(DataNode):
_text_name = "Literal"
_colour = "yellow"
_real_value = r'^[+-]?[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?$'
_int_value = r'(([+-]?[0-9]+)|(NOT_INITIALISED))'
_int_value = r'([+-]?[0-9]+)'

def __init__(self, value, datatype, parent=None):
super().__init__(parent=parent)
Expand Down
11 changes: 0 additions & 11 deletions src/psyclone/tests/domain/lfric/lfric_loop_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,8 @@ def test_lower_to_language_normal_loop():
dist_mem=False, idx=0)
sched = invoke.schedule
loop1 = sched.children[1]
# FIXME: NOT_INITIALISED -> loop_bound symbol reference now happens
# dureing LFRicBound lowering in psy.gen, maybe this is wrong?
return
assert loop1.start_expr.symbol.name == "loop1_start"

# Now remove loop 0, and verify that the start variable symbol has changed
# (which is a problem in case of driver creation, since the symbol names
# written in the full code can then be different from the symbols used
# in the driver). TODO #1731 might fix this, in which case this test
# will fail (and the whole lowering of LFRicLoop can likely be removed).
sched.children.pop(0)
assert loop1.start_expr.symbol.name == "loop0_start"

# The same test with the lowered schedule should not change the
# symbol anymore:
_, invoke = get_invoke("4.8_multikernel_invokes.f90", TEST_API,
Expand Down
2 changes: 1 addition & 1 deletion src/psyclone/tests/psyir/nodes/literal_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_literal_init_invalid_3(value):
with pytest.raises(ValueError) as err:
Literal(value, INTEGER_SINGLE_TYPE)
assert (f"A scalar integer literal value must conform to the "
f"supported format ('(([+-]?[0-9]+)|(NOT_INITIALISED))') "
f"supported format ('([+-]?[0-9]+)') "
f"but found '{value}'." in str(err.value))


Expand Down
9 changes: 0 additions & 9 deletions src/psyclone/tests/psyir/nodes/loop_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,6 @@ def test_loop_navigation_properties():
with pytest.raises(InternalError) as err:
_ = loop.loop_body
assert error_str in str(err.value)
with pytest.raises(InternalError) as err:
loop.start_expr = Literal("NOT_INITIALISED", INTEGER_SINGLE_TYPE)
assert error_str in str(err.value)
with pytest.raises(InternalError) as err:
loop.stop_expr = Literal("NOT_INITIALISED", INTEGER_SINGLE_TYPE)
assert error_str in str(err.value)
with pytest.raises(InternalError) as err:
loop.step_expr = Literal("NOT_INITIALISED", INTEGER_SINGLE_TYPE)
assert error_str in str(err.value)

# Check that Getters properties work
loop.addchild(Schedule(parent=loop))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ in the description means `cells`!) with an upper loop bound of
```bash
InvokeSchedule[invoke='invoke_0', dm=False]
0: Loop[type='dofs', field_space='any_space_1', it_space='dof', upper_bound='ndofs']
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Reference[name:'loop0_start']
Reference[name:'loop0_stop']
Literal[value:'1', Scalar<INTEGER, UNDEFINED>]
Schedule[]
0: BuiltIn setval_c(grad_p,0.0_r_def)
1: Loop[type='', field_space='any_space_1', it_space='cell_column', upper_bound='ncells']
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Reference[name:'loop1_start']
Reference[name:'loop1_stop']
Literal[value:'1', Scalar<INTEGER, UNDEFINED>]
Schedule[]
0: CodedKern scaled_matrix_vector_code(grad_p,p,div_star,hb_inv) [module_inline=False]
Expand Down Expand Up @@ -149,8 +149,8 @@ whilst the rest have `check_dirty=True`.
```bash
InvokeSchedule[invoke='invoke_0', dm=True]
0: Loop[type='dofs', field_space='any_space_1', it_space='dof', upper_bound='ndofs']
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Reference[name:'loop0_start']
Reference[name:'loop0_stop']
Literal[value:'1', Scalar<INTEGER, UNDEFINED>]
Schedule[]
0: BuiltIn setval_c(grad_p,0.0_r_def)
Expand All @@ -159,8 +159,8 @@ InvokeSchedule[invoke='invoke_0', dm=True]
3: HaloExchange[field='div_star', type='region', depth=1, check_dirty=True]
4: HaloExchange[field='hb_inv', type='region', depth=1, check_dirty=True]
5: Loop[type='', field_space='any_space_1', it_space='cell_column', upper_bound='cell_halo(1)']
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Reference[name:'loop1_start']
Reference[name:'loop1_stop']
Literal[value:'1', Scalar<INTEGER, UNDEFINED>]
Schedule[]
0: CodedKern scaled_matrix_vector_code(grad_p,p,div_star,hb_inv) [module_inline=False]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ You will see that all halo exchanges have been converted to asynchronous halo ex
```bash
InvokeSchedule[invoke='invoke_0', dm=True]
0: Loop[type='dofs', field_space='any_space_1', it_space='dof', upper_bound='ndofs']
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Reference[name:'loop0_start']
Reference[name:'loop0_stop']
Literal[value:'1', Scalar<INTEGER, UNDEFINED>]
Schedule[]
0: BuiltIn setval_c(grad_p,0.0_r_def)
Expand Down Expand Up @@ -225,8 +225,8 @@ output. For example:
```bash
InvokeSchedule[invoke='invoke_0', dm=True]
0: Loop[type='dofs', field_space='any_space_1', it_space='dof', upper_bound='ndofs']
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Literal[value:'NOT_INITIALISED', Scalar<INTEGER, UNDEFINED>]
Reference[name:'loop0_start']
Reference[name:'loop0_stop']
Literal[value:'1', Scalar<INTEGER, UNDEFINED>]
Schedule[]
0: BuiltIn setval_c(grad_p,0.0_r_def)
Expand Down

0 comments on commit cd18e86

Please sign in to comment.