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

2483 support derived types in driver #2706

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

Conversation

hiker
Copy link
Collaborator

@hiker hiker commented Sep 3, 2024

Adds support for the drivers to properly read in derived type (using non-derived Fortran variables based on the actual basic type of the members).

Copy link

codecov bot commented Sep 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.89%. Comparing base (6afc06a) to head (14c1d56).
Report is 151 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2706   +/-   ##
=======================================
  Coverage   99.89%   99.89%           
=======================================
  Files         359      359           
  Lines       51073    51114   +41     
=======================================
+ Hits        51021    51062   +41     
  Misses         52       52           

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

@hiker hiker added LFRic Issue relates to the LFRic domain PSyData NG-ARCH Issues relevant to the GPU parallelisation of LFRic and other models expected to be used in NG-ARCH labels Dec 17, 2024
@hiker
Copy link
Collaborator Author

hiker commented Feb 9, 2025

To clarify: this does not support passing derived types to subroutines (upcoming PR for 2830_support_user_defined_type_arguments), it only handles the case that a subroutine somewhere uses a member

@hiker hiker added PSyKE Related to the kernel extraction and driver creation PSyKE and removed PSyData labels Feb 13, 2025
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.

Thanks for this Joerg. Functionally it all looks OK but I do have questions about array accesses in structures and structure accesses of greater depths.
Aside from that, I'm not entirely comfortable about the Signature <-> PSyIR interface and think it should perhaps be the other way around. It's not a biggie for this PR though.
I'll launch the integration tests next time (unless you fancy doing it when you arrive at the office in the morning?).

from psyclone.psyir.nodes import Reference, StructureReference

if self.is_structure:
ref = StructureReference.create(symbol, list(self._signature[1:]))
Copy link
Member

Choose a reason for hiding this comment

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

What about arrays?

I have to admit that having a Signature method take a Symbol and give back PSyIR feels like the wrong way around. I think StructureReference should perhaps have a new create_from_signature method? That way, we might not need the imports either.

@@ -98,7 +106,8 @@ def add_result_tests(program, output_symbols):
values that have been read in from a file.
:type output_symbols: list[tuple[
:py:class:`psyclone.psyir.symbols.Symbol`,
:py:class:`psyclone.psyir.symbols.Symbol`]]
:py:class:`psyclone.psyir.symbols.Symbol`,
:py:class:`psyclone.core.signature.Signature`]]
Copy link
Member

Choose a reason for hiding this comment

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

Could this be a Reference instead - that way we use PSyIR consistently?

datatype=sym.datatype)
if module_name:
post_tag = f"{name}{postfix}@{module_name}"
if module_name and hasattr(sym.datatype, "interface"):
Copy link
Member

Choose a reason for hiding this comment

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

A TypedSymbol always has an interface so (hopefully) you don't need the hasattr?

post_name = f"{flat_name}_{module_name}{postfix}"
mod_man = ModuleManager.get()
mod_info = mod_man.get_module_info(module_name)
datatype = mod_info.get_symbol(sym.datatype.name)
Copy link
Member

Choose a reason for hiding this comment

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

A bit picky but for clarity I suggest s/datatype/sym/ or something as it is a symbol, not a datatype.

if isinstance(datatype, DataTypeSymbol):
# This is a structure. We need to create a flattened name
# and find the base type of the member involved
datatype = datatype.datatype
Copy link
Member

Choose a reason for hiding this comment

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

If you had a Reference here, this would just be ref.datatype. That would also allow for array subsections which I don't think you cover here?

@@ -420,7 +422,7 @@ def _add_all_kernel_symbols(self, sched, symbol_table, proxy_name_mapping,

# -------------------------------------------------------------------------
@staticmethod
def _create_output_var_code(name, program, is_input, read_var,
def _create_output_var_code(signature, program, is_input, read_var,
Copy link
Member

Choose a reason for hiding this comment

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

The docstring for the name argument needs to be updated.

("routine", None, "unknown_subroutine")]
)
("routine", None, "unknown_subroutine"),
('unknown', 'module_with_var_mod', 'user_var%member_read_write'),
Copy link
Member

Choose a reason for hiding this comment

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

Now that I look at this, would this work for arbitrary-depth references, e.g. user_var%member%this_one%read_write?

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 NG-ARCH Issues relevant to the GPU parallelisation of LFRic and other models expected to be used in NG-ARCH PSyKE Related to the kernel extraction and driver creation PSyKE reviewed with actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants