-
Notifications
You must be signed in to change notification settings - Fork 74
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
implement alpaka::concepts::Tag #2403
Conversation
include/alpaka/acc/Tag.hpp
Outdated
#define CREATE_ACC_TAG(tag_name) \ | ||
struct tag_name \ | ||
struct tag_name : public concepts::Implements<alpaka::ConceptTag, tag_name> \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to introduce the ConceptTag
to make the class unique. Otherwise the only property to identify a alpaka tag is the helper static class function get_name
, which is not unique.
Maybe we should think about to rename alpaka::concepts
because it confuses now, than we have C++20 concepts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked what alpaka::concepts::Implements
is actual doing and if we can replace it with C++20 concepts.
The answer is no, because it implements a type hierarchy like in Julia with type traits. It is possible to do it with C++ concepts but nothing which is already provided by the STL.
Therefore I suggest to rename alpaka::concepts
to alpaka::type_hierarchy
and also the corresponding function and structs to avoid confusions with C++20 concepts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In an offline discussion with @fwyzard he suggested alpaka::interfaces
. I like the idea, because actual this mechanism imitates traits from other languages but traits has already a meaning in alpaka. Therefore interface is a good solution because it sounds like java interfaces which is pretty similar.
@alpaka-group/alpaka-maintainers I was thinking about naming concepts. Here it is easy because I the case of
In the case of template class deduction this can confuse: // use the class alpaka::Queue, deducts the argument from the function call
alpaka::Queue queue = create_queue();
// use the concept alpaka::Queue
alpaka::Queue auto queue2 = create_queue(); The C++ standard makes clear, where classes and where concepts are used. But without the context, like in the documentation, it is hard to distinguish. Possible solutions:
What do you think? |
What is the syntax for using concepts ? |
Have a look in this commit: 37c62ed Also interesting is, what is the error message. Try to call the functions |
You can also write something like this: template<typename T>
requires std::integral<T>
T gcd(T a, T b) {
if( b == 0 ) return a;
else return gcd(b, a % b);
} But I prefer the version, which I used because it uses less boilerplate code and looks more intuitive. |
a61e591
to
3527b00
Compare
I am a friend of namespaces and not mangling all into names. |
No, I agree that template<std::integral T> looks cleaner. |
👍🏻 |
To avoid confusion, we could rename the current namespace and classes called "Concept" to "Interface" ? |
I agree with you. And I was thinking about, when you need this template<typename T, typename U>
concept foo = requires { requires std::is_same_v<T,U>; };
template<typename T, typename U>
void bar() requires foo<T,U> {} But if we can do it, we should use the first syntax. |
I agree with the idea. So let's rename the current By the way. All our namespaces are singular. But we cannot use |
85c3302
to
6526078
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alpaka::concepts::Tag
should be concepts::Tag
.
Except in the tests if we are not in the alpaka namespace.
6526078
to
8ebdb6e
Compare
- remove support for Clang 10 until 12 because the C++20 Concepts are not fully supported
66a3e24
to
9015f07
Compare
First alpaka C++20 concept :-) I think there are several points to discuss.
Implement
alpaka::concept::Tag
which checks the requirements for an alpaka tag.Remove support Clang 10, 11 and 12 because they are not fully supports C++20 concepts.