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

#2711 DoF Kernel Code Generation #2712

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open

Conversation

oakleybrunt
Copy link
Collaborator

@oakleybrunt oakleybrunt commented Sep 16, 2024

Closes #2711 which has a checklist of actions taken

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.86%. Comparing base (59668bb) to head (681581b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2712   +/-   ##
=======================================
  Coverage   99.86%   99.86%           
=======================================
  Files         354      354           
  Lines       48963    48980   +17     
=======================================
+ Hits        48899    48916   +17     
  Misses         64       64           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@oakleybrunt oakleybrunt self-assigned this Sep 19, 2024
@oakleybrunt oakleybrunt added ready for review LFRic Issue relates to the LFRic domain labels Sep 19, 2024
Copy link
Member

@arporter arporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good first step @oakleybrunt, thank you. You'll see that I think we can do away with the new property you've added and thus shorten the code and tests somewhat.

In reading the Developer Guide, I also discovered that it needs updating - please see https://psyclone-dev.readthedocs.io/en/latest/APIs.html#loop-iterators and update it slightly.

I'll launch the integration tests next time round but I don't anticipate any issues.

doc/user_guide/dynamo0p3.rst Outdated Show resolved Hide resolved
doc/user_guide/dynamo0p3.rst Outdated Show resolved Hide resolved
doc/user_guide/dynamo0p3.rst Outdated Show resolved Hide resolved
src/psyclone/domain/lfric/kern_call_arg_list.py Outdated Show resolved Hide resolved
src/psyclone/domain/lfric/kern_call_arg_list.py Outdated Show resolved Hide resolved
src/psyclone/tests/domain/lfric/dofkern_test.py Outdated Show resolved Hide resolved
src/psyclone/tests/domain/lfric/dofkern_test.py Outdated Show resolved Hide resolved
src/psyclone/tests/domain/lfric/dofkern_test.py Outdated Show resolved Hide resolved
src/psyclone/tests/dynamo0p3_stubgen_test.py Outdated Show resolved Hide resolved
src/psyclone/tests/domain/lfric/dofkern_test.py Outdated Show resolved Hide resolved
@arporter
Copy link
Member

Is there a possibility that when ACC transformations happen, the KernCallArgList is remade with no checks for where the arguments originate from? I'm not entirely sure what's happening

I think the sub-class KernCallACCArgList is used to work out what data needs to be transferred to the GPU. Perhaps this method gets called by that class?

@oakleybrunt
Copy link
Collaborator Author

I think the sub-class KernCallACCArgList is used to work out what data needs to be transferred to the GPU. Perhaps this method gets called by that class?

That is exactly what's happening. Does this mean that the isinstance check is justified, or that another change needs to be made?

@arporter
Copy link
Member

That is exactly what's happening. Does this mean that the isinstance check is justified, or that another change needs to be made?

It probably means that you need to override this method in KernCallACCArgList and make sure that it provides the correct list of arguments for an ACC enter data directive. For a field, this will just be its name, irrespective of whether or not the kernel operates on cell columns or dofs (which is different from the kernel argument that this method in this class is generating).

Copy link
Member

@arporter arporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking very nice now Oakley, thanks. Well done for minimising the code changes.
Some of the new methods you've added need explicit tests. (We have a rule that the test battery associated with a given source file should give 100% coverage of that file. In some places we're still working towards this ambition but all new code should have appropriate tests added.)
I've also realised that we probably need more 'functional' tests as there's lots that can go wrong when adding an important new concept like this. Please could you add a test that Dynamo0p3RedundantComputationTrans (https://psyclone-ref.readthedocs.io/en/latest/_static/html/classpsyclone_1_1transformations_1_1Dynamo0p3RedundantComputationTrans.html) works when applied to one of the new dof kernels.
You'll need to check that the halo-exchanges are to the correct depth.
Please could you also construct a more complex test invoke that mixes kernels that operate on cell-columns, user kernels that operate on dofs and, finally, builtin kernels.
You could base this off e.g. test_files/dynamo0p3/3.1_multi_functions_multi_invokes.f90 but you needn't bother with multiple invokes.
In the meantime, I've also fired off the integration tests but it's going to take a while for them to run.

@@ -93,6 +93,27 @@ def cell_position(self, var_accesses=None):
_, ref = self.cell_ref_name(var_accesses)
self.append(ref.symbol.name)

def field(self, arg, var_accesses=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for this method to tests/domain/lfric/kern_call_acc_arg_list_test.py

@@ -557,6 +557,19 @@ def base_name(self):
'''
return self._base_name

@property
def undf_name(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for this method in tests/domain/lfric/lfric_kern_test.py.

assert 'undf' in test_fs._var_list


def test_compiles(tmpdir):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test can go now.

assert LFRicBuild(tmpdir).code_compiles(psy)


def test_undf_initialisation(tmpdir):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test can probably go now unless it is covering something specific to dof kernels.

" loop0_stop = f1_proxy%vspace%get_last_dof_owned()"
)

# Shared memory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annexed only has any effect if distributed-memory is enabled so you can simplify this to elif not dist_mem:

@arporter
Copy link
Member

arporter commented Oct 18, 2024

Unfortunately the compilation checks failed:
image
Looks like you just need proper declarations for the arguments to the test kernel.

You can test this locally by doing pytest --compile ....

@oakleybrunt
Copy link
Collaborator Author

oakleybrunt commented Oct 21, 2024

As I am working on making the dof kernel (src/psyclone/tests/test_files/dynamo0p3/testkern_dofs_mod.f90) compile, I noticed again that the arguments passed to the subroutine are single dofs, real or integer. This makes me question why we are passing undf to the kernel call at all. Originally, I thought it would be used for creating an array (e.g dimension(undf)), but I don't see a use for it here, much like it isn't passed to LFRic built-ins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LFRic Issue relates to the LFRic domain ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DoF kern code generation checklist
2 participants