Skip to content

appio: Mark intercepting functions as public such that they are properly linked when using the PAPI shared library#501

Merged
Treece-Burgess merged 1 commit intoicl-utk-edu:masterfrom
Treece-Burgess:10-30-2025-appio-intercept-shared-lib
Oct 31, 2025
Merged

appio: Mark intercepting functions as public such that they are properly linked when using the PAPI shared library#501
Treece-Burgess merged 1 commit intoicl-utk-edu:masterfrom
Treece-Burgess:10-30-2025-appio-intercept-shared-lib

Conversation

@Treece-Burgess
Copy link
Contributor

Pull Request Description

In the appio component, if you compile the tests appio_test_seek.c, appio_test_fread_fwrite.c, appio_test_read_write.c, appio_test_values_by_code.c, appio_test_values_by_name.c , and appio_test_pthreads.c with the PAPI shared library, the counter values will be zero:

[ICL:methane tests]$ gcc -I. -I../../.. -I../../../testlib -I../../../validation_tests appio_test_read_write.c -o appio_test_read_write ../../../testlib/libtestlib.a ../../../libpapi.so
[ICL:methane tests]$ ./appio_test_read_write
This program will read /etc/group and write it to /dev/null
----
OPEN_CALLS: 0
OPEN_FDS: 0
READ_CALLS: 0
READ_BYTES: 0
READ_USEC: 0
READ_ERR: 0
READ_INTERRUPTED: 0
READ_WOULD_BLOCK: 0
WRITE_CALLS: 0
WRITE_BYTES: 0
WRITE_USEC: 0
WRITE_WOULD_BLOCK: 0
PASSED

With the PAPI static library this does not occur.

Further, if we use LD_DEBUG=all on the executable for test_appio_read_write.c you will see that for open we bind with libc.so.6versions rather than our own implementation:

3890941: symbol=open;  lookup in file=/home/tburgess/papi_fork/papi/src/test-install/lib/libpapi.so.7.2 [0]
3890941: symbol=open;  lookup in file=/lib64/libc.so.6 [0]
3890941: binding file ./appio_test_read_write [0] to /lib64/libc.so.6 [0]: normal symbol `open' [GLIBC_2.2.5]

This PR resolves this behavior by explicitly setting our intercepting functions as public.

Testing

Testing was done on Methane at ICL with the setup of:

  • CPU: Intel Xeon Gold 6140
  • OS: Rocky Linux 9.6
  • GCC: 11.5

The aforementioned tests that returned 0 values when linking with the PAPI shared library now do not show zero values. Further, these values are comparable to the case of linking with the static library:

[ICL:methane tests]$ gcc -I. -I../../.. -I../../../testlib -I../../../validation_tests appio_test_read_write.c -o appio_test_read_write ../../../testlib/libtestlib.a ../../../libpapi.so
[ICL:methane tests]$ ./appio_test_read_write 
This program will read /etc/group and write it to /dev/null
----
OPEN_CALLS: 2
OPEN_FDS: 0
READ_CALLS: 2
READ_BYTES: 766
READ_USEC: 3
READ_ERR: 0
READ_INTERRUPTED: 0
READ_WOULD_BLOCK: 0
WRITE_CALLS: 1
WRITE_BYTES: 766
WRITE_USEC: 1
WRITE_WOULD_BLOCK: 0
PASSED

If we again look at the output when using LD_DEBUG=all on the executable for test_appio_read_write.c, you will now see we bind with our internal implementation of open:

symbol=open;  lookup in file=./appio_test_read_write [0]
symbol=open;  lookup in file=/home/tburgess/papi_fork/papi/src/test-install/lib/libpapi.so.7.2 [0]
binding file ./appio_test_read_write [0] to /home/tburgess/papi_fork/papi/src/test-install/lib/libpapi.so.7.2 [0]: normal symbol `open'

NOTE: The tests appio_test_blocking.c, appio_test_recv, appio_test_select, and appio_test_socket were not tested as they currently hang in the master branch and need to be addressed in a separate PR.

Author Checklist

  • Description
    Why this PR exists. Reference all relevant information, including background, issues, test failures, etc
  • Commits
    Commits are self contained and only do one thing
    Commits have a header of the form: module: short description
    Commits have a body (whenever relevant) containing a detailed description of the addressed problem and its solution
  • Tests
    The PR needs to pass all the tests

…rly linked when using the PAPI shared library
@Treece-Burgess Treece-Burgess added status-ready-for-review PR is ready to be reviewed type-bug Issues discussing bugs or PRs fixing bugs component-appio PRs and Issues related to the appio component labels Oct 30, 2025
@dbarry9
Copy link
Contributor

dbarry9 commented Oct 30, 2025

I am reviewing this PR.

@dbarry9
Copy link
Contributor

dbarry9 commented Oct 31, 2025

I have tested this pull request on the Frontier supercomputer (AMD Zen3 architecture, GCC 12.2.0). All PAPI utilities function properly. With the changes in this PR, I observe that the following appio component tests (built by dynamically linking PAPI) now return non-zero event counts, consistent with builds which statically link PAPI:

  • appio_test_fread_fwrite
  • appio_test_pthreads
  • appio_test_read_write
  • appio_test_seek
  • appio_values_by_name
  • appio_values_by_code

@Treece-Burgess In order to test that these changes had the intended effect on the component tests, I had to manually edit 'components/appio/tests/Makefile' to dynamically link PAPI to the targets. Should we make a variable in this Makefile that is commented-out by default, but can be toggled? This might be overkill, but it could be helpful for future testing.

@Treece-Burgess Treece-Burgess merged commit 487985f into icl-utk-edu:master Oct 31, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component-appio PRs and Issues related to the appio component status-ready-for-review PR is ready to be reviewed type-bug Issues discussing bugs or PRs fixing bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants