DPC++ Runtime
Runtime libraries for oneAPI DPC++
kernel_bundle.hpp
Go to the documentation of this file.
1 //==------- kernel_bundle.hpp - SYCL kernel_bundle and free functions ------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include <sycl/context.hpp>
12 #include <sycl/detail/common.hpp>
15 #include <sycl/detail/pi.h>
16 #include <sycl/detail/pi.hpp>
17 #include <sycl/device.hpp>
19 #include <sycl/kernel.hpp>
21 
22 #include <cassert>
23 #include <memory>
24 #include <set>
25 #include <vector>
26 
27 namespace sycl {
29 // Forward declaration
30 template <backend Backend> class backend_traits;
31 template <backend Backend, bundle_state State>
32 auto get_native(const kernel_bundle<State> &Obj)
33  -> backend_return_t<Backend, kernel_bundle<State>>;
34 
35 namespace detail {
36 class kernel_id_impl;
37 }
38 
39 template <typename KernelName> kernel_id get_kernel_id();
40 
44 class __SYCL_EXPORT kernel_id : public detail::OwnerLessBase<kernel_id> {
45 public:
46  kernel_id() = delete;
47 
49  const char *get_name() const noexcept;
50 
51  bool operator==(const kernel_id &RHS) const { return impl == RHS.impl; }
52 
53  bool operator!=(const kernel_id &RHS) const { return !(*this == RHS); }
54 
55 private:
56  kernel_id(const char *Name);
57 
58  kernel_id(const std::shared_ptr<detail::kernel_id_impl> &Impl)
59  : impl(std::move(Impl)) {}
60 
61  std::shared_ptr<detail::kernel_id_impl> impl;
62 
63  template <class Obj>
64  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
65 
66  template <class T>
67  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
68 };
69 
70 namespace detail {
71 class device_image_impl;
72 using DeviceImageImplPtr = std::shared_ptr<device_image_impl>;
73 
74 // The class is used as a base for device_image for "untemplating" public
75 // methods.
76 class __SYCL_EXPORT device_image_plain {
77 public:
79  : impl(std::move(Impl)) {}
80 
81  bool operator==(const device_image_plain &RHS) const {
82  return impl == RHS.impl;
83  }
84 
85  bool operator!=(const device_image_plain &RHS) const {
86  return !(*this == RHS);
87  }
88 
89  bool has_kernel(const kernel_id &KernelID) const noexcept;
90 
91  bool has_kernel(const kernel_id &KernelID, const device &Dev) const noexcept;
92 
93  pi_native_handle getNative() const;
94 
95 protected:
97 
98  template <class Obj>
99  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
100 
101  template <class T>
102  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
103 };
104 } // namespace detail
105 
107 template <sycl::bundle_state State>
109  public detail::OwnerLessBase<device_image<State>> {
110 public:
111  device_image() = delete;
112 
115  bool has_kernel(const kernel_id &KernelID) const noexcept {
116  return device_image_plain::has_kernel(KernelID);
117  }
118 
121  bool has_kernel(const kernel_id &KernelID, const device &Dev) const noexcept {
122  return device_image_plain::has_kernel(KernelID, Dev);
123  }
124 
125 private:
127  : device_image_plain(std::move(Impl)) {}
128 
129  template <class Obj>
130  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
131 
132  template <class T>
133  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
134 };
135 
136 namespace detail {
137 class kernel_bundle_impl;
138 using KernelBundleImplPtr = std::shared_ptr<detail::kernel_bundle_impl>;
139 
140 // The class is used as a base for kernel_bundle to "untemplate" it's methods
141 class __SYCL_EXPORT kernel_bundle_plain {
142 public:
144  : impl(std::move(Impl)) {}
145 
146  bool operator==(const kernel_bundle_plain &RHS) const {
147  return impl == RHS.impl;
148  }
149 
150  bool operator!=(const kernel_bundle_plain &RHS) const {
151  return !(*this == RHS);
152  }
153 
154  bool empty() const noexcept;
155 
156  backend get_backend() const noexcept;
157 
158  context get_context() const noexcept;
159 
160  std::vector<device> get_devices() const noexcept;
161 
162  bool has_kernel(const kernel_id &KernelID) const noexcept;
163 
164  bool has_kernel(const kernel_id &KernelID, const device &Dev) const noexcept;
165 
166  std::vector<kernel_id> get_kernel_ids() const;
167 
168  bool contains_specialization_constants() const noexcept;
169 
170  bool native_specialization_constant() const noexcept;
171 
172 protected:
173  // \returns a kernel object which represents the kernel identified by
174  // kernel_id passed
175  kernel get_kernel(const kernel_id &KernelID) const;
176 
177  // \returns an iterator to the first device image kernel_bundle contains
178  const device_image_plain *begin() const;
179 
180  // \returns an iterator to the last device image kernel_bundle contains
181  const device_image_plain *end() const;
182 
183  bool has_specialization_constant_impl(const char *SpecName) const noexcept;
184 
185  void set_specialization_constant_impl(const char *SpecName, void *Value,
186  size_t Size) noexcept;
187 
188  void get_specialization_constant_impl(const char *SpecName,
189  void *Value) const noexcept;
190 
191  bool is_specialization_constant_set(const char *SpecName) const noexcept;
192 
193  detail::KernelBundleImplPtr impl;
194 };
195 
196 } // namespace detail
197 
202 template <bundle_state State>
203 class kernel_bundle : public detail::kernel_bundle_plain,
204  public detail::OwnerLessBase<kernel_bundle<State>> {
205 public:
207 
208  kernel_bundle() = delete;
209 
211  bool empty() const noexcept { return kernel_bundle_plain::empty(); }
212 
214  backend get_backend() const noexcept {
215  return kernel_bundle_plain::get_backend();
216  }
217 
219  context get_context() const noexcept {
220  return kernel_bundle_plain::get_context();
221  }
222 
224  std::vector<device> get_devices() const noexcept {
225  return kernel_bundle_plain::get_devices();
226  }
227 
230  bool has_kernel(const kernel_id &KernelID) const noexcept {
231  return kernel_bundle_plain::has_kernel(KernelID);
232  }
233 
237  bool has_kernel(const kernel_id &KernelID, const device &Dev) const noexcept {
238  return kernel_bundle_plain::has_kernel(KernelID, Dev);
239  }
240 
243  template <typename KernelName> bool has_kernel() const noexcept {
244  return has_kernel(get_kernel_id<KernelName>());
245  }
246 
249  template <typename KernelName>
250  bool has_kernel(const device &Dev) const noexcept {
251  return has_kernel(get_kernel_id<KernelName>(), Dev);
252  }
253 
255  std::vector<kernel_id> get_kernel_ids() const {
257  }
258 
261  bool contains_specialization_constants() const noexcept {
262  return kernel_bundle_plain::contains_specialization_constants();
263  }
264 
267  bool native_specialization_constant() const noexcept {
268  return kernel_bundle_plain::native_specialization_constant();
269  }
270 
273  template <bundle_state _State = State,
275  kernel get_kernel(const kernel_id &KernelID) const {
276  return detail::kernel_bundle_plain::get_kernel(KernelID);
277  }
278 
281  template <typename KernelName, bundle_state _State = State,
283  kernel get_kernel() const {
284  return detail::kernel_bundle_plain::get_kernel(get_kernel_id<KernelName>());
285  }
286 
289  template <auto &SpecName> bool has_specialization_constant() const noexcept {
290  const char *SpecSymName = detail::get_spec_constant_symbolic_ID<SpecName>();
291  return has_specialization_constant_impl(SpecSymName);
292  }
293 
297  template <auto &SpecName, bundle_state _State = State,
300  typename std::remove_reference_t<decltype(SpecName)>::value_type Value) {
301  const char *SpecSymName = detail::get_spec_constant_symbolic_ID<SpecName>();
302  set_specialization_constant_impl(SpecSymName, &Value,
303  sizeof(decltype(Value)));
304  }
305 
308  template <auto &SpecName>
309  typename std::remove_reference_t<decltype(SpecName)>::value_type
311  using SCType =
312  typename std::remove_reference_t<decltype(SpecName)>::value_type;
313 
314  const char *SpecSymName = detail::get_spec_constant_symbolic_ID<SpecName>();
315  SCType Res{SpecName.getDefaultValue()};
316  if (!is_specialization_constant_set(SpecSymName))
317  return Res;
318 
319  std::array<char, sizeof(SCType)> RetValue;
320  get_specialization_constant_impl(SpecSymName, RetValue.data());
321  std::memcpy(&Res, RetValue.data(), sizeof(SCType));
322 
323  return Res;
324  }
325 
328  return reinterpret_cast<device_image_iterator>(
329  kernel_bundle_plain::begin());
330  }
331 
334  return reinterpret_cast<device_image_iterator>(kernel_bundle_plain::end());
335  }
336 
337 private:
339  : kernel_bundle_plain(std::move(Impl)) {}
340 
341  template <class Obj>
342  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
343 
344  template <class T>
345  friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
346 
347  template <backend Backend, bundle_state StateB>
348  friend auto get_native(const kernel_bundle<StateB> &Obj)
349  -> backend_return_t<Backend, kernel_bundle<StateB>>;
350 
351  template <backend Backend>
352  backend_return_t<Backend, kernel_bundle<State>> getNative() const {
353  // NOTE: implementation assumes that the return type is a
354  // derivative of std::vector.
355  backend_return_t<Backend, kernel_bundle<State>> ReturnValue;
356  ReturnValue.reserve(std::distance(begin(), end()));
357 
358  for (const device_image<State> &DevImg : *this) {
359  ReturnValue.push_back(
360  detail::pi::cast<typename decltype(ReturnValue)::value_type>(
361  DevImg.getNative()));
362  }
363 
364  return ReturnValue;
365  }
366 };
367 template <bundle_state State>
368 kernel_bundle(kernel_bundle<State> &&) -> kernel_bundle<State>;
369 
371 // get_kernel_id API
373 
374 namespace detail {
375 // Internal non-template versions of get_kernel_id API which is used by public
376 // onces
377 __SYCL_EXPORT kernel_id get_kernel_id_impl(std::string KernelName);
378 } // namespace detail
379 
381 template <typename KernelName> kernel_id get_kernel_id() {
382  // FIXME: This must fail at link-time if KernelName not in any available
383  // translation units.
384  using KI = sycl::detail::KernelInfo<KernelName>;
385  return detail::get_kernel_id_impl(KI::getName());
386 }
387 
389 __SYCL_EXPORT std::vector<kernel_id> get_kernel_ids();
390 
392 // get_kernel_bundle API
394 
395 namespace detail {
396 
397 // Internal non-template versions of get_kernel_bundle API which is used by
398 // public onces
399 __SYCL_EXPORT detail::KernelBundleImplPtr
400 get_kernel_bundle_impl(const context &Ctx, const std::vector<device> &Devs,
401  bundle_state State);
402 
403 __SYCL_EXPORT const std::vector<device>
404 removeDuplicateDevices(const std::vector<device> &Devs);
405 
406 } // namespace detail
407 
412 template <bundle_state State>
414  const std::vector<device> &Devs) {
415  std::vector<device> UniqueDevices = detail::removeDuplicateDevices(Devs);
416 
418  detail::get_kernel_bundle_impl(Ctx, UniqueDevices, State);
419 
420  return detail::createSyclObjFromImpl<kernel_bundle<State>>(Impl);
421 }
422 
423 template <bundle_state State>
425  return get_kernel_bundle<State>(Ctx, Ctx.get_devices());
426 }
427 
428 namespace detail {
429 
430 // Internal non-template versions of get_kernel_bundle API which is used by
431 // public onces
432 __SYCL_EXPORT detail::KernelBundleImplPtr
433 get_kernel_bundle_impl(const context &Ctx, const std::vector<device> &Devs,
434  const std::vector<kernel_id> &KernelIDs,
435  bundle_state State);
436 } // namespace detail
437 
446 template <bundle_state State>
447 kernel_bundle<State>
448 get_kernel_bundle(const context &Ctx, const std::vector<device> &Devs,
449  const std::vector<kernel_id> &KernelIDs) {
450  std::vector<device> UniqueDevices = detail::removeDuplicateDevices(Devs);
451 
453  detail::get_kernel_bundle_impl(Ctx, UniqueDevices, KernelIDs, State);
454  return detail::createSyclObjFromImpl<kernel_bundle<State>>(Impl);
455 }
456 
457 template <bundle_state State>
458 kernel_bundle<State>
459 get_kernel_bundle(const context &Ctx, const std::vector<kernel_id> &KernelIDs) {
460  return get_kernel_bundle<State>(Ctx, Ctx.get_devices(), KernelIDs);
461 }
462 
463 template <typename KernelName, bundle_state State>
465  return get_kernel_bundle<State>(Ctx, Ctx.get_devices(),
466  {get_kernel_id<KernelName>()});
467 }
468 
469 template <typename KernelName, bundle_state State>
471  const std::vector<device> &Devs) {
472  return get_kernel_bundle<State>(Ctx, Devs, {get_kernel_id<KernelName>()});
473 }
474 
475 namespace detail {
476 
477 // Stable selector function type for passing thru library boundaries
478 using DevImgSelectorImpl =
479  std::function<bool(const detail::DeviceImageImplPtr &DevImgImpl)>;
480 
481 // Internal non-template versions of get_kernel_bundle API which is used by
482 // public onces
483 __SYCL_EXPORT detail::KernelBundleImplPtr
484 get_kernel_bundle_impl(const context &Ctx, const std::vector<device> &Devs,
485  bundle_state State, const DevImgSelectorImpl &Selector);
486 
487 // Internal non-template versions of get_empty_interop_kernel_bundle API which
488 // is used by public onces
489 __SYCL_EXPORT detail::KernelBundleImplPtr
491  const std::vector<device> &Devs);
492 
495 template <bundle_state State>
499  return detail::createSyclObjFromImpl<sycl::kernel_bundle<State>>(Impl);
500 }
501 } // namespace detail
502 
505 template <bundle_state State, typename SelectorT>
507  const std::vector<device> &Devs,
508  SelectorT Selector) {
509  std::vector<device> UniqueDevices = detail::removeDuplicateDevices(Devs);
510 
511  detail::DevImgSelectorImpl SelectorWrapper =
512  [Selector](const detail::DeviceImageImplPtr &DevImg) {
513  return Selector(
514  detail::createSyclObjFromImpl<sycl::device_image<State>>(DevImg));
515  };
516 
518  Ctx, UniqueDevices, State, SelectorWrapper);
519 
520  return detail::createSyclObjFromImpl<sycl::kernel_bundle<State>>(Impl);
521 }
522 
523 template <bundle_state State, typename SelectorT>
524 kernel_bundle<State> get_kernel_bundle(const context &Ctx, SelectorT Selector) {
525  return get_kernel_bundle<State>(Ctx, Ctx.get_devices(), Selector);
526 }
527 
529 // has_kernel_bundle API
531 
532 namespace detail {
533 
534 __SYCL_EXPORT bool has_kernel_bundle_impl(const context &Ctx,
535  const std::vector<device> &Devs,
536  bundle_state State);
537 
538 __SYCL_EXPORT bool
539 has_kernel_bundle_impl(const context &Ctx, const std::vector<device> &Devs,
540  const std::vector<kernel_id> &kernelIds,
541  bundle_state State);
542 } // namespace detail
543 
554 template <bundle_state State>
555 bool has_kernel_bundle(const context &Ctx, const std::vector<device> &Devs) {
556  return detail::has_kernel_bundle_impl(Ctx, Devs, State);
557 }
558 
559 template <bundle_state State>
560 bool has_kernel_bundle(const context &Ctx, const std::vector<device> &Devs,
561  const std::vector<kernel_id> &KernelIDs) {
562  return detail::has_kernel_bundle_impl(Ctx, Devs, KernelIDs, State);
563 }
564 
565 template <bundle_state State> bool has_kernel_bundle(const context &Ctx) {
566  return has_kernel_bundle<State>(Ctx, Ctx.get_devices());
567 }
568 
569 template <bundle_state State>
570 bool has_kernel_bundle(const context &Ctx,
571  const std::vector<kernel_id> &KernelIDs) {
572  return has_kernel_bundle<State>(Ctx, Ctx.get_devices(), KernelIDs);
573 }
574 
575 template <typename KernelName, bundle_state State>
576 bool has_kernel_bundle(const context &Ctx) {
577  return has_kernel_bundle<State>(Ctx, {get_kernel_id<KernelName>()});
578 }
579 
580 template <typename KernelName, bundle_state State>
581 bool has_kernel_bundle(const context &Ctx, const std::vector<device> &Devs) {
582  return has_kernel_bundle<State>(Ctx, Devs, {get_kernel_id<KernelName>()});
583 }
584 
586 // is_compatible API
588 
591 __SYCL_EXPORT bool is_compatible(const std::vector<kernel_id> &KernelIDs,
592  const device &Dev);
593 
594 template <typename KernelName> bool is_compatible(const device &Dev) {
595  return is_compatible({get_kernel_id<KernelName>()}, Dev);
596 }
597 
599 // join API
601 
602 namespace detail {
603 
604 __SYCL_EXPORT std::shared_ptr<detail::kernel_bundle_impl>
605 join_impl(const std::vector<detail::KernelBundleImplPtr> &Bundles,
606  bundle_state State);
607 } // namespace detail
608 
611 template <sycl::bundle_state State>
612 sycl::kernel_bundle<State>
613 join(const std::vector<sycl::kernel_bundle<State>> &Bundles) {
614  // Convert kernel_bundle<State> to impls to abstract template parameter away
615  std::vector<detail::KernelBundleImplPtr> KernelBundleImpls;
616  KernelBundleImpls.reserve(Bundles.size());
617  for (const sycl::kernel_bundle<State> &Bundle : Bundles)
618  KernelBundleImpls.push_back(detail::getSyclObjImpl(Bundle));
619 
620  std::shared_ptr<detail::kernel_bundle_impl> Impl =
621  detail::join_impl(KernelBundleImpls, State);
622  return detail::createSyclObjFromImpl<kernel_bundle<State>>(Impl);
623 }
624 
626 // compile API
628 
629 namespace detail {
630 
631 __SYCL_EXPORT std::shared_ptr<detail::kernel_bundle_impl>
632 compile_impl(const kernel_bundle<bundle_state::input> &InputBundle,
633  const std::vector<device> &Devs, const property_list &PropList);
634 }
635 
640 inline kernel_bundle<bundle_state::object>
642  const std::vector<device> &Devs, const property_list &PropList = {}) {
643  std::vector<device> UniqueDevices = detail::removeDuplicateDevices(Devs);
644 
646  detail::compile_impl(InputBundle, UniqueDevices, PropList);
648  kernel_bundle<sycl::bundle_state::object>>(Impl);
649 }
650 
651 inline kernel_bundle<bundle_state::object>
653  const property_list &PropList = {}) {
654  return compile(InputBundle, InputBundle.get_devices(), PropList);
655 }
656 
658 // link API
660 
661 namespace detail {
662 __SYCL_EXPORT std::vector<sycl::device> find_device_intersection(
663  const std::vector<kernel_bundle<bundle_state::object>> &ObjectBundles);
664 
665 __SYCL_EXPORT std::shared_ptr<detail::kernel_bundle_impl>
666 link_impl(const std::vector<kernel_bundle<bundle_state::object>> &ObjectBundles,
667  const std::vector<device> &Devs, const property_list &PropList);
668 } // namespace detail
669 
675 inline kernel_bundle<bundle_state::executable>
676 link(const std::vector<kernel_bundle<bundle_state::object>> &ObjectBundles,
677  const std::vector<device> &Devs, const property_list &PropList = {}) {
678  std::vector<device> UniqueDevices = detail::removeDuplicateDevices(Devs);
679 
681  detail::link_impl(ObjectBundles, UniqueDevices, PropList);
683  kernel_bundle<sycl::bundle_state::executable>>(Impl);
684 }
685 
686 inline kernel_bundle<bundle_state::executable>
688  const property_list &PropList = {}) {
689  return link(std::vector<kernel_bundle<bundle_state::object>>{ObjectBundle},
690  ObjectBundle.get_devices(), PropList);
691 }
692 
693 inline kernel_bundle<bundle_state::executable>
694 link(const std::vector<kernel_bundle<bundle_state::object>> &ObjectBundles,
695  const property_list &PropList = {}) {
696  std::vector<sycl::device> IntersectDevices =
697  find_device_intersection(ObjectBundles);
698  return link(ObjectBundles, IntersectDevices, PropList);
699 }
700 
701 inline kernel_bundle<bundle_state::executable>
703  const std::vector<device> &Devs, const property_list &PropList = {}) {
704  return link(std::vector<kernel_bundle<bundle_state::object>>{ObjectBundle},
705  Devs, PropList);
706 }
707 
709 // build API
711 
712 namespace detail {
713 __SYCL_EXPORT std::shared_ptr<detail::kernel_bundle_impl>
714 build_impl(const kernel_bundle<bundle_state::input> &InputBundle,
715  const std::vector<device> &Devs, const property_list &PropList);
716 }
717 
722 inline kernel_bundle<bundle_state::executable>
724  const std::vector<device> &Devs, const property_list &PropList = {}) {
725  std::vector<device> UniqueDevices = detail::removeDuplicateDevices(Devs);
726 
728  detail::build_impl(InputBundle, UniqueDevices, PropList);
730  kernel_bundle<sycl::bundle_state::executable>>(Impl);
731 }
732 
733 inline kernel_bundle<bundle_state::executable>
735  const property_list &PropList = {}) {
736  return build(InputBundle, InputBundle.get_devices(), PropList);
737 }
738 
739 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
740 } // namespace sycl
741 
742 namespace std {
743 template <> struct hash<sycl::kernel_id> {
744  size_t operator()(const sycl::kernel_id &KernelID) const {
745  return hash<std::shared_ptr<sycl::detail::kernel_id_impl>>()(
746  sycl::detail::getSyclObjImpl(KernelID));
747  }
748 };
749 
750 template <sycl::bundle_state State> struct hash<sycl::device_image<State>> {
751  size_t operator()(const sycl::device_image<State> &DeviceImage) const {
752  return hash<std::shared_ptr<sycl::detail::device_image_impl>>()(
753  sycl::detail::getSyclObjImpl(DeviceImage));
754  }
755 };
756 
757 template <sycl::bundle_state State> struct hash<sycl::kernel_bundle<State>> {
758  size_t operator()(const sycl::kernel_bundle<State> &KernelBundle) const {
759  return hash<std::shared_ptr<sycl::detail::kernel_bundle_impl>>()(
760  sycl::detail::getSyclObjImpl(KernelBundle));
761  }
762 };
763 } // namespace std
sycl::_V1::build
kernel_bundle< bundle_state::executable > build(const kernel_bundle< bundle_state::input > &InputBundle, const std::vector< device > &Devs, const property_list &PropList={})
Definition: kernel_bundle.hpp:723
sycl::_V1::kernel_bundle::get_context
context get_context() const noexcept
Definition: kernel_bundle.hpp:219
sycl::_V1::property_list
Objects of the property_list class are containers for the SYCL properties.
Definition: property_list.hpp:24
sycl::_V1::detail::get_kernel_bundle_impl
detail::KernelBundleImplPtr get_kernel_bundle_impl(const context &Ctx, const std::vector< device > &Devs, bundle_state State, const DevImgSelectorImpl &Selector)
Definition: kernel_bundle.cpp:149
sycl::_V1::kernel_bundle::get_backend
backend get_backend() const noexcept
Definition: kernel_bundle.hpp:214
pi.h
sycl::_V1::backend
backend
Definition: backend_types.hpp:21
sycl::_V1::detail::device_image_plain::operator==
bool operator==(const device_image_plain &RHS) const
Definition: kernel_bundle.hpp:81
sycl::_V1::kernel_id::operator!=
bool operator!=(const kernel_id &RHS) const
Definition: kernel_bundle.hpp:53
sycl::_V1::kernel_bundle::get_kernel
kernel get_kernel() const
Definition: kernel_bundle.hpp:283
device.hpp
sycl::_V1::detail::DeviceImageImplPtr
std::shared_ptr< device_image_impl > DeviceImageImplPtr
Definition: kernel_bundle.hpp:72
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:11
sycl::_V1::detail::get_kernel_id_impl
kernel_id get_kernel_id_impl(std::string KernelName)
Definition: kernel_bundle.cpp:130
sycl::_V1::detail::memcpy
void memcpy(void *Dst, const void *Src, size_t Size)
Definition: memcpy.hpp:16
sycl::_V1::context::get_devices
std::vector< device > get_devices() const
Gets devices associated with this SYCL context.
Definition: context.cpp:139
sycl::_V1::kernel_bundle::native_specialization_constant
bool native_specialization_constant() const noexcept
Definition: kernel_bundle.hpp:267
context.hpp
sycl::_V1::kernel_bundle::has_kernel
bool has_kernel(const kernel_id &KernelID) const noexcept
Definition: kernel_bundle.hpp:230
sycl::_V1::detail::join_impl
std::shared_ptr< detail::kernel_bundle_impl > join_impl(const std::vector< detail::KernelBundleImplPtr > &Bundles, bundle_state State)
Definition: kernel_bundle.cpp:162
sycl::_V1::kernel_bundle::begin
device_image_iterator begin() const
Definition: kernel_bundle.hpp:327
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
sycl::_V1::detail::find_device_intersection
std::vector< sycl::device > find_device_intersection(const std::vector< kernel_bundle< bundle_state::object >> &ObjectBundles)
Definition: kernel_bundle.cpp:262
sycl::_V1::device_image
Objects of the class represents an instance of an image in a specific state.
Definition: kernel_bundle.hpp:108
sycl::_V1::detail::KernelBundleImplPtr
std::shared_ptr< detail::kernel_bundle_impl > KernelBundleImplPtr
Definition: kernel_bundle.hpp:138
sycl::_V1::detail::kernel_bundle_plain
Definition: kernel_bundle.hpp:141
pi.hpp
cast
To cast(From value)
Definition: pi_opencl.cpp:42
sycl::_V1::kernel_bundle::set_specialization_constant
void set_specialization_constant(typename std::remove_reference_t< decltype(SpecName)>::value_type Value)
Sets the value of the specialization constant whose address is SpecName for this bundle.
Definition: kernel_bundle.hpp:299
sycl::_V1::get_kernel_bundle
kernel_bundle< State > get_kernel_bundle(const context &Ctx, SelectorT Selector)
Definition: kernel_bundle.hpp:524
owner_less_base.hpp
sycl::_V1::detail::link_impl
std::shared_ptr< detail::kernel_bundle_impl > link_impl(const std::vector< kernel_bundle< bundle_state::object >> &ObjectBundles, const std::vector< device > &Devs, const property_list &PropList)
Definition: kernel_bundle.cpp:247
sycl::_V1::detail::enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Definition: stl_type_traits.hpp:24
sycl::_V1::kernel
Provides an abstraction of a SYCL kernel.
Definition: kernel.hpp:71
sycl::_V1::detail::get_empty_interop_kernel_bundle_impl
detail::KernelBundleImplPtr get_empty_interop_kernel_bundle_impl(const context &Ctx, const std::vector< device > &Devs)
Definition: kernel_bundle.cpp:156
sycl::_V1::kernel_bundle::get_specialization_constant
std::remove_reference_t< decltype(SpecName)>::value_type get_specialization_constant() const
Definition: kernel_bundle.hpp:310
kernel.hpp
sycl::_V1::detail::compile_impl
std::shared_ptr< detail::kernel_bundle_impl > compile_impl(const kernel_bundle< bundle_state::input > &InputBundle, const std::vector< device > &Devs, const property_list &PropList)
Definition: kernel_bundle.cpp:240
sycl::_V1::kernel_id::operator==
bool operator==(const kernel_id &RHS) const
Definition: kernel_bundle.hpp:51
sycl::_V1::kernel_bundle::get_devices
std::vector< device > get_devices() const noexcept
Definition: kernel_bundle.hpp:224
kernel_bundle_enums.hpp
sycl::_V1::detail::OwnerLessBase
Definition: owner_less_base.hpp:21
sycl::_V1::detail::device_image_plain::device_image_plain
device_image_plain(const detail::DeviceImageImplPtr &Impl)
Definition: kernel_bundle.hpp:78
sycl::_V1::detail::device_image_plain::impl
detail::DeviceImageImplPtr impl
Definition: kernel_bundle.hpp:96
sycl::_V1::detail::has_kernel_bundle_impl
bool has_kernel_bundle_impl(const context &Ctx, const std::vector< device > &Devs, const std::vector< kernel_id > &kernelIds, bundle_state State)
Definition: kernel_bundle.cpp:190
sycl::_V1::kernel_bundle::has_kernel
bool has_kernel(const kernel_id &KernelID, const device &Dev) const noexcept
Definition: kernel_bundle.hpp:237
sycl::_V1::kernel_id
Objects of the class identify kernel is some kernel_bundle related APIs.
Definition: kernel_bundle.hpp:44
sycl::_V1::detail::kernel_bundle_plain::kernel_bundle_plain
kernel_bundle_plain(const detail::KernelBundleImplPtr &Impl)
Definition: kernel_bundle.hpp:143
sycl::_V1::kernel_bundle
The kernel_bundle class represents collection of device images in a particular state.
Definition: kernel.hpp:29
common.hpp
sycl::_V1::kernel_bundle::end
device_image_iterator end() const
Definition: kernel_bundle.hpp:333
sycl::_V1::detail::device_image_plain::operator!=
bool operator!=(const device_image_plain &RHS) const
Definition: kernel_bundle.hpp:85
sycl::_V1::device_image::has_kernel
bool has_kernel(const kernel_id &KernelID, const device &Dev) const noexcept
Definition: kernel_bundle.hpp:121
sycl::_V1::detail::kernel_bundle_plain::operator!=
bool operator!=(const kernel_bundle_plain &RHS) const
Definition: kernel_bundle.hpp:150
sycl::_V1::device
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:49
sycl::_V1::kernel_bundle::has_kernel
bool has_kernel(const device &Dev) const noexcept
Definition: kernel_bundle.hpp:250
sycl::_V1::detail::createSyclObjFromImpl
T createSyclObjFromImpl(decltype(T::impl) ImplObj)
Definition: common.hpp:318
sycl::_V1::detail::get_empty_interop_kernel_bundle
kernel_bundle< State > get_empty_interop_kernel_bundle(const context &Ctx)
make_kernel may need an empty interop kernel bundle.
Definition: kernel_bundle.hpp:496
sycl::_V1::kernel_bundle::has_specialization_constant
bool has_specialization_constant() const noexcept
Definition: kernel_bundle.hpp:289
pi_native_handle
uintptr_t pi_native_handle
Definition: pi.h:133
sycl::_V1::detail::removeDuplicateDevices
const std::vector< device > removeDuplicateDevices(const std::vector< device > &Devs)
Definition: kernel_bundle.cpp:118
sycl::_V1::detail::remove_reference_t
typename std::remove_reference< T >::type remove_reference_t
Definition: stl_type_traits.hpp:35
sycl::_V1::has_kernel_bundle
bool has_kernel_bundle(const context &Ctx, const std::vector< device > &Devs)
Definition: kernel_bundle.hpp:581
sycl::_V1::device_image::has_kernel
bool has_kernel(const kernel_id &KernelID) const noexcept
Definition: kernel_bundle.hpp:115
sycl::_V1::link
kernel_bundle< bundle_state::executable > link(const kernel_bundle< bundle_state::object > &ObjectBundle, const std::vector< device > &Devs, const property_list &PropList={})
Definition: kernel_bundle.hpp:702
std::hash< sycl::kernel_id >::operator()
size_t operator()(const sycl::kernel_id &KernelID) const
Definition: kernel_bundle.hpp:744
sycl::_V1::detail::device_image_plain
Definition: kernel_bundle.hpp:76
sycl::_V1::get_kernel_id
kernel_id get_kernel_id()
Definition: kernel_bundle.hpp:381
sycl::_V1::kernel_bundle::get_kernel_ids
std::vector< kernel_id > get_kernel_ids() const
Definition: kernel_bundle.hpp:255
std
Definition: accessor.hpp:3230
sycl::_V1::kernel_bundle::get_kernel
kernel get_kernel(const kernel_id &KernelID) const
Definition: kernel_bundle.hpp:275
kernel_desc.hpp
std::hash< sycl::device_image< State > >::operator()
size_t operator()(const sycl::device_image< State > &DeviceImage) const
Definition: kernel_bundle.hpp:751
sycl::_V1::join
sycl::kernel_bundle< State > join(const std::vector< sycl::kernel_bundle< State >> &Bundles)
Definition: kernel_bundle.hpp:613
sycl::_V1::is_compatible
bool is_compatible(const device &Dev)
Definition: kernel_bundle.hpp:594
sycl::_V1::kernel_bundle::has_kernel
bool has_kernel() const noexcept
Definition: kernel_bundle.hpp:243
sycl::_V1::get_kernel_ids
std::vector< kernel_id > get_kernel_ids()
Definition: kernel_bundle.cpp:288
sycl::_V1::detail::kernel_bundle_plain::impl
detail::KernelBundleImplPtr impl
Definition: kernel_bundle.hpp:193
sycl::_V1::kernel_bundle
kernel_bundle(kernel_bundle< State > &&) -> kernel_bundle< State >
sycl::_V1::compile
kernel_bundle< bundle_state::object > compile(const kernel_bundle< bundle_state::input > &InputBundle, const property_list &PropList={})
Definition: kernel_bundle.hpp:652
sycl::_V1::bundle_state
bundle_state
Definition: kernel_bundle_enums.hpp:14
sycl::_V1::kernel_bundle::empty
bool empty() const noexcept
Definition: kernel_bundle.hpp:211
sycl::_V1::detail::kernel_bundle_plain::operator==
bool operator==(const kernel_bundle_plain &RHS) const
Definition: kernel_bundle.hpp:146
weak_object_base.hpp
sycl::_V1::kernel_bundle::contains_specialization_constants
bool contains_specialization_constants() const noexcept
Definition: kernel_bundle.hpp:261
sycl::_V1::detail::build_impl
std::shared_ptr< detail::kernel_bundle_impl > build_impl(const kernel_bundle< bundle_state::input > &InputBundle, const std::vector< device > &Devs, const property_list &PropList)
Definition: kernel_bundle.cpp:254
sycl::_V1::get_native
auto get_native(const SyclObjectT &Obj) -> backend_return_t< BackendName, SyclObjectT >
Definition: backend.hpp:123
std::hash< sycl::kernel_bundle< State > >::operator()
size_t operator()(const sycl::kernel_bundle< State > &KernelBundle) const
Definition: kernel_bundle.hpp:758
sycl::_V1::detail::getSyclObjImpl
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: common.hpp:300
sycl::_V1::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:41
sycl::_V1::detail::DevImgSelectorImpl
std::function< bool(const detail::DeviceImageImplPtr &DevImgImpl)> DevImgSelectorImpl
Definition: kernel_bundle.hpp:479