|
| 1 | +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s |
| 2 | + |
| 3 | +#include "sycl/sycl.hpp" |
| 4 | +#include <sycl/ext/intel/fpga_extensions.hpp> |
| 5 | + |
| 6 | +using namespace sycl::ext::oneapi::experimental; |
| 7 | +using namespace sycl::ext::intel::experimental; |
| 8 | + |
| 9 | +static annotated_ptr<int, decltype(properties())> AnnotatedPtr1; |
| 10 | +static annotated_ptr<int, decltype(properties(register_map))> AnnotatedPtr2; |
| 11 | +static annotated_ptr<int, decltype(properties(conduit, stable))> AnnotatedPtr3; |
| 12 | +static annotated_ptr<int, decltype(properties(buffer_location<1>, |
| 13 | + read_write_mode_read, stable, |
| 14 | + conduit))> |
| 15 | + AnnotatedPtr4; |
| 16 | + |
| 17 | +struct A {}; |
| 18 | + |
| 19 | +// Checks is_property_key_of and is_property_value_of for T. |
| 20 | +template <typename T> void checkIsPropertyOf() { |
| 21 | + static_assert(is_property_key_of<register_map_key, T>::value); |
| 22 | + static_assert(is_property_key_of<conduit_key, T>::value); |
| 23 | + static_assert(is_property_key_of<stable_key, T>::value); |
| 24 | + |
| 25 | + static_assert(is_property_key_of<buffer_location_key, T>::value); |
| 26 | + static_assert(is_property_key_of<awidth_key, T>::value); |
| 27 | + static_assert(is_property_key_of<dwidth_key, T>::value); |
| 28 | + static_assert(is_property_key_of<latency_key, T>::value); |
| 29 | + static_assert(is_property_key_of<read_write_mode_key, T>::value); |
| 30 | + static_assert(is_property_key_of<maxburst_key, T>::value); |
| 31 | + static_assert(is_property_key_of<wait_request_key, T>::value); |
| 32 | + |
| 33 | + static_assert(is_property_value_of<decltype(register_map), T>::value); |
| 34 | + static_assert(is_property_value_of<decltype(conduit), T>::value); |
| 35 | + static_assert(is_property_value_of<decltype(stable), T>::value); |
| 36 | + |
| 37 | + static_assert(is_property_value_of<decltype(buffer_location<1>), T>::value); |
| 38 | + static_assert(is_property_value_of<decltype(awidth<2>), T>::value); |
| 39 | + static_assert(is_property_value_of<decltype(dwidth<8>), T>::value); |
| 40 | + static_assert(is_property_value_of<decltype(latency<0>), T>::value); |
| 41 | + static_assert(is_property_value_of<decltype(read_write_mode_read), T>::value); |
| 42 | + static_assert(is_property_value_of<decltype(maxburst<1>), T>::value); |
| 43 | + static_assert( |
| 44 | + is_property_value_of<decltype(wait_request_requested), T>::value); |
| 45 | +} |
| 46 | + |
| 47 | +// Checks is_property_key_of and is_property_value_of are false for non-pointer |
| 48 | +// type T. |
| 49 | +template <typename T> void checkIsValidPropertyOfNonPtr() { |
| 50 | + static_assert( |
| 51 | + is_valid_property<T, decltype(wait_request_not_requested)>::value == |
| 52 | + false); |
| 53 | + static_assert(is_valid_property<T, decltype(latency<8>)>::value == false); |
| 54 | +} |
| 55 | + |
| 56 | +int main() { |
| 57 | + static_assert(is_property_key<register_map_key>::value); |
| 58 | + static_assert(is_property_key<buffer_location_key>::value); |
| 59 | + |
| 60 | + checkIsPropertyOf<decltype(AnnotatedPtr1)>(); |
| 61 | + static_assert(!AnnotatedPtr1.has_property<register_map_key>()); |
| 62 | + static_assert(!AnnotatedPtr1.has_property<buffer_location_key>()); |
| 63 | + |
| 64 | + checkIsPropertyOf<decltype(AnnotatedPtr2)>(); |
| 65 | + static_assert(AnnotatedPtr2.has_property<register_map_key>()); |
| 66 | + static_assert(!AnnotatedPtr2.has_property<conduit_key>()); |
| 67 | + static_assert(!AnnotatedPtr2.has_property<buffer_location_key>()); |
| 68 | + static_assert(AnnotatedPtr2.get_property<register_map_key>() == register_map); |
| 69 | + |
| 70 | + checkIsPropertyOf<decltype(AnnotatedPtr3)>(); |
| 71 | + static_assert(!AnnotatedPtr3.has_property<register_map_key>()); |
| 72 | + static_assert(AnnotatedPtr3.has_property<conduit_key>()); |
| 73 | + static_assert(AnnotatedPtr3.has_property<stable_key>()); |
| 74 | + static_assert(!AnnotatedPtr3.has_property<buffer_location_key>()); |
| 75 | + static_assert(AnnotatedPtr3.get_property<stable_key>() == stable); |
| 76 | + static_assert(AnnotatedPtr3.get_property<conduit_key>() == conduit); |
| 77 | + |
| 78 | + checkIsPropertyOf<decltype(AnnotatedPtr4)>(); |
| 79 | + static_assert(!AnnotatedPtr4.has_property<register_map_key>()); |
| 80 | + static_assert(AnnotatedPtr4.has_property<conduit_key>()); |
| 81 | + static_assert(AnnotatedPtr4.has_property<stable_key>()); |
| 82 | + static_assert(AnnotatedPtr4.has_property<buffer_location_key>()); |
| 83 | + static_assert(AnnotatedPtr4.has_property<read_write_mode_key>()); |
| 84 | + static_assert(AnnotatedPtr4.get_property<conduit_key>() == conduit); |
| 85 | + static_assert(AnnotatedPtr4.get_property<stable_key>() == stable); |
| 86 | + static_assert(AnnotatedPtr4.get_property<buffer_location_key>() == |
| 87 | + buffer_location<1>); |
| 88 | + static_assert(AnnotatedPtr4.get_property<read_write_mode_key>() == |
| 89 | + read_write_mode_read); |
| 90 | + |
| 91 | + // Check if a property is valid for a given type |
| 92 | + checkIsValidPropertyOfNonPtr<A>(); |
| 93 | + |
| 94 | + // expected-error-re@sycl/ext/oneapi/experimental/annotated_ptr/annotated_ptr.hpp:* {{static assertion failed due to requirement {{.+}}: FPGA Interface properties (i.e. awidth, dwidth, etc.) can only be set with BufferLocation together.}} |
| 95 | + annotated_ptr<int, decltype(properties(read_write_mode_read))> AnnotatedPtr5; |
| 96 | + return 0; |
| 97 | +} |
0 commit comments