@@ -471,7 +471,7 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
471
471
472
472
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
473
473
template <typename Param, bool InitializingCache = false >
474
- typename Param::return_type get_info () const {
474
+ decltype ( auto ) get_info() const {
475
475
#define CALL_GET_INFO get_info
476
476
#else
477
477
// We've been exporting
@@ -484,10 +484,27 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
484
484
#define CALL_GET_INFO get_info_abi_workaround
485
485
template <typename Param> typename Param::return_type get_info () const ;
486
486
template <typename Param, bool InitializingCache = false >
487
- typename Param::return_type get_info_abi_workaround () const {
487
+ decltype ( auto ) get_info_abi_workaround () const {
488
488
#endif
489
489
using execution_scope = ext::oneapi::experimental::execution_scope;
490
490
491
+ // With the return type of this function being automatically
492
+ // deduced we can't simply do
493
+ //
494
+ // CASE(Desc1) { return get_info<Desc2>(); }
495
+ //
496
+ // because the function isn't defined yet and we can't auto-deduce the
497
+ // return type for `Desc2` yet. The solution here is to make that delegation
498
+ // template-parameter-dependent. We use the `InitializingCache` parameter
499
+ // for that out of convenience.
500
+ //
501
+ // Note that for "eager" cache it's the programmer's responsibility that
502
+ // the descriptor we delegate to is initialized first (by referencing that
503
+ // descriptor first when defining the cache data member). For "CallOnce"
504
+ // cache we want to be querying cached value so "false" is the right
505
+ // template parameter for such delegation.
506
+ constexpr bool DependentFalse = InitializingCache && false ;
507
+
491
508
if constexpr (decltype (MCache)::has<Param>() && !InitializingCache) {
492
509
return MCache.get <Param>();
493
510
}
@@ -523,11 +540,13 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
523
540
return range<3 >{result[2 ], result[1 ], result[0 ]};
524
541
}
525
542
CASE (info::device::max_work_item_sizes<2 >) {
526
- range<3 > r3 = CALL_GET_INFO<info::device::max_work_item_sizes<3 >>();
543
+ range<3 > r3 =
544
+ CALL_GET_INFO<info::device::max_work_item_sizes<3 >, DependentFalse>();
527
545
return range<2 >{r3[1 ], r3[2 ]};
528
546
}
529
547
CASE (info::device::max_work_item_sizes<1 >) {
530
- range<3 > r3 = CALL_GET_INFO<info::device::max_work_item_sizes<3 >>();
548
+ range<3 > r3 =
549
+ CALL_GET_INFO<info::device::max_work_item_sizes<3 >, DependentFalse>();
531
550
return range<1 >{r3[2 ]};
532
551
}
533
552
@@ -608,16 +627,18 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
608
627
// profiling, urDeviceGetGlobalTimestamps is not supported,
609
628
// command_submit, command_start, command_end will be calculated. See
610
629
// MFallbackProfiling
611
- return get_info_impl<UR_DEVICE_INFO_QUEUE_PROPERTIES>() &
612
- UR_QUEUE_FLAG_PROFILING_ENABLE;
630
+ return static_cast <bool >(
631
+ get_info_impl<UR_DEVICE_INFO_QUEUE_PROPERTIES>() &
632
+ UR_QUEUE_FLAG_PROFILING_ENABLE);
613
633
}
614
634
615
635
CASE (info::device::built_in_kernels) {
616
636
return split_string (get_info_impl<UR_DEVICE_INFO_BUILT_IN_KERNELS>(),
617
637
' ;' );
618
638
}
619
639
CASE (info::device::built_in_kernel_ids) {
620
- auto names = CALL_GET_INFO<info::device::built_in_kernels>();
640
+ auto names =
641
+ CALL_GET_INFO<info::device::built_in_kernels, DependentFalse>();
621
642
622
643
std::vector<kernel_id> ids;
623
644
ids.reserve (names.size ());
@@ -655,7 +676,8 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
655
676
" the info::device::preferred_interop_user_sync info descriptor can "
656
677
" only be queried with an OpenCL backend" );
657
678
658
- return get_info_impl<UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC>();
679
+ return static_cast <bool >(
680
+ get_info_impl<UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC>());
659
681
}
660
682
661
683
CASE (info::device::partition_properties) {
@@ -753,16 +775,19 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
753
775
}
754
776
755
777
CASE (info::device::usm_device_allocations) {
756
- return get_info_impl<UR_DEVICE_INFO_USM_DEVICE_SUPPORT>() &
757
- UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS;
778
+ return static_cast <bool >(
779
+ get_info_impl<UR_DEVICE_INFO_USM_DEVICE_SUPPORT>() &
780
+ UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS);
758
781
}
759
782
CASE (info::device::usm_host_allocations) {
760
- return get_info_impl<UR_DEVICE_INFO_USM_HOST_SUPPORT>() &
761
- UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS;
783
+ return static_cast <bool >(
784
+ get_info_impl<UR_DEVICE_INFO_USM_HOST_SUPPORT>() &
785
+ UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS);
762
786
}
763
787
CASE (info::device::usm_shared_allocations) {
764
- return get_info_impl<UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT>() &
765
- UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS;
788
+ return static_cast <bool >(
789
+ get_info_impl<UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT>() &
790
+ UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS);
766
791
}
767
792
CASE (info::device::usm_restricted_shared_allocations) {
768
793
ur_device_usm_access_capability_flags_t cap_flags =
@@ -773,14 +798,16 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
773
798
UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_CONCURRENT_ACCESS));
774
799
}
775
800
CASE (info::device::usm_system_allocations) {
776
- return get_info_impl<UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT>() &
777
- UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS;
801
+ return static_cast <bool >(
802
+ get_info_impl<UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT>() &
803
+ UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS);
778
804
}
779
805
780
806
CASE (info::device::opencl_c_version) {
781
807
throw sycl::exception (errc::feature_not_supported,
782
808
" Deprecated interface that hasn't been working for "
783
809
" some time already" );
810
+ return std::string{}; // for return type deduction.
784
811
}
785
812
786
813
CASE (ext::intel::info::device::max_mem_bandwidth) {
@@ -794,30 +821,34 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
794
821
CASE (info::device::ext_oneapi_max_global_work_groups) {
795
822
// Deprecated alias.
796
823
return CALL_GET_INFO<
797
- ext::oneapi::experimental::info::device::max_global_work_groups>();
824
+ ext::oneapi::experimental::info::device::max_global_work_groups,
825
+ DependentFalse>();
798
826
}
799
827
CASE (info::device::ext_oneapi_max_work_groups_1d) {
800
828
// Deprecated alias.
801
829
return CALL_GET_INFO<
802
- ext::oneapi::experimental::info::device::max_work_groups<1 >>();
830
+ ext::oneapi::experimental::info::device::max_work_groups<1 >,
831
+ DependentFalse>();
803
832
}
804
833
CASE (info::device::ext_oneapi_max_work_groups_2d) {
805
834
// Deprecated alias.
806
835
return CALL_GET_INFO<
807
- ext::oneapi::experimental::info::device::max_work_groups<2 >>();
836
+ ext::oneapi::experimental::info::device::max_work_groups<2 >,
837
+ DependentFalse>();
808
838
}
809
839
CASE (info::device::ext_oneapi_max_work_groups_3d) {
810
840
// Deprecated alias.
811
841
return CALL_GET_INFO<
812
- ext::oneapi::experimental::info::device::max_work_groups<3 >>();
842
+ ext::oneapi::experimental::info::device::max_work_groups<3 >,
843
+ DependentFalse>();
813
844
}
814
845
815
846
CASE (info::device::ext_oneapi_cuda_cluster_group) {
816
847
if (getBackend () != backend::ext_oneapi_cuda)
817
848
return false ;
818
849
819
850
return get_info_impl_nocheck<UR_DEVICE_INFO_CLUSTER_LAUNCH_SUPPORT_EXP>()
820
- .value_or (0 );
851
+ .value_or (0 ) != 0 ;
821
852
}
822
853
823
854
// ext_codeplay_device_traits.def
@@ -834,7 +865,8 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
834
865
}
835
866
CASE (ext::oneapi::experimental::info::device::max_work_groups<3 >) {
836
867
size_t Limit = CALL_GET_INFO<
837
- ext::oneapi::experimental::info::device::max_global_work_groups>();
868
+ ext::oneapi::experimental::info::device::max_global_work_groups,
869
+ DependentFalse>();
838
870
839
871
// TODO: std::array<size_t, 3> ?
840
872
size_t result[3 ];
@@ -846,12 +878,14 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
846
878
}
847
879
CASE (ext::oneapi::experimental::info::device::max_work_groups<2 >) {
848
880
id<3 > max_3d = CALL_GET_INFO<
849
- ext::oneapi::experimental::info::device::max_work_groups<3 >>();
881
+ ext::oneapi::experimental::info::device::max_work_groups<3 >,
882
+ DependentFalse>();
850
883
return id<2 >{max_3d[1 ], max_3d[2 ]};
851
884
}
852
885
CASE (ext::oneapi::experimental::info::device::max_work_groups<1 >) {
853
886
id<3 > max_3d = CALL_GET_INFO<
854
- ext::oneapi::experimental::info::device::max_work_groups<3 >>();
887
+ ext::oneapi::experimental::info::device::max_work_groups<3 >,
888
+ DependentFalse>();
855
889
return id<1 >{max_3d[2 ]};
856
890
}
857
891
@@ -896,8 +930,8 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
896
930
}
897
931
898
932
CASE (ext::oneapi::experimental::info::device::mipmap_max_anisotropy) {
899
- // Implicit conversion:
900
- return get_info_impl<UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP>();
933
+ return static_cast < float >(
934
+ get_info_impl<UR_DEVICE_INFO_MIPMAP_MAX_ANISOTROPY_EXP>() );
901
935
}
902
936
903
937
CASE (ext::oneapi::experimental::info::device::component_devices) {
@@ -906,7 +940,7 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
906
940
if (!Devs.has_val ()) {
907
941
ur_result_t Err = Devs.error ();
908
942
if (Err == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION)
909
- return {};
943
+ return std::vector<sycl::device> {};
910
944
getAdapter ()->checkUrResult (Err);
911
945
}
912
946
@@ -935,8 +969,8 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
935
969
" must have a composite device." );
936
970
}
937
971
CASE (ext::oneapi::info::device::num_compute_units) {
938
- // uint32_t -> size_t
939
- return get_info_impl<UR_DEVICE_INFO_NUM_COMPUTE_UNITS>();
972
+ return static_cast < size_t >(
973
+ get_info_impl<UR_DEVICE_INFO_NUM_COMPUTE_UNITS>() );
940
974
}
941
975
942
976
// ext_intel_device_traits.def
@@ -1028,8 +1062,8 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
1028
1062
return get_info_impl<UR_DEVICE_INFO_MEMORY_BUS_WIDTH>();
1029
1063
}
1030
1064
CASE (ext::intel::info::device::max_compute_queue_indices) {
1031
- // uint32_t-> int implicit conversion.
1032
- return get_info_impl<UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES>();
1065
+ return static_cast < int >(
1066
+ get_info_impl<UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES>() );
1033
1067
}
1034
1068
CASE (ext::intel::esimd::info::device::has_2d_block_io_support) {
1035
1069
if (!has (aspect::ext_intel_esimd))
@@ -1093,7 +1127,7 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
1093
1127
}
1094
1128
else {
1095
1129
constexpr auto Desc = UrInfoCode<Param>::value;
1096
- return get_info_impl<Desc>();
1130
+ return static_cast < typename Param::return_type>( get_info_impl<Desc>() );
1097
1131
}
1098
1132
#undef CASE
1099
1133
}
0 commit comments