-
Notifications
You must be signed in to change notification settings - Fork 752
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
[SYCL] Update validation of annotated_arg/annotated_ptr parameterization #10437
base: sycl
Are you sure you want to change the base?
Conversation
@@ -76,6 +76,9 @@ __SYCL_TYPE(annotated_arg) annotated_arg<T *, detail::properties_t<Props...>> { | |||
public: | |||
static_assert(is_property_list<property_list_t>::value, | |||
"Property list is invalid."); | |||
static_assert( | |||
validate_annotated_type<annotated_arg<T *, property_list_t>>::value, | |||
"The property list contains invalid property."); |
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 hope in a future update we can make this better? Which property is invalid? Why is it invalid? Not gating on this.
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 see better errors are bellow.
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.
Make sure to add some test files.
struct validate_annotated_type< | ||
annotated_arg<T, detail::properties_t<Prop, Props...>>> | ||
: std::conditional_t<is_valid_property<T, Prop>::value && | ||
is_property_value_of_annotated_arg<Prop>::value, | ||
validate_annotated_type< | ||
annotated_arg<T, detail::properties_t<Props...>>>, | ||
std::false_type> { | ||
static_assert( | ||
is_valid_property<T, Prop>::value, | ||
"Property is invalid for the underlying type of annotated_arg."); | ||
static_assert(is_property_value_of_annotated_arg<Prop>::value, | ||
"Property is not supported for annotated_arg."); | ||
}; |
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.
Due to the static_assert
inside the body, it seems unnecessary to check them in the conditional too. It would make sense if std::conditional
didn't evaluate both branches, but it does. However, I believe you can prevent further checks if you move the recursive use of validate_annotated_type
to after the static_assert
.
That is, I would prefer one of:
struct validate_annotated_type< | |
annotated_arg<T, detail::properties_t<Prop, Props...>>> | |
: std::conditional_t<is_valid_property<T, Prop>::value && | |
is_property_value_of_annotated_arg<Prop>::value, | |
validate_annotated_type< | |
annotated_arg<T, detail::properties_t<Props...>>>, | |
std::false_type> { | |
static_assert( | |
is_valid_property<T, Prop>::value, | |
"Property is invalid for the underlying type of annotated_arg."); | |
static_assert(is_property_value_of_annotated_arg<Prop>::value, | |
"Property is not supported for annotated_arg."); | |
}; | |
struct validate_annotated_type< | |
annotated_arg<T, detail::properties_t<Prop, Props...>>> | |
: validate_annotated_type<annotated_arg<T, detail::properties_t<Props...>>> { | |
static_assert( | |
is_valid_property<T, Prop>::value, | |
"Property is invalid for the underlying type of annotated_arg."); | |
static_assert(is_property_value_of_annotated_arg<Prop>::value, | |
"Property is not supported for annotated_arg."); | |
}; |
or
struct validate_annotated_type< | |
annotated_arg<T, detail::properties_t<Prop, Props...>>> | |
: std::conditional_t<is_valid_property<T, Prop>::value && | |
is_property_value_of_annotated_arg<Prop>::value, | |
validate_annotated_type< | |
annotated_arg<T, detail::properties_t<Props...>>>, | |
std::false_type> { | |
static_assert( | |
is_valid_property<T, Prop>::value, | |
"Property is invalid for the underlying type of annotated_arg."); | |
static_assert(is_property_value_of_annotated_arg<Prop>::value, | |
"Property is not supported for annotated_arg."); | |
}; | |
struct validate_annotated_type< | |
annotated_arg<T, detail::properties_t<Prop, Props...>>> { | |
static_assert( | |
is_valid_property<T, Prop>::value, | |
"Property is invalid for the underlying type of annotated_arg."); | |
static_assert(is_property_value_of_annotated_arg<Prop>::value, | |
"Property is not supported for annotated_arg."); | |
static constexpr bool value = validate_annotated_type<annotated_arg<T, detail::properties_t<Props...>>>::value; | |
}; |
where (to my knowledge) the latter would stop at the first invalid property.
template <typename T, typename... Props> | ||
struct check_property_list : std::true_type {}; | ||
struct validate_annotated_type<annotated_arg<T, detail::properties_t<Props...>>> | ||
: std::true_type {}; |
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.
Isn't the detail::properties_t<>
the only case that hits this? If so, we might as well make that clear in the definition:
template <typename T>
struct validate_annotated_type<annotated_arg<T, detail::properties_t<>>>
: std::true_type {};
This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days. |
Hey @wangdi4 , I think we implemented this later in some other PR, please verify and close this one. |
Update the validation of annotated_arg/annotated_pointer type parameterization as follows. Given a parameterized
annotated_arg<T, PropertyList>
orannotated_arg<T, PropertyList>
, validate the type from two aspects:T
, pointer-specific properties are not allowed if T is not pointer. E.g.,buffer_location<N>
is not applicable for non pointers.alignment<N>
is only supported for anntoated_ptr, whilerestrict
is only supported for annotated_arg. Therefore this PR each property inPropertyList
must be supported for annotated_arg (or anntoated_ptr)