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

[oneDPL][ranges][tests] a fix for std::ranges::<algo> using with Windows C++ standard library. #1920

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

MikeDvorskiy
Copy link
Contributor

[oneDPL][ranges][tests] a fix for std::ranges::sort using with Windows C++ standard library.
This PR is a sequel for #1885.

@dmitriy-sobolev dmitriy-sobolev added the test Test only Change label Oct 23, 2024
@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/std_ranges_test_sort_fix_windows branch 2 times, most recently from a4b1db9 to 6f8de9b Compare October 23, 2024 16:52
@@ -21,18 +21,24 @@ main()
#if _ENABLE_STD_RANGES_TESTING
using namespace test_std_ranges;
namespace dpl_ranges = oneapi::dpl::ranges;
auto sort_checker =
#if _ONEDPL_STD_RANGES_ALGO_CPP_FUN
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you introduce a similar macro in the tests in order not to rely on oneDPL internals?

Copy link
Contributor Author

@MikeDvorskiy MikeDvorskiy Oct 24, 2024

Choose a reason for hiding this comment

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

I still strong disagree to make the code duplication.
Rather lets consider a an option to make public that macro....

Copy link
Contributor

@dmitriy-sobolev dmitriy-sobolev Oct 24, 2024

Choose a reason for hiding this comment

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

I do not think that having a public macro for that is a good idea given that it is a workaround for a niche issue, not resulting in enablement of any oneDPL feature. Also, I understand that duplication increases maintenance burden,
but I would duplicate this small code section to decouple the tests and implementation. I guess we need a mediator here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Relocating my comment here, I missed this discussion in my initial review. I agree with Dmitriy here, this has been the convention as established by @akukanov.

We have tried to stay away from using internal helpers / utilities / implementation details in our tests.

If we want to use the same macro here, I think we probably want to re-define it here test/support/utils.h, or somewhere similar as _TEST_PREPARE_CALLABLE, or something like that, then use that throughout the tests.

@MikeDvorskiy MikeDvorskiy changed the title [oneDPL][ranges][tests] a fix for std::ranges::sort using with Windows C++ standard library. [oneDPL][ranges][tests] a fix for std::ranges::<algo> using with Windows C++ standard library. Oct 24, 2024
@@ -333,4 +333,11 @@
# define _ONEDPL_STD_RANGES_ALGO_CPP_FUN 0
#endif

#if _ONEDPL_STD_RANGES_ALGO_CPP_FUN
# define _ONEDPL_ALGO(std_algo_name) \
[](auto&&... __args) { return std_algo_name(std::forward<decltype(__args)>(__args)...); }
Copy link
Contributor

Choose a reason for hiding this comment

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

Will not it be better to move that utility in a separate header, e.g. utils.h?
A "config" usually contains well some settings, e.g. to enable workarounds, rather than workarounds themselves. Also, having a macro (which are generelly avoided) looks unnecessary to resolve that particular issue.

Copy link
Contributor Author

@MikeDvorskiy MikeDvorskiy Oct 24, 2024

Choose a reason for hiding this comment

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

To tell the truth, practically, many macro wrappers were accumulated in onedpl_config.h. F.e. a lot of _ONEDPL_PRAGMA_SIMD wrappers. Proposed _ONEDPL_ALGO is a kind of macro wrapper as _ONEDPL_PRAGMA_SIMD.
File utils.h, traditionally, contains C/C++ functions/utilities.

Copy link
Contributor

Choose a reason for hiding this comment

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

I implied creation of a function instead of a macro in utils.h, but perhaps it is a matter of taste, so I do not insist.

Copy link
Contributor Author

@MikeDvorskiy MikeDvorskiy Oct 25, 2024

Choose a reason for hiding this comment

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

No, it is not "it is a matter of taste"...
Of course I prefer a function too... But there is no way to write a function here.

Copy link
Contributor

Choose a reason for hiding this comment

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

But it is possible to write a function in utils.h, if I understood you correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I agree that this is more of a "utility" than a "configuration". I understand the motivation to group preprocessor macros together, and utility functions together, but the concept seems more important to me.
I think I would be in favor of keeping _ONEDPL_STD_RANGES_ALGO_CPP_FUN definition here, and moving the rest to "utils.h", but I also wont insist.

Copy link
Contributor

@dmitriy-sobolev dmitriy-sobolev left a comment

Choose a reason for hiding this comment

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

The PR solves the problem, but I cannot decide whether to approve it or not due to the approach (using internal macro in the tests, using a macro, where it is possible to have an ordinary function). Let's add more reviewers for more opinions.

@@ -333,4 +333,11 @@
# define _ONEDPL_STD_RANGES_ALGO_CPP_FUN 0
#endif

#if _ONEDPL_STD_RANGES_ALGO_CPP_FUN
# define _ONEDPL_ALGO(std_algo_name) \
Copy link
Contributor

@danhoeflinger danhoeflinger Nov 6, 2024

Choose a reason for hiding this comment

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

Nitpick: _ONEDPL_ALGO is not very descriptive.
Something like _ONEDPL_PREPARE_FUNCTION_OBJ, or _ONEDPL_PREPARE_CALLABLE or something would be more descriptive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't mind _ONEDPL_PREPARE_CALLABLE macro name

@danhoeflinger
Copy link
Contributor

I think I agree with the clang-format suggestions, but not a blocker for me.

@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/std_ranges_test_sort_fix_windows branch from 0188ba1 to d6b8e9b Compare November 7, 2024 11:22
@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/std_ranges_test_sort_fix_windows branch from d6b8e9b to 322e0ea Compare November 7, 2024 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Test only Change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants