Skip to content

Conversation

@loumalouomega
Copy link
Member

@loumalouomega loumalouomega commented Nov 27, 2025

📝 Description

Use ParallelUtilities::IsInParallel() instead of legacy OpenMPUtils in DataValueContainer. Also minor clean up.

🆕 Changelog

@loumalouomega loumalouomega requested a review from a team as a code owner November 27, 2025 14:56
@loumalouomega loumalouomega added Cleanup Kratos Core FastPR This Pr is simple and / or has been already tested and the revision should be fast Legacy Old code not maintained labels Nov 27, 2025
@loumalouomega loumalouomega changed the title [Core] Use ParallelUtilities::GetNumThreads() instead of legacy OpenMPUtils in DataValueContainer [Core] Use ParallelUtilities::IsInParallel() instead of legacy OpenMPUtils in DataValueContainer Nov 27, 2025
Comment on lines 98 to 101
* @brief Wrapper for omp_in_parallel()
* @return Maximum number of OpenMP threads that will be used in parallel regions.
*/
[[nodiscard]] static int IsInParallel();
Copy link
Member

Choose a reason for hiding this comment

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

this was deliberately not added so far since there is no good solution for Cxx-based parallelisation. I did lots of testing on this, but couldnt get it to work
IIRC the main issue was that the main-thread contributes also in the parallel loop, thus its not as simple as to just check if the current thread-id is different from the main-thread id

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's what I found, that why I only return in OMP

Copy link
Member

Choose a reason for hiding this comment

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

my reasoning for not adding it was that if it doesnt work generally it shouldnt be in the ParallelUtils

Its sth OpenMP specific, thus should remain there until we figure it out

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, otherwise we will never remove the legacy OMPUtils. An alternative is to simply hardcode it in OMP

Copy link
Member

Choose a reason for hiding this comment

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

someone should probably invest more time to solve it properly rather than hiding the issue ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooooookay......

Copy link
Member

Choose a reason for hiding this comment

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

my opinion, feel free to ignore 🙃

Copy link
Member Author

Choose a reason for hiding this comment

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

Of course, I don't have time to invest on that. Anyway no one is using the C++11 parallel and we should support the C++17 which was actually game changer.

@philbucher philbucher removed the FastPR This Pr is simple and / or has been already tested and the revision should be fast label Nov 28, 2025
return 1;
#endif
}

Copy link
Member

Choose a reason for hiding this comment

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

yes, as @philbucher pointed out, this one was deliberately left out. We should NOT use this to be forward compatible

Copy link
Member Author

Choose a reason for hiding this comment

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

In that case I will simply hardcode it

@matekelemen
Copy link
Contributor

My two cents is that we shouldn't even construct an entry in GetValue if it's not already there. It's a super confusing difference between the const and non-const versions of the function and can introduce all sorts of silent bugs.

@philbucher
Copy link
Member

My two cents is that we shouldn't even construct an entry in GetValue if it's not already there. It's a super confusing difference between the const and non-const versions of the function and can introduce all sorts of silent bugs.

Oh boy, probably one of the biggest bugOrfeature discussions :D
See also #3712

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cleanup Kratos Core Legacy Old code not maintained

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants