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 ability for users to specify PAPI events in Dr Hook #27

Open
wants to merge 33 commits into
base: develop
Choose a base branch
from

Conversation

Andrew-Beggs-ECMWF
Copy link

This PR extends #26 by allowing users to specify their own PAPI events (up to MAXNPAPICNTRS, defaulting to 4). This is done with the DR_HOOK_PAPI_COUNTERS flag. If the flag is not specified, and PAPI is enabled, then the following defaults will be chosen:
PAPI_TOT_CYC
PAPI_FP_OPS
PAPI_L1_DCA
PAPI_L2_DCM

If an invalid event is chosen, then DrHook will simply crash will an appropriate error message.

Other commits are also included, which tidy up error messages introduced in #26.

Currently in draft mode to allow for review while adding tests.

MartynF and others added 4 commits July 24, 2024 16:16

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@FussyDuck
Copy link

FussyDuck commented Aug 21, 2024

CLA assistant check
All committers have signed the CLA.

@wdeconinck
Copy link
Collaborator

That looks all like good improvements. Thanks @Andrew-Beggs-ECMWF for doing the review + modifications of #26 .
Only remark I have is to watch the whitespacing for some of the added lines.

Ultimately you (or someone else?) that looks at benchmarking IFS should be happy with this feature and sign off that everything works as expected.

Andrew-Beggs-ECMWF added a commit to Andrew-Beggs-ECMWF/fiat that referenced this pull request Aug 28, 2024
This commit removes all tabs, in favour of two spaces, in files touched by ecmwf-ifs#26 and ecmwf-ifs#27.
@Andrew-Beggs-ECMWF
Copy link
Author

That should be all the tabs banished : )

I found that CMake tests aren't quite powerful enough to do the tests that I was envisioning. So I think you're right that it might just be a case of a "works on my machine" guarantee, which should be fine as I've tested it on our hpc2020 machine.

This new print clarifies what the next set of prints are referring to.

It also slightly optimises the subsequent control flow.
This allows user to specify their own PAPI events (up to MAXNPAPICNTRS, defaulting to 4).
This is done with the DR_HOOK_PAPI_COUNTERS flag. If the flag is not specified, and PAPI
is enabled, then the following defaults will be chosen:
PAPI_TOT_CYC
PAPI_FP_OPS
PAPI_L1_DCA
PAPI_L2_DCM

If an invalid event is chosen, then DrHook will simply crash will an appropriate error message.
This commit removes all tabs, in favour of two spaces, in files touched by ecmwf-ifs#26 and ecmwf-ifs#27.
@Andrew-Beggs-ECMWF
Copy link
Author

Just adding a comment that I intend to do some work to this PR to better align it with how extensions are handled in #28. After that I think it should be good to go : )

# Conflicts:
#	src/fiat/drhook/drhook.c
While PAPI code was behind #ifdefs, opt_papi was only used for toggling the printing of counters. PAPI would still be running as part of DrHook. To be inline with other options, PAPI is now behind both #ifdefs statically and if (opt_papi) dynamically.
The qualifier needed to be removed so that malloc_drhook() could be used from within drhook_papi.c. To try and retain some restricted scoping (albeit no longer enforced by the compiler), malloc_drhook() hasn't been added to a header and extern is needed to use it.
Also fixed some related white spacing
Previously nproc was initialised to 0. This meant that get_mon_out() wouldn't work as expected when not using MPI due to a bad assumption in an if statement.
When outputting the value of DR_HOOK_PAPI_COUNTERS, the info prefix was missing.
dr_hook_procinfo() now separates the setting of myproc & nproc from the reporting of initialising MPI. It will now initialise both myproc and nproc to 1 if DrHook is not running with MPI. To report the state of MPI, the new parameter mpi_init will be used.
Tests that any counters over MAXNPAPICNTRS are silently dropped.
Previously set_tests_properties() would fail because it couldn't find  fiat_test_drhook_papi_mpi_valid_csv to add properties to. This was because fiat_test_drhook_papi_mpi_valid_csv was behind a condition that required MPI, while set_tests_properties() was not.
Copy link
Collaborator

@wdeconinck wdeconinck left a comment

Choose a reason for hiding this comment

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

Great improvements!

Prevents errors of not finding a test when trying to set properties.
Used to ensure type safety between C and Fortran for DR_HOOK_PROCINFO()
Tests were accidentally searching for the wrong string in the regex check
@Andrew-Beggs-ECMWF Andrew-Beggs-ECMWF marked this pull request as ready for review November 19, 2024 16:20
@wdeconinck wdeconinck requested a review from ioanhadade February 6, 2025 15:35
Copy link
Collaborator

@wdeconinck wdeconinck left a comment

Choose a reason for hiding this comment

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

I think this is good.
Perhaps this can be rebased on latest develop, and then I'd like @ioanhadade to test this too.

@Andrew-Beggs-ECMWF Andrew-Beggs-ECMWF changed the base branch from papi to develop February 10, 2025 15:46
Previously papi.h was needed by drhook_papi.h, even when building without PAPI. Now it is only needed when PAPI is requested as the type is defined locally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants