Skip to content

rocp_sdk: multithreaded component test#603

Open
dbarry9 wants to merge 1 commit into
icl-utk-edu:masterfrom
dbarry9:2026.05.18_rocp_sdk_threads
Open

rocp_sdk: multithreaded component test#603
dbarry9 wants to merge 1 commit into
icl-utk-edu:masterfrom
dbarry9:2026.05.18_rocp_sdk_threads

Conversation

@dbarry9

@dbarry9 dbarry9 commented May 20, 2026

Copy link
Copy Markdown
Contributor

Pull Request Description

Add a component test that uses multiple threads.

These changes have been tested on the AMD MI300A architecture using ROCm version 7.2.0.

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

Comment thread src/components/rocp_sdk/tests/multi_pthreads.cpp Outdated
Comment thread src/components/rocp_sdk/tests/multi_pthreads.cpp Outdated

// Check if there was an error in any of the threads.
if( 0 != overall_status ) {
test_fail(__FILE__, __LINE__, "Encountered an error in one of the threads", PAPI_EMISC);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: For myself, I avoid using test_fail unless it is associated with a PAPI function call, i.e.:

int retval = PAPI_add_named_event( ... )
if (retval != PAPI_OK) {
    test_fail(__FILE__, __LINE__, "PAPI_add_named_event", retval);
}

As currently the output appears as:

Line # 81 Error in Encountered an error in one of the threads: Unknown error code

I tend to use, fprintf(stderr, "..."); exit(EXIT_FAILURE).

Comment thread src/components/rocp_sdk/tests/multi_pthreads.cpp Outdated
// PAPI front matter.
int retval = PAPI_library_init(PAPI_VER_CURRENT);
if( retval != PAPI_VER_CURRENT ) {
test_fail(__FILE__, __LINE__, "PAPI_library_init() failed", retval);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I would drop failed. As it would read better due to the format shown in the comment on line 81.


// Create event set.
int stat;
pthread_barrier_wait(&barrier);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q: For the PAPI calls, you setup pthread_barrier_wait, why do we need to wait at the barriers until all threads reach the barrier? Each thread appears that it will be self-contained.

Comment thread src/components/rocp_sdk/tests/multi_pthreads.cpp Outdated
// Join the threads.
for(int thdIdx = 0; thdIdx < ONT; ++thdIdx) {
pthread_join(tid[thdIdx], NULL);
if( status[thdIdx] != 0 ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I would suggest differentiating status to be papi_status and hip_status (or rocm_status).

Comment thread src/components/rocp_sdk/tests/kernel.cpp
Comment thread src/components/rocp_sdk/tests/multi_pthreads.cpp Outdated
@dbarry9 dbarry9 force-pushed the 2026.05.18_rocp_sdk_threads branch from c0438e8 to 6f0371a Compare May 26, 2026 19:47
Add a component test that uses multiple threads.

These changes have been tested on the AMD MI300A architecture using ROCm
version 7.2.0.
@dbarry9 dbarry9 force-pushed the 2026.05.18_rocp_sdk_threads branch from 6f0371a to 6bb2fa4 Compare May 27, 2026 16:39
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.

2 participants