Skip to content

[SYCL] Specific error messages for invalid properties on non pointer types #11843

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

Merged

Conversation

yug-intel
Copy link
Contributor

@yug-intel yug-intel commented Nov 9, 2023

This change adds specific error messages for invalid properties that are specified on non pointer types. This change is directly in the header annotated_arg.hpp and these checks are done before the check_property_list check which previously accounted for this but had a generic error message.

This change adds static asserts so that the error message specifies the invalid property and that it is invalid due to a non pointer type for the underlying data type.

For example, if the user tries to declare the following variable:

annotated_arg<int, decltype(properties{buffer_location<0>})> a;

The following error message is outputted:

error: static assertion failed due to requirement '!has_buffer_location': Property buffer_location cannot be specified for annotated_arg<T> when T is a non pointer type.
  288 |   static_assert(!has_buffer_location,
      |                 ^~~~~~~~~~~~~~~~~~~~

Prior to this change, the following generic error message was printed with multiple notes:

/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/common_annotated_properties/properties.hpp:59:17: error: static assertion failed due to requirement 'is_valid_property_for_given_type': Property is invalid for the given type.
   59 |   static_assert(is_valid_property_for_given_type,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:307:7: note: in instantiation of template class 'sycl::ext::oneapi::experimental::check_property_list<int, sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>' requested here
  307 |       check_property_list<T, Props...>::value;
      |       ^
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:308:17: note: in instantiation of static data member 'sycl::ext::oneapi::experimental::annotated_arg<int, sycl::ext::oneapi::experimental::properties<std::tuple<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>>>::contains_valid_properties' requested here
  308 |   static_assert(contains_valid_properties,
      |                 ^
temp.cpp:15:66: note: in instantiation of template class 'sycl::ext::oneapi::experimental::annotated_arg<int, sycl::ext::oneapi::experimental::properties<std::tuple<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>>>' requested here
   15 |     annotated_arg<int, decltype(properties{buffer_location<0>})> a;
      |                                                                  ^

Alternate Methods

PR #11748 adds the same checks but in the fpga_annotated_properties.hpp file as a separate check. This PR has the checks directly in the annotated_arg.hpp header file so that there are fewer notes printed below the error message. Here is a comparison of how the error message is outputted when the checks are in different files:

With error checks in properties header file and using a macro (PR #11748):

/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/intel/experimental/fpga_annotated_properties.hpp:396:3: error: static assertion failed due to requirement '!has_buffer_location': Property buffer_location cannot be specified for annotated_arg<T> when T is a non pointer type.
  396 |   CHECK_INVALID_PROPERTY(buffer_location, list)
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/intel/experimental/fpga_annotated_properties.hpp:389:17: note: expanded from macro 'CHECK_INVALID_PROPERTY'
  389 |   static_assert(!has_##property,                                               \
      |                 ^~~~~~~~~~~~~~~
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:202:25: note: in instantiation of template class 'sycl::ext::oneapi::experimental::detail::checkPropertiesForNonPointerType<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>' requested here
  202 |   static_assert(detail::checkPropertiesForNonPointerType<Props...>::value);
      |                         ^
temp.cpp:15:66: note: in instantiation of template class 'sycl::ext::oneapi::experimental::annotated_arg<int, sycl::ext::oneapi::experimental::properties<std::tuple<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>>>' requested here
   15 |     annotated_arg<int, decltype(properties{buffer_location<0>})> a;
      |                                                                  ^

With error check in annotated_arg header and using a macro:

/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:292:3: error: static assertion failed due to requirement '!has_buffer_location': Property buffer_location cannot be specified for annotated_arg<T> when T is a non pointer type.
  292 |   CHECK_INVALID_PROPERTY(buffer_location, property_tuple)
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:23:17: note: expanded from macro 'CHECK_INVALID_PROPERTY'
   23 |   static_assert(!has_##property,                                               \
      |                 ^~~~~~~~~~~~~~~
temp.cpp:15:66: note: in instantiation of template class 'sycl::ext::oneapi::experimental::annotated_arg<int, sycl::ext::oneapi::experimental::properties<std::tuple<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>>>' requested here
   15 |     annotated_arg<int, decltype(properties{buffer_location<0>})> a;
      |                                                                  ^

This Change

With error check in annotated_arg header and not using a macro (This PR):

/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:288:17: error: static assertion failed due to requirement '!has_buffer_location': Property buffer_location cannot be specified for annotated_arg<T> when T is a non pointer type.
  288 |   static_assert(!has_buffer_location,
      |                 ^~~~~~~~~~~~~~~~~~~~
temp.cpp:15:66: note: in instantiation of template class 'sycl::ext::oneapi::experimental::annotated_arg<int, sycl::ext::oneapi::experimental::properties<std::tuple<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>>>' requested here
   15 |     annotated_arg<int, decltype(properties{buffer_location<0>})> a;
      |                                                                  ^

This version only prints one note and therefore it is more clear for the user.

@yug-intel yug-intel marked this pull request as ready for review November 9, 2023 21:15
@yug-intel yug-intel requested a review from a team as a code owner November 9, 2023 21:15
@yug-intel
Copy link
Contributor Author

@againull Could you merge this PR?

@dm-vodopyanov dm-vodopyanov merged commit 728b132 into intel:sycl Nov 14, 2023
@yug-intel yug-intel deleted the error-message-for-invalid-property branch November 14, 2023 19:17
wangdi4 pushed a commit to wangdi4/llvm that referenced this pull request Dec 12, 2023
…types (intel#11843)

This change adds specific error messages for invalid properties that are
specified on non pointer types. This change is directly in the header
annotated_arg.hpp and these checks are done before the
`check_property_list` check which previously accounted for this but had
a generic error message.

This change adds static asserts so that the error message specifies the
invalid property and that it is invalid due to a non pointer type for
the underlying data type.

For example, if the user tries to declare the following variable: 

```cpp
annotated_arg<int, decltype(properties{buffer_location<0>})> a;
```

The following error message is outputted: 

```
error: static assertion failed due to requirement '!has_buffer_location': Property buffer_location cannot be specified for annotated_arg<T> when T is a non pointer type.
  288 |   static_assert(!has_buffer_location,
      |                 ^~~~~~~~~~~~~~~~~~~~
```

Prior to this change, the following generic error message was printed
with multiple notes:

```
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/common_annotated_properties/properties.hpp:59:17: error: static assertion failed due to requirement 'is_valid_property_for_given_type': Property is invalid for the given type.
   59 |   static_assert(is_valid_property_for_given_type,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:307:7: note: in instantiation of template class 'sycl::ext::oneapi::experimental::check_property_list<int, sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>' requested here
  307 |       check_property_list<T, Props...>::value;
      |       ^
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:308:17: note: in instantiation of static data member 'sycl::ext::oneapi::experimental::annotated_arg<int, sycl::ext::oneapi::experimental::properties<std::tuple<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>>>::contains_valid_properties' requested here
  308 |   static_assert(contains_valid_properties,
      |                 ^
temp.cpp:15:66: note: in instantiation of template class 'sycl::ext::oneapi::experimental::annotated_arg<int, sycl::ext::oneapi::experimental::properties<std::tuple<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>>>' requested here
   15 |     annotated_arg<int, decltype(properties{buffer_location<0>})> a;
      |                                                                  ^
```

### Alternate Methods

PR intel#11748 adds the same checks but in
the `fpga_annotated_properties.hpp` file as a separate check. This PR
has the checks directly in the `annotated_arg.hpp` header file so that
there are fewer notes printed below the error message. Here is a
comparison of how the error message is outputted when the checks are in
different files:

With error checks in properties header file and using a macro (PR
intel#11748):

```
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/intel/experimental/fpga_annotated_properties.hpp:396:3: error: static assertion failed due to requirement '!has_buffer_location': Property buffer_location cannot be specified for annotated_arg<T> when T is a non pointer type.
  396 |   CHECK_INVALID_PROPERTY(buffer_location, list)
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/intel/experimental/fpga_annotated_properties.hpp:389:17: note: expanded from macro 'CHECK_INVALID_PROPERTY'
  389 |   static_assert(!has_##property,                                               \
      |                 ^~~~~~~~~~~~~~~
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:202:25: note: in instantiation of template class 'sycl::ext::oneapi::experimental::detail::checkPropertiesForNonPointerType<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>' requested here
  202 |   static_assert(detail::checkPropertiesForNonPointerType<Props...>::value);
      |                         ^
temp.cpp:15:66: note: in instantiation of template class 'sycl::ext::oneapi::experimental::annotated_arg<int, sycl::ext::oneapi::experimental::properties<std::tuple<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>>>' requested here
   15 |     annotated_arg<int, decltype(properties{buffer_location<0>})> a;
      |                                                                  ^
```

With error check in annotated_arg header and using a macro: 

```
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:292:3: error: static assertion failed due to requirement '!has_buffer_location': Property buffer_location cannot be specified for annotated_arg<T> when T is a non pointer type.
  292 |   CHECK_INVALID_PROPERTY(buffer_location, property_tuple)
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:23:17: note: expanded from macro 'CHECK_INVALID_PROPERTY'
   23 |   static_assert(!has_##property,                                               \
      |                 ^~~~~~~~~~~~~~~
temp.cpp:15:66: note: in instantiation of template class 'sycl::ext::oneapi::experimental::annotated_arg<int, sycl::ext::oneapi::experimental::properties<std::tuple<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>>>' requested here
   15 |     annotated_arg<int, decltype(properties{buffer_location<0>})> a;
      |                                                                  ^
```

### This Change

With error check in annotated_arg header and not using a macro (This
PR):

```
/p/psg/swip/w/yugteshs/sycl_include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp:288:17: error: static assertion failed due to requirement '!has_buffer_location': Property buffer_location cannot be specified for annotated_arg<T> when T is a non pointer type.
  288 |   static_assert(!has_buffer_location,
      |                 ^~~~~~~~~~~~~~~~~~~~
temp.cpp:15:66: note: in instantiation of template class 'sycl::ext::oneapi::experimental::annotated_arg<int, sycl::ext::oneapi::experimental::properties<std::tuple<sycl::ext::oneapi::experimental::property_value<sycl::ext::intel::experimental::buffer_location_key, std::integral_constant<int, 0>>>>>' requested here
   15 |     annotated_arg<int, decltype(properties{buffer_location<0>})> a;
      |                                                                  ^
 ```
 
 This version only prints one note and therefore it is more clear for the user.
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.

3 participants