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 explicit deduction guides for blocked_nd_range #1525

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

kboyarinov
Copy link
Contributor

@kboyarinov kboyarinov commented Oct 8, 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

@kboyarinov kboyarinov force-pushed the rarutyun/blocked_range_nd_class branch from 3fe65dc to 64610c6 Compare December 20, 2024 12:22
@kboyarinov kboyarinov changed the title Extend blocked_rangeNd CTAD PR with tests and explicit deduction guide Extend blocked_nd_range CTAD with tests and explicit deduction guide Dec 20, 2024
Base automatically changed from rarutyun/blocked_range_nd_class to master January 14, 2025 11:50
Copy link
Contributor

@akukanov akukanov left a comment

Choose a reason for hiding this comment

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

In addition to the notes below: it would be great to comment the guides explaining which ctor calls are covered by which.

Comment on lines 170 to 177
template <typename Value, unsigned int N>
blocked_nd_range(blocked_nd_range<Value, N>, oneapi::tbb::split)
-> blocked_nd_range<Value, N>;

template <typename Value, unsigned int N>
blocked_nd_range(blocked_nd_range<Value, N>, oneapi::tbb::proportional_split)
-> blocked_nd_range<Value, N>;

Copy link
Contributor

Choose a reason for hiding this comment

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

Splitting constructors are not really for users but for algorithms. Do we need deduction guides for these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think the main purpose of the splitting constructors are TBB algorithms that don't currently use CTAD. But they are still part of the specification and the user may expect that for some implementation these constructors can be covered by the implicit deduction guides (see short example here).
And also all of the other blocked ranges in TBB currently supports CTAD for splitting constructors implicitly.
It seems like the reason why they do not work for N-d range are the class layout of the current implementation.

I feel that these deduction guides can be excluded from the future specification, but should be added into the implementation.

Comment on lines 161 to 165
template <typename Value, unsigned int N,
typename = std::enable_if_t<(N != 2 && N != 3)>>
blocked_nd_range(const Value (&)[N])
-> blocked_nd_range<Value, N>;

Copy link
Contributor

Choose a reason for hiding this comment

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

What if the argument is explicitly an array of 2 or 3 elements, not a braced init list? Seems there is no deduction guide for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Passing single array of 2 or 3 elements should be considered as a valid use-case, but having an extra deduction guide for array of 2 or 3 will also cover the braced-init-list of size 2 and 3.
As we discussed braced-init-list of size 2 and 3 should not be supported because of ambiguity between 1-D range constructed from single blocked_range and 2/3-D range constructed from the array.
This use-case is the main open question in the RFC #1607

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed in the RFC, added support for both single array and single braced-init-list with preference to multi-dimensional ranges

#if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
//! Testing blocked_rangeNd deduction guides
//! \brief \ref interface
TEST_CASE("blocked_rangeNd deduction guides") {
Copy link
Contributor

Choose a reason for hiding this comment

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

The test misses any checks for constructing explicitly from an array. It needs to check construction from arrays of different sizes (incl. 2 and 3), with and without a grainsize argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 304 to 306
oneapi::tbb::blocked_range<int> dim_range(0, 100);

blocked_nd_range<int, 2> source_range(dim_range, dim_range);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we test with something more fancy than int for the value type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@kboyarinov kboyarinov changed the title Extend blocked_nd_range CTAD with tests and explicit deduction guide Add explicit deduction guides for blocked_nd_range Jan 22, 2025
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