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

Fix mistaken logic in pthread creation #4157

Merged
merged 1 commit into from
Jul 14, 2021
Merged

Fix mistaken logic in pthread creation #4157

merged 1 commit into from
Jul 14, 2021

Conversation

PhilMiller
Copy link
Contributor

No description provided.

@PhilMiller
Copy link
Contributor Author

@stanmoore1 may want to test this cherry-picked on the latest release for any performance implication.

if (0 == pthread_attr_init(&attr) ||
0 == pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) ||
if (0 == pthread_attr_init(&attr) &&
0 == pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) &&
0 == pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) {
Copy link
Member

Choose a reason for hiding this comment

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

hm is this really &&? Not ||? Was it initially correct if any of these things are not set that it needs to recreated?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, should pthread_attr_destroy only be called if the pthread_attr_init call succeeded? The POSIX spec says that "[t]he behavior is undefined if the value specified by the attr argument to pthread_attr_destroy() does not refer to an initialized thread attributes object."

@crtrott crtrott added this to In progress in Kokkos Release 3.5 Jul 14, 2021
@crtrott crtrott moved this from In progress to Awaiting Feedback in Kokkos Release 3.5 Jul 14, 2021
@crtrott
Copy link
Member

crtrott commented Jul 14, 2021

That said maybe we don't want the conflict with the std::thread PR?

@crtrott crtrott merged commit 3510f0f into develop Jul 14, 2021
Kokkos Release 3.5 automation moved this from Awaiting Feedback to Done Jul 14, 2021
@dalg24 dalg24 deleted the pthread-attr branch July 21, 2021 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Developer: Phil Miller
Done in or before release 3.5
Development

Successfully merging this pull request may close these issues.

None yet

4 participants