@@ -465,6 +465,40 @@ template <int Dims> class AccessorImplDevice {
465
465
}
466
466
};
467
467
468
+ // CRTP class supplying a common definition of owner-before ordering for
469
+ // accessors.
470
+ template <class AccessorT > class AccessorOwnerLessBase {
471
+ public:
472
+ #ifndef __SYCL_DEVICE_ONLY__
473
+ // / Compares the accessor against a weak object using an owner-based
474
+ // / implementation-defined ordering.
475
+ // /
476
+ // / \param Other is the weak object to compare ordering against.
477
+ // / \return true if this object precedes \param Other and false otherwise.
478
+ bool ext_oneapi_owner_before (
479
+ const ext::oneapi::detail::weak_object_base<AccessorT> &Other)
480
+ const noexcept {
481
+ return static_cast <const AccessorT *>(this )->impl .owner_before (
482
+ ext::oneapi::detail::getSyclWeakObjImpl (Other));
483
+ }
484
+
485
+ // / Compares the accessor against another accessor using an owner-based
486
+ // / implementation-defined ordering.
487
+ // /
488
+ // / \param Other is the object to compare ordering against.
489
+ // / \return true if this object precedes \param Other and false otherwise.
490
+ bool ext_oneapi_owner_before (const AccessorT &Other) const noexcept {
491
+ return static_cast <const AccessorT *>(this )->impl .owner_before (Other.impl );
492
+ }
493
+ #else
494
+ bool ext_oneapi_owner_before (
495
+ const ext::oneapi::detail::weak_object_base<AccessorT> &Other)
496
+ const noexcept ;
497
+
498
+ bool ext_oneapi_owner_before (const AccessorT &Other) const noexcept ;
499
+ #endif
500
+ };
501
+
468
502
class AccessorImplHost ;
469
503
470
504
void __SYCL_EXPORT addHostAccessorAndWait (AccessorImplHost *Req);
@@ -543,6 +577,8 @@ class __SYCL_EXPORT LocalAccessorBaseHost {
543
577
template <class Obj >
544
578
friend Obj detail::createSyclObjFromImpl (decltype (Obj::impl) ImplObj);
545
579
580
+ template <class AccessorT > friend class AccessorOwnerLessBase ;
581
+
546
582
LocalAccessorImplPtr impl;
547
583
};
548
584
@@ -988,7 +1024,10 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
988
1024
public detail::AccessorBaseHost,
989
1025
#endif
990
1026
public detail::accessor_common<DataT, Dimensions, AccessMode, AccessTarget,
991
- IsPlaceholder, PropertyListT> {
1027
+ IsPlaceholder, PropertyListT>,
1028
+ public detail::AccessorOwnerLessBase<
1029
+ accessor<DataT, Dimensions, AccessMode, AccessTarget, IsPlaceholder,
1030
+ PropertyListT>> {
992
1031
protected:
993
1032
static_assert ((AccessTarget == access::target::global_buffer ||
994
1033
AccessTarget == access::target::constant_buffer ||
@@ -2145,34 +2184,6 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
2145
2184
bool operator ==(const accessor &Rhs) const { return impl == Rhs.impl ; }
2146
2185
bool operator !=(const accessor &Rhs) const { return !(*this == Rhs); }
2147
2186
2148
- #ifndef __SYCL_DEVICE_ONLY__
2149
- // / Compares the accessor against a weak object using an owner-based
2150
- // / implementation-defined ordering.
2151
- // /
2152
- // / \param Other is the weak object to compare ordering against.
2153
- // / \return true if this object precedes \param Other and false otherwise.
2154
- bool ext_oneapi_owner_before (
2155
- const ext::oneapi::detail::weak_object_base<accessor> &Other)
2156
- const noexcept {
2157
- return impl.owner_before (ext::oneapi::detail::getSyclWeakObjImpl (Other));
2158
- }
2159
-
2160
- // / Compares the accessor against another accessor using an owner-based
2161
- // / implementation-defined ordering.
2162
- // /
2163
- // / \param Other is the object to compare ordering against.
2164
- // / \return true if this object precedes \param Other and false otherwise.
2165
- bool ext_oneapi_owner_before (const accessor &Other) const noexcept {
2166
- return impl.owner_before (Other.impl );
2167
- }
2168
- #else
2169
- bool ext_oneapi_owner_before (
2170
- const ext::oneapi::detail::weak_object_base<accessor> &Other)
2171
- const noexcept ;
2172
-
2173
- bool ext_oneapi_owner_before (const accessor &Other) const noexcept ;
2174
- #endif
2175
-
2176
2187
iterator begin () const noexcept {
2177
2188
return iterator::getBegin (
2178
2189
get_pointer (),
@@ -2678,7 +2689,10 @@ template <typename DataT, int Dimensions, access::mode AccessMode,
2678
2689
access::placeholder IsPlaceholder>
2679
2690
class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
2680
2691
access::target::local, IsPlaceholder>
2681
- : public local_accessor_base<DataT, Dimensions, AccessMode, IsPlaceholder> {
2692
+ : public local_accessor_base<DataT, Dimensions, AccessMode, IsPlaceholder>,
2693
+ public detail::AccessorOwnerLessBase<
2694
+ accessor<DataT, Dimensions, AccessMode, access::target::local,
2695
+ IsPlaceholder>> {
2682
2696
2683
2697
using local_acc =
2684
2698
local_accessor_base<DataT, Dimensions, AccessMode, IsPlaceholder>;
@@ -2704,44 +2718,17 @@ class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
2704
2718
range>::template get<0 >();
2705
2719
}
2706
2720
2707
- bool ext_oneapi_owner_before (
2708
- const ext::oneapi::detail::weak_object_base<accessor> &Other)
2709
- const noexcept ;
2710
- bool ext_oneapi_owner_before (const accessor &Other) const noexcept ;
2711
-
2712
2721
#else
2713
2722
private:
2714
2723
accessor (const detail::AccessorImplPtr &Impl) : local_acc{Impl} {}
2715
-
2716
- public:
2717
- // / Compares the accessor against a weak object using an owner-based
2718
- // / implementation-defined ordering.
2719
- // /
2720
- // / \param Other is the weak object to compare ordering against.
2721
- // / \return true if this object precedes \param Other and false otherwise.
2722
- bool ext_oneapi_owner_before (
2723
- const ext::oneapi::detail::weak_object_base<accessor> &Other)
2724
- const noexcept {
2725
- return local_acc::impl.owner_before (
2726
- ext::oneapi::detail::getSyclWeakObjImpl (Other));
2727
- }
2728
-
2729
- // / Compares the accessor against another accessor using an owner-based
2730
- // / implementation-defined ordering.
2731
- // /
2732
- // / \param Other is the object to compare ordering against.
2733
- // / \return true if this object precedes \param Other and false otherwise.
2734
- bool ext_oneapi_owner_before (const accessor &Other) const noexcept {
2735
- return local_acc::impl.owner_before (Other.impl );
2736
- }
2737
-
2738
2724
#endif
2739
2725
};
2740
2726
2741
2727
template <typename DataT, int Dimensions = 1 >
2742
2728
class __SYCL_SPECIAL_CLASS __SYCL_TYPE (local_accessor) local_accessor
2743
2729
: public local_accessor_base<DataT, Dimensions, access::mode::read_write,
2744
- access::placeholder::false_t> {
2730
+ access::placeholder::false_t>,
2731
+ public detail::AccessorOwnerLessBase<local_accessor<DataT, Dimensions>> {
2745
2732
2746
2733
using local_acc =
2747
2734
local_accessor_base<DataT, Dimensions, access::mode::read_write,
@@ -2768,35 +2755,8 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
2768
2755
range>::template get<0 >();
2769
2756
}
2770
2757
2771
- bool ext_oneapi_owner_before (
2772
- const ext::oneapi::detail::weak_object_base<local_accessor> &Other)
2773
- const noexcept ;
2774
- bool ext_oneapi_owner_before (const local_accessor &Other) const noexcept ;
2775
-
2776
2758
#else
2777
2759
local_accessor (const detail::AccessorImplPtr &Impl) : local_acc{Impl} {}
2778
-
2779
- public:
2780
- // / Compares the local_accessor against a weak object using an owner-based
2781
- // / implementation-defined ordering.
2782
- // /
2783
- // / \param Other is the weak object to compare ordering against.
2784
- // / \return true if this object precedes \param Other and false otherwise.
2785
- bool ext_oneapi_owner_before (
2786
- const ext::oneapi::detail::weak_object_base<local_accessor> &Other)
2787
- const noexcept {
2788
- return local_acc::impl.owner_before (
2789
- ext::oneapi::detail::getSyclWeakObjImpl (Other));
2790
- }
2791
-
2792
- // / Compares the local_accessor against another local_accessor using an
2793
- // / owner-based implementation-defined ordering.
2794
- // /
2795
- // / \param Other is the object to compare ordering against.
2796
- // / \return true if this object precedes \param Other and false otherwise.
2797
- bool ext_oneapi_owner_before (const local_accessor &Other) const noexcept {
2798
- return local_acc::impl.owner_before (Other.impl );
2799
- }
2800
2760
#endif
2801
2761
2802
2762
public:
@@ -2864,7 +2824,10 @@ class __SYCL_SPECIAL_CLASS
2864
2824
__SYCL_TYPE (accessor) accessor<DataT, Dimensions, AccessMode,
2865
2825
access::target::image, IsPlaceholder>
2866
2826
: public detail::image_accessor<DataT, Dimensions, AccessMode,
2867
- access::target::image, IsPlaceholder> {
2827
+ access::target::image, IsPlaceholder>,
2828
+ public detail::AccessorOwnerLessBase<
2829
+ accessor<DataT, Dimensions, AccessMode, access::target::image,
2830
+ IsPlaceholder>> {
2868
2831
private:
2869
2832
accessor (const detail::AccessorImplPtr &Impl)
2870
2833
: detail::image_accessor<DataT, Dimensions, AccessMode,
@@ -2911,34 +2874,6 @@ __SYCL_TYPE(accessor) accessor<DataT, Dimensions, AccessMode,
2911
2874
public:
2912
2875
// Default constructor for objects later initialized with __init member.
2913
2876
accessor () = default ;
2914
-
2915
- bool ext_oneapi_owner_before (
2916
- const ext::oneapi::detail::weak_object_base<accessor> &Other)
2917
- const noexcept ;
2918
- bool ext_oneapi_owner_before (const accessor &Other) const noexcept ;
2919
- #else
2920
- public:
2921
- // / Compares the accessor against a weak object using an owner-based
2922
- // / implementation-defined ordering.
2923
- // /
2924
- // / \param Other is the weak object to compare ordering against.
2925
- // / \return true if this object precedes \param Other and false otherwise.
2926
- bool ext_oneapi_owner_before (
2927
- const ext::oneapi::detail::weak_object_base<accessor> &Other)
2928
- const noexcept {
2929
- return detail::AccessorBaseHost::impl.owner_before (
2930
- ext::oneapi::detail::getSyclWeakObjImpl (Other));
2931
- }
2932
-
2933
- // / Compares the accessor against another accessor using an
2934
- // / owner-based implementation-defined ordering.
2935
- // /
2936
- // / \param Other is the object to compare ordering against.
2937
- // / \return true if this object precedes \param Other and false otherwise.
2938
- bool ext_oneapi_owner_before (const accessor &Other) const noexcept {
2939
- return detail::AccessorBaseHost::impl.owner_before (Other.impl );
2940
- }
2941
-
2942
2877
#endif
2943
2878
};
2944
2879
@@ -2954,7 +2889,10 @@ template <typename DataT, int Dimensions, access::mode AccessMode,
2954
2889
class accessor <DataT, Dimensions, AccessMode, access::target::host_image,
2955
2890
IsPlaceholder>
2956
2891
: public detail::image_accessor<DataT, Dimensions, AccessMode,
2957
- access::target::host_image, IsPlaceholder> {
2892
+ access::target::host_image, IsPlaceholder>,
2893
+ public detail::AccessorOwnerLessBase<
2894
+ accessor<DataT, Dimensions, AccessMode, access::target::host_image,
2895
+ IsPlaceholder>> {
2958
2896
public:
2959
2897
template <typename AllocatorT>
2960
2898
accessor (sycl::image<Dimensions, AllocatorT> &Image)
@@ -2970,34 +2908,6 @@ class accessor<DataT, Dimensions, AccessMode, access::target::host_image,
2970
2908
Image, Image.getElementSize()) {
2971
2909
(void )propList;
2972
2910
}
2973
-
2974
- #ifndef __SYCL_DEVICE_ONLY__
2975
- // / Compares the accessor against a weak object using an owner-based
2976
- // / implementation-defined ordering.
2977
- // /
2978
- // / \param Other is the weak object to compare ordering against.
2979
- // / \return true if this object precedes \param Other and false otherwise.
2980
- bool ext_oneapi_owner_before (
2981
- const ext::oneapi::detail::weak_object_base<accessor> &Other)
2982
- const noexcept {
2983
- return detail::AccessorBaseHost::impl.owner_before (
2984
- ext::oneapi::detail::getSyclWeakObjImpl (Other));
2985
- }
2986
-
2987
- // / Compares the accessor against another accessor using an
2988
- // / owner-based implementation-defined ordering.
2989
- // /
2990
- // / \param Other is the object to compare ordering against.
2991
- // / \return true if this object precedes \param Other and false otherwise.
2992
- bool ext_oneapi_owner_before (const accessor &Other) const noexcept {
2993
- return detail::AccessorBaseHost::impl.owner_before (Other.impl );
2994
- }
2995
- #else
2996
- bool ext_oneapi_owner_before (
2997
- const ext::oneapi::detail::weak_object_base<accessor> &Other)
2998
- const noexcept ;
2999
- bool ext_oneapi_owner_before (const accessor &Other) const noexcept ;
3000
- #endif
3001
2911
};
3002
2912
3003
2913
// / Image array accessor.
@@ -3014,7 +2924,10 @@ class __SYCL_SPECIAL_CLASS
3014
2924
__SYCL_TYPE (accessor) accessor<DataT, Dimensions, AccessMode,
3015
2925
access::target::image_array, IsPlaceholder>
3016
2926
: public detail::image_accessor<DataT, Dimensions + 1, AccessMode,
3017
- access::target::image, IsPlaceholder> {
2927
+ access::target::image, IsPlaceholder>,
2928
+ public detail::AccessorOwnerLessBase<
2929
+ accessor<DataT, Dimensions, AccessMode, access::target::image_array,
2930
+ IsPlaceholder>> {
3018
2931
#ifdef __SYCL_DEVICE_ONLY__
3019
2932
private:
3020
2933
using OCLImageTy =
@@ -3063,41 +2976,15 @@ __SYCL_TYPE(accessor) accessor<DataT, Dimensions, AccessMode,
3063
2976
return detail::__image_array_slice__<DataT, Dimensions, AccessMode,
3064
2977
IsPlaceholder>(*this , Index);
3065
2978
}
3066
-
3067
- #ifndef __SYCL_DEVICE_ONLY__
3068
- // / Compares the accessor against a weak object using an owner-based
3069
- // / implementation-defined ordering.
3070
- // /
3071
- // / \param Other is the weak object to compare ordering against.
3072
- // / \return true if this object precedes \param Other and false otherwise.
3073
- bool ext_oneapi_owner_before (
3074
- const ext::oneapi::detail::weak_object_base<accessor> &Other)
3075
- const noexcept {
3076
- return detail::AccessorBaseHost::impl.owner_before (
3077
- ext::oneapi::detail::getSyclWeakObjImpl (Other));
3078
- }
3079
-
3080
- // / Compares the accessor against another accessor using an
3081
- // / owner-based implementation-defined ordering.
3082
- // /
3083
- // / \param Other is the object to compare ordering against.
3084
- // / \return true if this object precedes \param Other and false otherwise.
3085
- bool ext_oneapi_owner_before (const accessor &Other) const noexcept {
3086
- return detail::AccessorBaseHost::impl.owner_before (Other.impl );
3087
- }
3088
- #else
3089
- bool ext_oneapi_owner_before (
3090
- const ext::oneapi::detail::weak_object_base<accessor> &Other)
3091
- const noexcept ;
3092
- bool ext_oneapi_owner_before (const accessor &Other) const noexcept ;
3093
- #endif
3094
2979
};
3095
2980
3096
2981
template <typename DataT, int Dimensions = 1 ,
3097
2982
access_mode AccessMode = access_mode::read_write>
3098
2983
class host_accessor
3099
2984
: public accessor<DataT, Dimensions, AccessMode, target::host_buffer,
3100
- access::placeholder::false_t > {
2985
+ access::placeholder::false_t >,
2986
+ public detail::AccessorOwnerLessBase<
2987
+ host_accessor<DataT, Dimensions, AccessMode>> {
3101
2988
protected:
3102
2989
using AccessorT = accessor<DataT, Dimensions, AccessMode, target::host_buffer,
3103
2990
access::placeholder::false_t >;
@@ -3293,27 +3180,6 @@ class host_accessor
3293
3180
PropertyList, CodeLoc) {}
3294
3181
3295
3182
#endif
3296
-
3297
- // / Compares the host_accessor against a weak object using an owner-based
3298
- // / implementation-defined ordering.
3299
- // /
3300
- // / \param Other is the weak object to compare ordering against.
3301
- // / \return true if this object precedes \param Other and false otherwise.
3302
- bool ext_oneapi_owner_before (
3303
- const ext::oneapi::detail::weak_object_base<host_accessor> &Other)
3304
- const noexcept {
3305
- return detail::AccessorBaseHost::impl.owner_before (
3306
- ext::oneapi::detail::getSyclWeakObjImpl (Other));
3307
- }
3308
-
3309
- // / Compares the host_accessor against another host_accessor using an
3310
- // / owner-based implementation-defined ordering.
3311
- // /
3312
- // / \param Other is the object to compare ordering against.
3313
- // / \return true if this object precedes \param Other and false otherwise.
3314
- bool ext_oneapi_owner_before (const host_accessor &Other) const noexcept {
3315
- return detail::AccessorBaseHost::impl.owner_before (Other.impl );
3316
- }
3317
3183
};
3318
3184
3319
3185
#if __cplusplus >= 201703L
0 commit comments