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

Document issue with Kokkos::sort and comparators #504

Merged

Conversation

masterleinad
Copy link
Contributor

that are forwarded to the TPL satisfy the sycl::is_device_copyable trait to avoid compiler errors. This holds true in particular
for comparators used with Kokkos::sort in Kokkos versions prior to 4.3. The best advice to give is to make sure the respective
parameters are trivially-copyable. If this isn't possible, sycl::is_device_copyable should be specialized and users should make
sure to use raw pointers instead of Kokkos::Views.
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a code example and include the compile error so that it can be easily found by users?

Copy link
Member

Choose a reason for hiding this comment

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

Kokkos::sort(exec, values, KOKKOS_LAMBDA(int i, int j) { return keys(i) < keys(j); });  // error blah with SYCL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SYCL
====

- Multiple of the Kokkos algorithm functions use third-party libraries like oneDPL.
Copy link
Member

Choose a reason for hiding this comment

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

"Multiple of" sounds weird to me.
Maybe "several" or "a number of"? Maybe a native English speaker can advise here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/usr/bin/compiler/../../include/sycl/handler.hpp:2332:5: note: (skipping 7 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
2332 | parallel_for_lambda_impl<KernelName, KernelType, 1, PropertiesT>(
| ^
[...]
Copy link
Member

Choose a reason for hiding this comment

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

Please add a Functor definition followed by a sycl::is_device_copyable traits specialization to showcase what the user is expected to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I meant also adding a definition for MyComparator and showing the actual Kokkos::sort invocation.
Do you think it is too obvious?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That commit changes the example into

MyComparator my_comparator;
     Kokkos::sort(exec, values, my_comparator);

I find this already to be pretty verbose and don't think we need to provide details on the potential implementation of MyComparator.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I thought you'd transform the lambda into that comparator thing.
I suppose that is good enough.

Copy link
Member

Choose a reason for hiding this comment

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

The error you posted was with a lambda though right? (Not necessarily asking you to update)

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, it was with a lambda but I printed only those errors that are independent of the example. The lambda referenced in it comes from oneDPL.

@dalg24 dalg24 merged commit e2ab511 into kokkos:main Apr 15, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants