Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Reduce the test scope for sort.cpp #670

Merged
merged 4 commits into from
Dec 24, 2021
Merged

Reduce the test scope for sort.cpp #670

merged 4 commits into from
Dec 24, 2021

Conversation

bader
Copy link

@bader bader commented Dec 23, 2021

This test takes ~50 sec to run in CI system, whereas most of other tests executed in < 5 sec.
There should be no value in running multiple problem sizes to validate
that sort works.

This test takes ~50 sec to run in CI system.
There should be no value in running multiple problem sizes to validate
that sort works.
@bader
Copy link
Author

bader commented Dec 23, 2021

@capatober, FYI.
I'd like to discuss testing strategy for sort algorithm. Is there any value in testing all combinations ?
I think something like <types x 64> + <int x sizes> should be good enough to catch most of the bugs. Right?

AlexeySachkov
AlexeySachkov previously approved these changes Dec 23, 2021
@andreyfe1
Copy link

@bader, thanks for informing me about these changes!
I've tried to cover as many cases as I could find. Cases are listed in the description for #438

Regarding the patch. The thing is that group sorting algorithm has different behavior depending on size of sequence (as other group algorithms):

  1. size is less than work-group size
  2. size is greater than work-group size, but data are processed by single work-group
  3. size is greater than work-group size, but data are processed by multiple work-groups

To reduce testing let's keep just 3 values: 1, 256, 1024. These 3 cases are matched to aforementioned 3 points. Other values are duplication.

Let's see how else we can reduce the testing.
Per my understanding, infrastructure issues shouldn't lead to testing coverage gaps.

  1. Data types: let's keep just int8_t, int32_t, std::size_t, sycl::half, double. Others can be removed.
  2. "reverse order" case can also be removed

@bader
Copy link
Author

bader commented Dec 23, 2021

@capatober, I've reduced work-group size and applied minor style fixes. Please, take a look.

vladimirlaz
vladimirlaz previously approved these changes Dec 24, 2021
@@ -38,14 +36,11 @@ struct CustomFunctor {
}
};

// we need it since using std::abs leads to compilation error
template <typename T> T my_abs(T x) { return x >= 0 ? x : -x; }

Choose a reason for hiding this comment

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

I'm ok with the change if there are no compilation errors related to abs as it's mentioned in the comment

Copy link
Author

Choose a reason for hiding this comment

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

As you can see in pre-commit logs, there no compilation errors. BTW, the comment is about std::abs, not sycl::abs.
I trusted your comment and didn't try to use std::abs here.

Choose a reason for hiding this comment

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

I see. Sorry, missed that there is sycl::abs now.

Copy link
Author

Choose a reason for hiding this comment

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

I checked std::abs and I see the problem.

llvm-test-suite/SYCL/GroupAlgorithm/SYCL2020/sort.cpp:40:10: error: call to 'abs' is ambiguous
  return std::abs(lhs - rhs) > epsilon;
         ^~~~~~~~
/llvm-test-suite/SYCL/GroupAlgorithm/SYCL2020/sort.cpp:49:9: note: in instantiation of function template specialization 'check<unsigned int>' requested here
    if (check(expected[i], got[i], epsilon)) {
        ^

Standard library doesn't provide abs overloads for unsigned integer types. It make sense, so the question is: why SYCL spec defines abs for unsigned integer types?

I suppose your code might not work as expected for unsigned types. I suggest you to think about it.

Choose a reason for hiding this comment

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

Thanks for pointing it out. What is your opinion whether sycl::abs for unsigned integer types is a bug or a feature of SYCL?

Copy link
Author

Choose a reason for hiding this comment

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

Technically, I don't any problems with defining such function, but the use case is unclear. This function does nothing, but return its only argument.
I suppose it wasn't intention to define such function. It's just the side effect of listing all supported OpenCL types as allowed parameters for integer functions.
@intel/dpcpp-specification-reviewers, FYI.

Copy link

Choose a reason for hiding this comment

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

I captured this question as a Kronos issue against the SYCL spec: https://gitlab.khronos.org/sycl/Specification/-/issues/584

andreyfe1
andreyfe1 previously approved these changes Dec 24, 2021
@@ -38,14 +36,11 @@ struct CustomFunctor {
}
};

// we need it since using std::abs leads to compilation error
template <typename T> T my_abs(T x) { return x >= 0 ? x : -x; }

Choose a reason for hiding this comment

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

I see. Sorry, missed that there is sycl::abs now.

@bader bader merged commit f779c7e into intel:intel Dec 24, 2021
@bader bader deleted the sort branch December 24, 2021 13:11
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
This test takes ~50 sec to run in CI system, whereas most of other tests executed in < 5 sec.
There should be no value in running multiple problem sizes to validate
that sort works.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants