[rocprofiler-systems] Add Fortran main detection to rocprof-sys-instrument to avoid instrumenting around C "main" wrapper#1322
Merged
dgaliffiAMD merged 15 commits intoROCm:developfrom Oct 21, 2025
Conversation
dgaliffiAMD
reviewed
Oct 10, 2025
Contributor
There was a problem hiding this comment.
Thanks, @kcossett-amd. Your change looks good.
A couple additions that I would like to suggest:
- Add to the CHANGELOG
- Your note about the Cray compiler would be good to add to the document. There is a "Troubleshooting" section at the end of https://github.com/ROCm/rocm-systems/blob/develop/projects/rocprofiler-systems/docs/how-to/instrumenting-rewriting-binary-application.rst.
- If you haven't already added it to your other PR, I would recommend adding an example & test that would have fallen into this failing case.
Contributor
Author
|
@dgaliffiAMD The cray compiler issue was resolved (it generates "main" symbol that has same address as the Fortran main. So for PROGRAM hello, "hello_" and "main" have same address). Still, I added a general note to troubleshooting reminding the user that |
1 task
dgaliffiAMD
approved these changes
Oct 14, 2025
Contributor
dgaliffiAMD
left a comment
There was a problem hiding this comment.
Looks good to me.
@ROCm/rocm-documentation, please review documentation changes.
projects/rocprofiler-systems/docs/how-to/instrumenting-rewriting-binary-application.rst
Outdated
Show resolved
Hide resolved
projects/rocprofiler-systems/docs/how-to/instrumenting-rewriting-binary-application.rst
Outdated
Show resolved
Hide resolved
projects/rocprofiler-systems/docs/how-to/instrumenting-rewriting-binary-application.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Pratik Basyal <pratik.basyal@amd.com>
Co-authored-by: Pratik Basyal <pratik.basyal@amd.com>
Co-authored-by: Pratik Basyal <pratik.basyal@amd.com>
systems-assistant bot
pushed a commit
to ROCm/rocprofiler-systems
that referenced
this pull request
Oct 21, 2025
rocprof-sys-instrument to avoid instrumenting around C "main" wrapper (#1322) * Add check for Fortran main * Comment change * MAIN__ -> Fortran main * Cray Compiler comment change * Add changelog and troubleshooting comments * Improve CHANGELOG.md message * Change CHANGELOG msg to be in 7.2.0 * Apply review change #1 Co-authored-by: Pratik Basyal <pratik.basyal@amd.com> * Apply review change #2 Co-authored-by: Pratik Basyal <pratik.basyal@amd.com> * Apply review change #3 Co-authored-by: Pratik Basyal <pratik.basyal@amd.com> [rocm-systems] ROCm/rocm-systems#1322 (commit f0a41b6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Currently,
rocprof-sys-instrumentwill force themain_funcvariable to be eithermainor_main. This variable essentially dictates the primary function to instrument around.In Fortran programs, there is usually a C-style
mainwhich will call the Fortran main. This is usually not a problem as it will consider the Fortran main as a subroutine and instrument it. However, in the case where the Fortran main is non-returning (i.e. Dyninst determine that its FuncReturnStatus == NORETURN), it will not be instrumented. (See SWDEV-558265 for more details).The solution is to check if any of the Fortran main symbols exist and use them if possible.
Technical Details
Added check for Fortran main function. Uses regex.
Remove unused variable
_init_arg0.Test Plan
Tested using:
openmp-vv. Withamdflang, it will now center around_QQmain(Fortran main symbol for LLVM compilers).intervals_mpi.f90(this is part of the MPI CTest PR and is the original program where this issue was discovered). Withgfortran,binary-rewritewill now center aroundMAIN__(Fortran main symbol forgfortran).hello.f90program that forces the Fortran main to haveFuncReturnStatus == NORETURN. Withgfortran, it now centers itself aroundMAIN__.Test Result
openmp-vv, theomptraces are still present and the CTests pass.intervals_mpi.f90, the CTest passes and works on every workflow.Submission Checklist