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

Add reference implementation for parallel_block feature #1570

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

isaevil
Copy link
Contributor

@isaevil isaevil commented Nov 26, 2024

Description

Add a comprehensive description of proposed changes

Fixes # - issue number(s) if exists

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add a respective label(s) to PR if you have permissions

  • bug fix - change that fixes an issue
  • new feature - change that adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and some bug fixes
  • not needed

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Notify the following users

List users with @ to send notifications

Other information

@isaevil isaevil changed the title Add reference implementation of parallel_block feature Add reference implementation for parallel_block feature Nov 26, 2024
@isaevil
Copy link
Contributor Author

isaevil commented Nov 27, 2024

@akukanov @aleksei-fedotov @vossmjp Could you please take a look at the PR in terms of implementation and ABI.

P.S. Tests are still WIP.

Signed-off-by: Isaev, Ilya <[email protected]>
Signed-off-by: Isaev, Ilya <[email protected]>
Copy link
Contributor

@aleksei-fedotov aleksei-fedotov left a comment

Choose a reason for hiding this comment

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

Not a complete review, just a couple of starters to think about.

Comment on lines 60 to +67
if (is_worker_should_leave(slot)) {
if (!governor::hybrid_cpu()) {
if (
#if __TBB_PREVIEW_PARALLEL_BLOCK
!my_arena.my_thread_leave.should_leave()
#else
!governor::hybrid_cpu()
#endif
)
Copy link
Contributor

Choose a reason for hiding this comment

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

A readability issue. These should_leave functions do not convey any additional meaning except for whether thread should leave or not. In this case I would move all the logic into single main should_leave function, which would include a set of probes with more meaningful names the "leaving" algorithm is based on, such as below "my_arena.my_threading_control->is_any_other_client_active()" or "is_recall_requested". In my opinion, the general "should_leave" name is good for the most embracing function of such kind, not a set of smaller functions that check various parts of the system.

src/tbb/arena.h Outdated Show resolved Hide resolved
src/tbb/arena.h Outdated Show resolved Hide resolved

#if __TBB_PREVIEW_PARALLEL_BLOCK
TBB_EXPORT void __TBB_EXPORTED_FUNC register_parallel_block(d1::task_arena_base&);
TBB_EXPORT void __TBB_EXPORTED_FUNC unregister_parallel_block(d1::task_arena_base&, bool);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we anticipate any future extension? In other words, does it make sense to accept an untyped pointer for any future details?

Suggested change
TBB_EXPORT void __TBB_EXPORTED_FUNC unregister_parallel_block(d1::task_arena_base&, bool);
TBB_EXPORT void __TBB_EXPORTED_FUNC unregister_parallel_block(d1::task_arena_base&, void* /*supplemental details*/);

Also, I don't think single bit can be passed. At least a word (or even more?) is used anyway. Then, it makes sense to accept at least that width and do not kill opportunity for future extensions:

Suggested change
TBB_EXPORT void __TBB_EXPORTED_FUNC unregister_parallel_block(d1::task_arena_base&, bool);
TBB_EXPORT void __TBB_EXPORTED_FUNC unregister_parallel_block(d1::task_arena_base&, unsigned short/*supplemental details*/);

Please double check what size of information is passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I also have been thinking about that. Perhaps we should pass std::uintptr_t instead of void*?

isaevil and others added 2 commits November 28, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants