@@ -71,31 +71,36 @@ context_impl::context_impl(const std::vector<sycl::device> Devices,
71
71
72
72
context_impl::context_impl (sycl::detail::pi ::PiContext PiContext,
73
73
async_handler AsyncHandler, const PluginPtr &Plugin,
74
+ const std::vector<sycl::device> &DeviceList,
74
75
bool OwnedByRuntime)
75
- : MOwnedByRuntime(OwnedByRuntime), MAsyncHandler(AsyncHandler), MDevices(),
76
- MContext(PiContext), MPlatform(), MHostContext(false ),
77
- MSupportBufferLocationByDevices(NotChecked) {
78
-
79
- std::vector<sycl::detail::pi ::PiDevice> DeviceIds;
80
- uint32_t DevicesNum = 0 ;
81
- // TODO catch an exception and put it to list of asynchronous exceptions
82
- Plugin->call <PiApiKind::piContextGetInfo>(
83
- MContext, PI_CONTEXT_INFO_NUM_DEVICES, sizeof (DevicesNum), &DevicesNum,
84
- nullptr );
85
- DeviceIds.resize (DevicesNum);
86
- // TODO catch an exception and put it to list of asynchronous exceptions
87
- Plugin->call <PiApiKind::piContextGetInfo>(
88
- MContext, PI_CONTEXT_INFO_DEVICES,
89
- sizeof (sycl::detail::pi ::PiDevice) * DevicesNum, &DeviceIds[0 ], nullptr );
90
-
91
- if (!DeviceIds.empty ()) {
92
- std::shared_ptr<detail::platform_impl> Platform =
93
- platform_impl::getPlatformFromPiDevice (DeviceIds[0 ], Plugin);
94
- for (sycl::detail::pi ::PiDevice Dev : DeviceIds) {
95
- MDevices.emplace_back (createSyclObjFromImpl<device>(
96
- Platform->getOrMakeDeviceImpl (Dev, Platform)));
76
+ : MOwnedByRuntime(OwnedByRuntime), MAsyncHandler(AsyncHandler),
77
+ MDevices(DeviceList), MContext(PiContext), MPlatform(),
78
+ MHostContext(false ), MSupportBufferLocationByDevices(NotChecked) {
79
+ if (!MDevices.empty ()) {
80
+ MPlatform = detail::getSyclObjImpl (MDevices[0 ].get_platform ());
81
+ } else {
82
+ std::vector<sycl::detail::pi ::PiDevice> DeviceIds;
83
+ uint32_t DevicesNum = 0 ;
84
+ // TODO catch an exception and put it to list of asynchronous exceptions
85
+ Plugin->call <PiApiKind::piContextGetInfo>(
86
+ MContext, PI_CONTEXT_INFO_NUM_DEVICES, sizeof (DevicesNum), &DevicesNum,
87
+ nullptr );
88
+ DeviceIds.resize (DevicesNum);
89
+ // TODO catch an exception and put it to list of asynchronous exceptions
90
+ Plugin->call <PiApiKind::piContextGetInfo>(
91
+ MContext, PI_CONTEXT_INFO_DEVICES,
92
+ sizeof (sycl::detail::pi ::PiDevice) * DevicesNum, &DeviceIds[0 ],
93
+ nullptr );
94
+
95
+ if (!DeviceIds.empty ()) {
96
+ std::shared_ptr<detail::platform_impl> Platform =
97
+ platform_impl::getPlatformFromPiDevice (DeviceIds[0 ], Plugin);
98
+ for (sycl::detail::pi ::PiDevice Dev : DeviceIds) {
99
+ MDevices.emplace_back (createSyclObjFromImpl<device>(
100
+ Platform->getOrMakeDeviceImpl (Dev, Platform)));
101
+ }
102
+ MPlatform = Platform;
97
103
}
98
- MPlatform = Platform;
99
104
}
100
105
// TODO catch an exception and put it to list of asynchronous exceptions
101
106
// getPlugin() will be the same as the Plugin passed. This should be taken
0 commit comments