@@ -47,36 +47,35 @@ class kernel_bundle_impl {
47
47
MContext, MDevices, State, M);
48
48
}
49
49
50
- // Matches sycl::build
50
+ // Matches sycl::build and sycl::compile
51
51
kernel_bundle_impl (const kernel_bundle<bundle_state::input> &InputBundle,
52
- const std::vector<device> &Devs,
53
- const property_list &PropList) {
54
-
55
- // TODO: Add checks here
52
+ std::vector<device> Devs, const property_list &PropList,
53
+ bundle_state TargetState)
54
+ : MContext(InputBundle.get_context()), MDevices(std::move(Devs)) {
56
55
57
56
for (const device_image_plain &DeviceImage : InputBundle) {
58
- MDeviceImages.push_back (detail::ProgramManager::getInstance ().build (
59
- DeviceImage, Devs, PropList));
60
- }
61
- }
62
-
63
- // Matches sycl::compile
64
- // TODO: Replace kernel_bunlde_impl with kernel_bundle_plain
65
- kernel_bundle_impl (const std::shared_ptr<kernel_bundle_impl> &InputBundleImpl,
66
- const std::vector<device> Devs,
67
- const property_list &PropList)
68
- : MContext(InputBundleImpl->MContext), MDevices(std::move(Devs)) {
69
-
70
- for (const device_image_plain &DeviceImage : *InputBundleImpl) {
71
57
if (std::none_of (
72
58
MDevices.begin (), MDevices.end (),
73
59
[&DeviceImage](const device &Dev) {
74
60
return getSyclObjImpl (DeviceImage)->compatible_with_device (Dev);
75
61
}))
76
62
continue ;
77
63
78
- MDeviceImages.push_back (detail::ProgramManager::getInstance ().compile (
79
- DeviceImage, Devs, PropList));
64
+ switch (TargetState) {
65
+ case bundle_state::object:
66
+ MDeviceImages.push_back (detail::ProgramManager::getInstance ().compile (
67
+ DeviceImage, Devs, PropList));
68
+ break ;
69
+ case bundle_state::executable:
70
+ MDeviceImages.push_back (detail::ProgramManager::getInstance ().build (
71
+ DeviceImage, MDevices, PropList));
72
+ break ;
73
+ case bundle_state::input:
74
+ throw sycl::runtime_error (
75
+ " Internal error. The target state should not be input" ,
76
+ PI_INVALID_OPERATION);
77
+ break ;
78
+ }
80
79
}
81
80
}
82
81
@@ -86,27 +85,15 @@ class kernel_bundle_impl {
86
85
std::vector<device> Devs, const property_list &PropList)
87
86
: MContext(ObjectBundles[0 ].get_context()), MDevices(std::move(Devs)) {
88
87
89
- // for(const device &Dev: Devs) {
90
- // for(const kernel_bundle<bundle_state::object> &ObjectBundle: ObjectBundles) {
91
- // const std::vector<device> &BundleDevices =
92
- // getSyclObjImpl(ObjectBundle)->MDevices;
93
-
94
- // if (std::none_of(
95
- // BundleDevices.begin(), BundleDevices.end(),
96
- // [&Dev](const device &DevCand) { return Dev == DevCand; }))
97
- // throw "laga";
98
- // }
99
- // }
100
-
101
88
std::vector<device_image_plain> DeviceImages;
102
89
for (const kernel_bundle<bundle_state::object> &ObjectBundle :
103
90
ObjectBundles) {
104
91
DeviceImages.insert (DeviceImages.end (), ObjectBundle.begin (),
105
92
ObjectBundle.end ());
106
93
}
107
94
108
- MDeviceImages = detail::ProgramManager::getInstance ().link (DeviceImages,
109
- Devs, PropList);
95
+ MDeviceImages = detail::ProgramManager::getInstance ().link (
96
+ std::move (DeviceImages), Devs, PropList);
110
97
}
111
98
112
99
kernel_bundle_impl (const context &Ctx, const std::vector<device> &Devs,
0 commit comments