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

Add get_all_called_routine function to CallTreeUtils #2871

Open
hiker opened this issue Jan 24, 2025 · 4 comments
Open

Add get_all_called_routine function to CallTreeUtils #2871

hiker opened this issue Jan 24, 2025 · 4 comments
Assignees
Labels
NG-ARCH Issues relevant to the GPU parallelisation of LFRic and other models expected to be used in NG-ARCH

Comments

@hiker
Copy link
Collaborator

hiker commented Jan 24, 2025

ATM the call tree utilities return all symbols used, but there is no (easy) way to get name and location of all routines called. Add this functionality, which will likely require a refactoring of the existing functionality to avoid code duplication - I expected that the get all symbols functionality will first call get all routines, then query all the subroutines (while atm this is done all at once).

@hiker hiker self-assigned this Jan 24, 2025
@hiker hiker added the NG-ARCH Issues relevant to the GPU parallelisation of LFRic and other models expected to be used in NG-ARCH label Jan 24, 2025
@arporter
Copy link
Member

I must be missing something here Joerg. Why isn't it as a simple as routines = [call.routine for call in psyir.walk(Call)]? Is it because of function 'calls' that we don't spot?

@sergisiso
Copy link
Collaborator

They should now also be returned by node.reference_access() and filter for AccessType.CALLED

@hiker
Copy link
Collaborator Author

hiker commented Jan 24, 2025

Ah, I should have mentioned recursively - this will follow the whole (static) call tree (as far as possible that is).

@hiker
Copy link
Collaborator Author

hiker commented Jan 24, 2025

I'll find a better name. As an example, here what my (currently still hacky) branch does (call_tree.py just prints the output of this function):

  psyclone -l output --psykal-dsl lfric -s ./call_tree.py \
                     -d... .../casim_alg_mod.x90
        [('casim_code', 'casim_kernel_mod'),
        ('mphys_air_density', 'mphys_air_density_mod'),
        ('dr_hook', 'yomhook'),
        ('allocate_diagnostic_space', 'generic_diagnostic_variables'),
        ('shipway_microphysics', 'micro_main'),
        ('zero_procs', 'process_routines'),
        ('set_passive_fields', 'passive_fields'),
        ('throw_mphys_error', 'mphys_die'),
        ('ereport', 'ereport_mod'),
        ('log_event', 'log_mod'),
        ('traceback', 'traceback_mod'),
        ('abort_model', 'log_mod'),
        ('microphysics_common', 'micro_main'),
        ('tidy_qin', 'mphys_tidy'),
        ('recompute_qin_constants', 'mphys_tidy'),
        ('casim_reflec', 'casim_reflec_mod'),
        ('query_distributions', 'distributions'),
        ('get_slope_generic_kf', 'lookup'),
        ('casim_moments', 'casim_moments_mod'),
        ('get_lam_n0_3m', 'lookup'),
        ('get_lam_n0_2m', 'lookup'),
        ('get_lam_n0_1m', 'lookup'),
        ('get_lam_n0_1m_kf', 'lookup'),
        ('get_slope_generic', 'lookup'),
        ('deallocate_diagnostic_space',
        ('generic_diagnostic_variables')]

NIWA started to do this kind of analysis manually to identify the scope of work required to get (all) of a function on GPU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NG-ARCH Issues relevant to the GPU parallelisation of LFRic and other models expected to be used in NG-ARCH
Projects
None yet
Development

No branches or pull requests

3 participants