Skip to content

PAPI debug: Explicitly include unistd.h for getpid#612

Merged
dbarry9 merged 1 commit into
icl-utk-edu:masterfrom
Treece-Burgess:06-01-2026-explicit-include-unistd
Jun 18, 2026
Merged

PAPI debug: Explicitly include unistd.h for getpid#612
dbarry9 merged 1 commit into
icl-utk-edu:masterfrom
Treece-Burgess:06-01-2026-explicit-include-unistd

Conversation

@Treece-Burgess

Copy link
Copy Markdown
Contributor

Pull Request Description

During development of the cuda_range component, I encountered the below compilation error on Godzilla at Oregon (CPU: Intel Xeon CPU E5-2680, GPU: NVIDIA RTX PRO 6000 Blackwell, GCC 8.5.0):

components/cuda_range/cupti_range_profiler.cpp: In function ‘void* search_and_load_shared_objects(std::__cxx11::string, const char*, std::vector<std::__cxx11::basic_string<char> >)’:
./papi_debug.h:54:122: error: ‘getpid’ was not declared in this scope
 #define DEBUGLABEL(a) if (_papi_hwi_thread_id_fn) fprintf(stderr, "%s:%s:%s:%d:%d:%#lx ",a,__FILE__, FUNC, __LINE__,(int)getpid(),_papi_hwi_thread_id_fn()); else fprintf(stderr, "%s:%s:%s:%d:%d ",a,__FILE__, FUNC, __LINE__, (int)getpid())

To resolve this error, unistd.h must be included in papi_debug.h as the declaration of getpid lives there.

I did not encounter this behavior on Methane at ICL; however, this is most likely due to an implicit include for unistd.h occurring. It is considered best practice to be explicit about includes that are needed.

Testing

After adding #include <unistd.h> to papi_debug.h the cuda_range component compiled fine.

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

@Treece-Burgess Treece-Burgess requested a review from dbarry9 June 1, 2026 22:08
@Treece-Burgess Treece-Burgess added status-ready-for-review PR is ready to be reviewed type-maintenance Update code to keep it compatible, secure, modern. labels Jun 1, 2026
@dbarry9

dbarry9 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

I'm reviewing this PR.

@dbarry9 dbarry9 force-pushed the 06-01-2026-explicit-include-unistd branch from bfa4a53 to cc5d43d Compare June 18, 2026 20:05
@dbarry9

dbarry9 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

I tested these changes on a system containing the AMD EPYC 7763 CPU (Zen3 architecture) using GCC 8.5.0 and 14.0.1. This feature branch compiled successfully and the PAPI utilities function properly.

@dbarry9 dbarry9 merged commit be2acdb into icl-utk-edu:master Jun 18, 2026
40 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status-ready-for-review PR is ready to be reviewed type-maintenance Update code to keep it compatible, secure, modern.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants