@@ -1085,6 +1085,67 @@ struct get_device_info_impl<
1085
1085
}
1086
1086
};
1087
1087
1088
+ // Specialization for composite devices extension.
1089
+ template <>
1090
+ struct get_device_info_impl <
1091
+ std::vector<sycl::device>,
1092
+ ext::oneapi::experimental::info::device::component_devices> {
1093
+ static std::vector<sycl::device> get (const DeviceImplPtr &Dev) {
1094
+ if (Dev->getBackend () != backend::ext_oneapi_level_zero)
1095
+ return {};
1096
+ size_t ResultSize = 0 ;
1097
+ // First call to get DevCount.
1098
+ Dev->getPlugin ()->call <PiApiKind::piDeviceGetInfo>(
1099
+ Dev->getHandleRef (),
1100
+ PiInfoCode<
1101
+ ext::oneapi::experimental::info::device::component_devices>::value,
1102
+ 0 , nullptr , &ResultSize);
1103
+ size_t DevCount = ResultSize / sizeof (pi_device);
1104
+ // Second call to get the list.
1105
+ std::vector<pi_device> Devs (DevCount);
1106
+ Dev->getPlugin ()->call <PiApiKind::piDeviceGetInfo>(
1107
+ Dev->getHandleRef (),
1108
+ PiInfoCode<
1109
+ ext::oneapi::experimental::info::device::component_devices>::value,
1110
+ ResultSize, Devs.data (), nullptr );
1111
+ std::vector<sycl::device> Result;
1112
+ const auto &Platform = Dev->getPlatformImpl ();
1113
+ for (const auto &d : Devs)
1114
+ Result.push_back (createSyclObjFromImpl<device>(
1115
+ Platform->getOrMakeDeviceImpl (d, Platform)));
1116
+
1117
+ return Result;
1118
+ }
1119
+ };
1120
+ template <>
1121
+ struct get_device_info_impl <
1122
+ sycl::device, ext::oneapi::experimental::info::device::composite_device> {
1123
+ static sycl::device get (const DeviceImplPtr &Dev) {
1124
+ if (Dev->getBackend () != backend::ext_oneapi_level_zero)
1125
+ return {};
1126
+ if (!Dev->has (sycl::aspect::ext_oneapi_is_component))
1127
+ throw sycl::exception (make_error_code (errc::invalid),
1128
+ " Only devices with aspect::ext_oneapi_is_component "
1129
+ " can call this function." );
1130
+
1131
+ typename sycl_to_pi<device>::type Result;
1132
+ Dev->getPlugin ()->call <PiApiKind::piDeviceGetInfo>(
1133
+ Dev->getHandleRef (),
1134
+ PiInfoCode<
1135
+ ext::oneapi::experimental::info::device::composite_device>::value,
1136
+ sizeof (Result), &Result, nullptr );
1137
+
1138
+ if (Result) {
1139
+ const auto &Platform = Dev->getPlatformImpl ();
1140
+ return createSyclObjFromImpl<device>(
1141
+ Platform->getOrMakeDeviceImpl (Result, Platform));
1142
+ }
1143
+ throw sycl::exception (make_error_code (errc::invalid),
1144
+ " A component with aspect::ext_oneapi_is_component "
1145
+ " must have a composite device." );
1146
+ }
1147
+ };
1148
+
1088
1149
template <typename Param>
1089
1150
typename Param::return_type get_device_info (const DeviceImplPtr &Dev) {
1090
1151
static_assert (is_device_info_desc<Param>::value,
@@ -2041,6 +2102,20 @@ inline float get_device_info_host<
2041
2102
PI_ERROR_INVALID_DEVICE);
2042
2103
}
2043
2104
2105
+ template <>
2106
+ inline std::vector<sycl::device> get_device_info_host<
2107
+ ext::oneapi::experimental::info::device::component_devices>() {
2108
+ throw runtime_error (" Host devices cannot be component devices." ,
2109
+ PI_ERROR_INVALID_DEVICE);
2110
+ }
2111
+
2112
+ template <>
2113
+ inline sycl::device get_device_info_host<
2114
+ ext::oneapi::experimental::info::device::composite_device>() {
2115
+ throw runtime_error (" Host devices cannot be composite devices." ,
2116
+ PI_ERROR_INVALID_DEVICE);
2117
+ }
2118
+
2044
2119
} // namespace detail
2045
2120
} // namespace _V1
2046
2121
} // namespace sycl
0 commit comments