Skip to content

Commit 3a05631

Browse files
committed
applying comments
1 parent d382787 commit 3a05631

File tree

7 files changed

+63
-68
lines changed

7 files changed

+63
-68
lines changed

sycl/include/CL/sycl/detail/cg.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,21 @@ class kernel_bundle_impl;
7575
constexpr unsigned int ShiftBitsForVersion = 24;
7676

7777
// Constructs versioned type
78-
constexpr static unsigned int getVersionedCGType(unsigned int Type,
79-
unsigned char Version) {
78+
constexpr unsigned int getVersionedCGType(unsigned int Type,
79+
unsigned char Version) {
8080
return Type | ((unsigned int)Version << ShiftBitsForVersion);
8181
}
8282

8383
// Returns the version encoded to the type
84-
constexpr static unsigned char getCGTypeVersion(unsigned int Type) {
84+
constexpr unsigned char getCGTypeVersion(unsigned int Type) {
8585
return Type >> ShiftBitsForVersion;
8686
}
8787

8888
/// Base class for all types of command groups.
8989
class CG {
9090
public:
9191

92-
enum CG_VERSION: unsigned char {
92+
enum class CG_VERSION: unsigned char {
9393
V0 = 0,
9494
V1 = 1,
9595
};
@@ -111,7 +111,8 @@ class CG {
111111
PREFETCH_USM = 12,
112112
CODEPLAY_INTEROP_TASK = 13,
113113
CODEPLAY_HOST_TASK = 14,
114-
KERNEL_V2 = getVersionedCGType(KERNEL, CG_VERSION::V1),
114+
KERNEL_V2 =
115+
getVersionedCGType(KERNEL, static_cast<unsigned int>(CG_VERSION::V1)),
115116
};
116117

117118
CG(CGTYPE Type, vector_class<vector_class<char>> ArgsStorage,
@@ -139,7 +140,8 @@ class CG {
139140
CGTYPE getType() { return MType; }
140141

141142
std::shared_ptr<std::vector<ExtendedMemberT>> getExtendedMembers() {
142-
if (getCGTypeVersion(MType) == CG_VERSION::V0 || MSharedPtrStorage.empty())
143+
if (getCGTypeVersion(MType) == static_cast<unsigned int>(CG_VERSION::V0) ||
144+
MSharedPtrStorage.empty())
143145
return nullptr;
144146

145147
return convertToExtendedMembers(MSharedPtrStorage[0]);

sycl/include/CL/sycl/handler.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,6 @@ class __SYCL_EXPORT handler {
906906
void setHandlerKernelBundle(
907907
const std::shared_ptr<detail::kernel_bundle_impl> &NewKernelBundleImpPtr);
908908

909-
context getContext();
910-
911909
public:
912910
handler(const handler &) = delete;
913911
handler(handler &&) = delete;

sycl/include/CL/sycl/kernel_bundle.hpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,24 @@ link(const kernel_bundle<bundle_state::object> &ObjectBundle,
614614
// build API
615615
/////////////////////////
616616

617+
namespace detail {
618+
__SYCL_EXPORT std::shared_ptr<detail::kernel_bundle_impl>
619+
build_impl(const kernel_bundle<bundle_state::input> &InputBundle,
620+
const std::vector<device> &Devs, const property_list &PropList);
621+
}
622+
617623
/// \returns a new kernel_bundle which contains device images that are
618624
/// translated into one ore more new device images of state
619625
/// bundle_state::executable. The new bundle represents all of the kernels in
620626
/// InputBundle that are compatible with at least one of the devices in Devs.
621-
__SYCL_EXPORT kernel_bundle<bundle_state::executable>
627+
inline kernel_bundle<bundle_state::executable>
622628
build(const kernel_bundle<bundle_state::input> &InputBundle,
623-
const std::vector<device> &Devs, const property_list &PropList = {});
629+
const std::vector<device> &Devs, const property_list &PropList = {}) {
630+
detail::KernelBundleImplPtr Impl =
631+
detail::build_impl(InputBundle, Devs, PropList);
632+
return detail::createSyclObjFromImpl<
633+
kernel_bundle<sycl::bundle_state::executable>>(Impl);
634+
}
624635

625636
inline kernel_bundle<bundle_state::executable>
626637
build(const kernel_bundle<bundle_state::input> &InputBundle,

sycl/source/detail/kernel_bundle_impl.hpp

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,36 +47,35 @@ class kernel_bundle_impl {
4747
MContext, MDevices, State, M);
4848
}
4949

50-
// Matches sycl::build
50+
// Matches sycl::build and sycl::compile
5151
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)) {
5655

5756
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) {
7157
if (std::none_of(
7258
MDevices.begin(), MDevices.end(),
7359
[&DeviceImage](const device &Dev) {
7460
return getSyclObjImpl(DeviceImage)->compatible_with_device(Dev);
7561
}))
7662
continue;
7763

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+
}
8079
}
8180
}
8281

@@ -86,27 +85,15 @@ class kernel_bundle_impl {
8685
std::vector<device> Devs, const property_list &PropList)
8786
: MContext(ObjectBundles[0].get_context()), MDevices(std::move(Devs)) {
8887

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-
10188
std::vector<device_image_plain> DeviceImages;
10289
for (const kernel_bundle<bundle_state::object> &ObjectBundle :
10390
ObjectBundles) {
10491
DeviceImages.insert(DeviceImages.end(), ObjectBundle.begin(),
10592
ObjectBundle.end());
10693
}
10794

108-
MDeviceImages = detail::ProgramManager::getInstance().link(DeviceImages,
109-
Devs, PropList);
95+
MDeviceImages = detail::ProgramManager::getInstance().link(
96+
std::move(DeviceImages), Devs, PropList);
11097
}
11198

11299
kernel_bundle_impl(const context &Ctx, const std::vector<device> &Devs,

sycl/source/handler.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ handler::handler(const shared_ptr_class<detail::queue_impl> &Queue, bool IsHost)
2929
std::make_shared<std::vector<detail::ExtendedMemberT>>());
3030
}
3131

32-
context handler::getContext() { return MQueue->get_context(); }
33-
3432
std::shared_ptr<detail::kernel_bundle_impl>
3533
handler::getOrInsertHandlerKernelBundle(bool Insert) {
3634

@@ -54,7 +52,7 @@ handler::getOrInsertHandlerKernelBundle(bool Insert) {
5452
// No kernel bundle yet, create one
5553
if (!KernelBundleImpPtr && Insert) {
5654
KernelBundleImpPtr = detail::getSyclObjImpl(
57-
get_kernel_bundle<bundle_state::input>(getContext()));
55+
get_kernel_bundle<bundle_state::input>(MQueue->get_context()));
5856

5957
detail::ExtendedMemberT EMember = {
6058
detail::ExtendedMembersType::HANDLER_KERNEL_BUNDLE, KernelBundleImpPtr};
@@ -95,7 +93,8 @@ event handler::finalize() {
9593
return MLastEvent;
9694
MIsFinalized = true;
9795

98-
if (getCGTypeVersion(MCGType) > detail::CG::CG_VERSION::V0) {
96+
if (getCGTypeVersion(MCGType) >
97+
static_cast<unsigned int>(detail::CG::CG_VERSION::V0)) {
9998
// If there were uses of set_specialization_constant build the kernel_bundle
10099
std::shared_ptr<detail::kernel_bundle_impl> KernelBundleImpPtr =
101100
getOrInsertHandlerKernelBundle(/*Insert=*/false);

sycl/source/kernel_bundle.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ bool has_kernel_bundle_impl(const context &Ctx, const std::vector<device> &Devs,
124124

125125
bool has_kernel_bundle_impl(const context &Ctx, const std::vector<device> &Devs,
126126
const std::vector<kernel_id> &KernelIds,
127-
bundle_state State, OSModuleHandle &M) {
127+
bundle_state State, OSModuleHandle M) {
128128
// Just create a kernel_bundle and check if it has any device_images inside.
129129
detail::kernel_bundle_impl KernelBundleImpl(Ctx, Devs, KernelIds, State, M);
130130
return KernelBundleImpl.size();
@@ -134,7 +134,7 @@ std::shared_ptr<detail::kernel_bundle_impl>
134134
compile_impl(const kernel_bundle<bundle_state::input> &InputBundle,
135135
const std::vector<device> &Devs, const property_list &PropList) {
136136
return std::make_shared<detail::kernel_bundle_impl>(
137-
detail::getSyclObjImpl(InputBundle), Devs, PropList);
137+
InputBundle, Devs, PropList, bundle_state::object);
138138
}
139139

140140
std::shared_ptr<detail::kernel_bundle_impl>
@@ -144,18 +144,15 @@ link_impl(const std::vector<kernel_bundle<bundle_state::object>> &ObjectBundles,
144144
PropList);
145145
}
146146

147-
} // namespace detail
148-
149-
kernel_bundle<bundle_state::executable>
150-
build(const kernel_bundle<bundle_state::input> &InputBundle,
151-
const std::vector<device> &Devs, const property_list &PropList) {
152-
auto Impl =
153-
std::make_shared<detail::kernel_bundle_impl>(InputBundle, Devs, PropList);
154-
155-
return detail::createSyclObjFromImpl<
156-
kernel_bundle<sycl::bundle_state::executable>>(Impl);
147+
std::shared_ptr<detail::kernel_bundle_impl>
148+
build_impl(const kernel_bundle<bundle_state::input> &InputBundle,
149+
const std::vector<device> &Devs, const property_list &PropList) {
150+
return std::make_shared<detail::kernel_bundle_impl>(
151+
InputBundle, Devs, PropList, bundle_state::executable);
157152
}
158153

154+
} // namespace detail
155+
159156
__SYCL_EXPORT bool is_compatible(const std::vector<kernel_id> &KernelIDs,
160157
const device &Dev) {
161158
(void)KernelIDs;
@@ -174,7 +171,7 @@ __SYCL_EXPORT bool is_compatible(const std::vector<kernel_id> &KernelIDs,
174171
// return !Dev.has(Aspect);
175172
// });
176173
//
177-
assert(!"Not supported");
174+
assert(!"Not implemented");
178175
return false;
179176
}
180177

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3620,7 +3620,6 @@ _ZN2cl4sycl4freeEPvRKNS0_5queueE
36203620
_ZN2cl4sycl4freeEPvRKNS0_7contextE
36213621
_ZN2cl4sycl5INTEL15online_compilerILNS1_15source_languageE0EE7compileIJSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISC_EEEEES6_IhSaIhEERKSC_DpRKT_
36223622
_ZN2cl4sycl5INTEL15online_compilerILNS1_15source_languageE1EE7compileIJSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISC_EEEEES6_IhSaIhEERKSC_DpRKT_
3623-
_ZN2cl4sycl5buildERKNS0_13kernel_bundleILNS0_12bundle_stateE0EEERKSt6vectorINS0_6deviceESaIS7_EERKNS0_13property_listE
36243623
_ZN2cl4sycl5event13get_wait_listEv
36253624
_ZN2cl4sycl5event14wait_and_throwERKSt6vectorIS1_SaIS1_EE
36263625
_ZN2cl4sycl5event14wait_and_throwEv
@@ -3656,6 +3655,7 @@ _ZN2cl4sycl6ONEAPI15filter_selectorC1ERKNSt7__cxx1112basic_stringIcSt11char_trai
36563655
_ZN2cl4sycl6ONEAPI15filter_selectorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
36573656
_ZN2cl4sycl6ONEAPI6detail16reduGetMaxWGSizeESt10shared_ptrINS0_6detail10queue_implEEm
36583657
_ZN2cl4sycl6ONEAPI6detail17reduComputeWGSizeEmmRm
3658+
_ZN2cl4sycl6detail10build_implERKNS0_13kernel_bundleILNS0_12bundle_stateE0EEERKSt6vectorINS0_6deviceESaIS8_EERKNS0_13property_listE
36593659
_ZN2cl4sycl6detail10image_implILi1EE10getDevicesESt10shared_ptrINS1_12context_implEE
36603660
_ZN2cl4sycl6detail10image_implILi1EE10setPitchesEv
36613661
_ZN2cl4sycl6detail10image_implILi1EE11allocateMemESt10shared_ptrINS1_12context_implEEbPvRP9_pi_event
@@ -3791,11 +3791,11 @@ _ZN2cl4sycl6detail20associateWithHandlerERNS0_7handlerEPNS1_16AccessorBaseHostEN
37913791
_ZN2cl4sycl6detail20getDeviceFromHandlerERNS0_7handlerE
37923792
_ZN2cl4sycl6detail22addHostAccessorAndWaitEPNS1_16AccessorImplHostE
37933793
_ZN2cl4sycl6detail22getImageNumberChannelsENS0_19image_channel_orderE
3794-
_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateE
3795-
_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateERKSt8functionIFbRKSt10shared_ptrINS1_17device_image_implEEEE
3796-
_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EERKS5_INS0_9kernel_idESaISB_EENS0_12bundle_stateE
3797-
_ZN2cl4sycl6detail22has_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateE
3798-
_ZN2cl4sycl6detail22has_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EERKS5_INS0_9kernel_idESaISB_EENS0_12bundle_stateE
3794+
_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateERKSt8functionIFbRKSt10shared_ptrINS1_17device_image_implEEEEl
3795+
_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateEl
3796+
_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EERKS5_INS0_9kernel_idESaISB_EENS0_12bundle_stateEl
3797+
_ZN2cl4sycl6detail22has_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateEl
3798+
_ZN2cl4sycl6detail22has_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EERKS5_INS0_9kernel_idESaISB_EENS0_12bundle_stateEl
37993799
_ZN2cl4sycl6detail27getPixelCoordLinearFiltModeENS0_3vecIfLi4EEENS0_15addressing_modeENS0_5rangeILi3EEERS3_
38003800
_ZN2cl4sycl6detail28getDeviceFunctionPointerImplERNS0_6deviceERNS0_7programEPKc
38013801
_ZN2cl4sycl6detail28getPixelCoordNearestFiltModeENS0_3vecIfLi4EEENS0_15addressing_modeENS0_5rangeILi3EEE
@@ -3850,7 +3850,6 @@ _ZN2cl4sycl7contextC2ERKSt6vectorINS0_6deviceESaIS3_EERKNS0_13property_listE
38503850
_ZN2cl4sycl7contextC2ERKSt6vectorINS0_6deviceESaIS3_EESt8functionIFvNS0_14exception_listEEERKNS0_13property_listE
38513851
_ZN2cl4sycl7contextC2ERKSt8functionIFvNS0_14exception_listEEERKNS0_13property_listE
38523852
_ZN2cl4sycl7contextC2ESt10shared_ptrINS0_6detail12context_implEE
3853-
_ZN2cl4sycl7handler10getContextEv
38543853
_ZN2cl4sycl7handler10processArgEPvRKNS0_6detail19kernel_param_kind_tEimRmb
38553854
_ZN2cl4sycl7handler10processArgEPvRKNS0_6detail19kernel_param_kind_tEimRmbb
38563855
_ZN2cl4sycl7handler13getKernelNameB5cxx11Ev
@@ -3865,6 +3864,8 @@ _ZN2cl4sycl7handler6memsetEPvim
38653864
_ZN2cl4sycl7handler7barrierERKSt6vectorINS0_5eventESaIS3_EE
38663865
_ZN2cl4sycl7handler8finalizeEv
38673866
_ZN2cl4sycl7handler8prefetchEPKvm
3867+
_ZN2cl4sycl7handlerC1ERKSt10shared_ptrINS0_6detail10queue_implEEb
3868+
_ZN2cl4sycl7handlerC2ERKSt10shared_ptrINS0_6detail10queue_implEEb
38683869
_ZN2cl4sycl7program17build_with_sourceENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_
38693870
_ZN2cl4sycl7program19compile_with_sourceENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_
38703871
_ZN2cl4sycl7program22build_with_kernel_nameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_l

0 commit comments

Comments
 (0)