@@ -79,8 +79,7 @@ class kernel_bundle_impl {
79
79
80
80
public:
81
81
kernel_bundle_impl (context Ctx, std::vector<device> Devs, bundle_state State)
82
- : MContext(std::move(Ctx)), MDevices(std::move(Devs)),
83
- MInitialState (State) {
82
+ : MContext(std::move(Ctx)), MDevices(std::move(Devs)), MState(State) {
84
83
85
84
common_ctor_checks (State);
86
85
@@ -90,7 +89,7 @@ class kernel_bundle_impl {
90
89
91
90
// Interop constructor used by make_kernel
92
91
kernel_bundle_impl (context Ctx, std::vector<device> Devs)
93
- : MContext(Ctx), MDevices(Devs), MInitialState (bundle_state::executable) {
92
+ : MContext(Ctx), MDevices(Devs), MState (bundle_state::executable) {
94
93
if (!checkAllDevicesAreInContext (Devs, Ctx))
95
94
throw sycl::exception (
96
95
make_error_code (errc::invalid),
@@ -113,7 +112,7 @@ class kernel_bundle_impl {
113
112
std::vector<device> Devs, const property_list &PropList,
114
113
bundle_state TargetState)
115
114
: MContext(InputBundle.get_context()), MDevices(std::move(Devs)),
116
- MInitialState (TargetState) {
115
+ MState (TargetState) {
117
116
118
117
MSpecConstValues = getSyclObjImpl (InputBundle)->get_spec_const_map_ref ();
119
118
@@ -163,7 +162,7 @@ class kernel_bundle_impl {
163
162
kernel_bundle_impl (
164
163
const std::vector<kernel_bundle<bundle_state::object>> &ObjectBundles,
165
164
std::vector<device> Devs, const property_list &PropList)
166
- : MDevices(std::move(Devs)), MInitialState (bundle_state::executable) {
165
+ : MDevices(std::move(Devs)), MState (bundle_state::executable) {
167
166
168
167
if (MDevices.empty ())
169
168
throw sycl::exception (make_error_code (errc::invalid),
@@ -243,8 +242,7 @@ class kernel_bundle_impl {
243
242
kernel_bundle_impl (context Ctx, std::vector<device> Devs,
244
243
const std::vector<kernel_id> &KernelIDs,
245
244
bundle_state State)
246
- : MContext(std::move(Ctx)), MDevices(std::move(Devs)),
247
- MInitialState(State) {
245
+ : MContext(std::move(Ctx)), MDevices(std::move(Devs)), MState(State) {
248
246
249
247
// TODO: Add a check that all kernel ids are compatible with at least one
250
248
// device in Devs
@@ -256,8 +254,7 @@ class kernel_bundle_impl {
256
254
257
255
kernel_bundle_impl (context Ctx, std::vector<device> Devs,
258
256
const DevImgSelectorImpl &Selector, bundle_state State)
259
- : MContext(std::move(Ctx)), MDevices(std::move(Devs)),
260
- MInitialState(State) {
257
+ : MContext(std::move(Ctx)), MDevices(std::move(Devs)), MState(State) {
261
258
262
259
common_ctor_checks (State);
263
260
@@ -268,7 +265,7 @@ class kernel_bundle_impl {
268
265
// C'tor matches sycl::join API
269
266
kernel_bundle_impl (const std::vector<detail::KernelBundleImplPtr> &Bundles,
270
267
bundle_state State)
271
- : MInitialState (State) {
268
+ : MState (State) {
272
269
if (Bundles.empty ())
273
270
return ;
274
271
@@ -492,7 +489,7 @@ class kernel_bundle_impl {
492
489
return bundle_state::executable;
493
490
// All device images are expected to have the same state
494
491
return MDeviceImages.empty ()
495
- ? MInitialState
492
+ ? MState
496
493
: detail::getSyclObjImpl (MDeviceImages[0 ])->get_state ();
497
494
}
498
495
@@ -502,38 +499,31 @@ class kernel_bundle_impl {
502
499
503
500
bool isInterop () const { return MIsInterop; }
504
501
505
- void add_kernel (const kernel_id &KernelID, const device &Dev) {
502
+ bool add_kernel (const kernel_id &KernelID, const device &Dev) {
506
503
// Skip if kernel is already there
507
504
if (has_kernel (KernelID, Dev))
508
- return ;
505
+ return true ;
509
506
510
507
// First try and get images in current bundle state
511
508
const bundle_state BundleState = get_bundle_state ();
512
509
std::vector<device_image_plain> NewDevImgs =
513
510
detail::ProgramManager::getInstance ().getSYCLDeviceImages (
514
511
MContext, {Dev}, {KernelID}, BundleState);
515
512
516
- // If no images were found and the bundle is in input state we try and get
517
- // the image in executable state and then bring the existing binaries into
518
- // executable as well
519
- if (NewDevImgs.empty () && BundleState == bundle_state::input) {
520
- NewDevImgs = detail::ProgramManager::getInstance ().getSYCLDeviceImages (
521
- MContext, {Dev}, {KernelID}, bundle_state::executable);
522
- detail::ProgramManager::getInstance ().bringSYCLDeviceImagesToState (
523
- MDeviceImages, bundle_state::executable);
524
- }
525
-
526
- assert (!NewDevImgs.empty () && " Device images for kernel was not found." );
513
+ // No images found so we report as not inserted
514
+ if (NewDevImgs.empty ())
515
+ return false ;
527
516
528
517
// Propagate already set specialization constants to the new images
529
- for (device_image_plain DevImg : NewDevImgs)
518
+ for (device_image_plain & DevImg : NewDevImgs)
530
519
for (auto SpecConst : MSpecConstValues)
531
520
getSyclObjImpl (DevImg)->set_specialization_constant_raw_value (
532
521
SpecConst.first .c_str (), SpecConst.second .data ());
533
522
534
523
// Add the images to the collection
535
524
MDeviceImages.insert (MDeviceImages.end (), NewDevImgs.begin (),
536
525
NewDevImgs.end ());
526
+ return true ;
537
527
}
538
528
539
529
private:
@@ -544,7 +534,7 @@ class kernel_bundle_impl {
544
534
// from any device image.
545
535
SpecConstMapT MSpecConstValues;
546
536
bool MIsInterop = false ;
547
- bundle_state MInitialState ;
537
+ bundle_state MState ;
548
538
};
549
539
550
540
} // namespace detail
0 commit comments