44 :
context(Platform.get_devices(), PropList) {}
48 :
context(Platform.get_devices(), AsyncHandler, PropList) {}
56 if (DeviceList.empty()) {
57 throw invalid_parameter_error(
"DeviceList is empty.",
58 PI_ERROR_INVALID_VALUE);
60 auto NonHostDeviceIter = std::find_if_not(
61 DeviceList.begin(), DeviceList.end(),
62 [&](
const device &CurrentDevice) { return CurrentDevice.is_host(); });
63 if (NonHostDeviceIter == DeviceList.end())
64 impl = std::make_shared<detail::context_impl>(DeviceList[0], AsyncHandler,
67 const device &NonHostDevice = *NonHostDeviceIter;
68 const auto &NonHostPlatform =
70 if (
std::any_of(DeviceList.begin(), DeviceList.end(),
71 [&](
const device &CurrentDevice) {
73 CurrentDevice.is_host() ||
74 (detail::getSyclObjImpl(CurrentDevice.get_platform())
75 ->getHandleRef() != NonHostPlatform));
77 throw invalid_parameter_error(
78 "Can't add devices across platforms to a single context.",
79 PI_ERROR_INVALID_DEVICE);
81 impl = std::make_shared<detail::context_impl>(DeviceList, AsyncHandler,
86 const auto &Plugin = RT::getPlugin<backend::opencl>();
87 impl = std::make_shared<detail::context_impl>(
88 detail::pi::cast<detail::RT::PiContext>(ClContext), AsyncHandler, Plugin);
91 #define __SYCL_PARAM_TRAITS_SPEC(param_type, param, ret_type) \
93 __SYCL_EXPORT ret_type context::get_info<info::param_type::param>() const { \
94 return impl->get_info<info::param_type::param>(); \
97 #include <CL/sycl/info/context_traits.def>
99 #undef __SYCL_PARAM_TRAITS_SPEC
101 #define __SYCL_PARAM_TRAITS_SPEC(param_type) \
102 template <> __SYCL_EXPORT bool context::has_property<param_type>() const { \
103 return impl->has_property<param_type>(); \
105 #include <CL/sycl/detail/properties_traits.def>
107 #undef __SYCL_PARAM_TRAITS_SPEC
109 #define __SYCL_PARAM_TRAITS_SPEC(param_type) \
111 __SYCL_EXPORT param_type context::get_property<param_type>() const { \
112 return impl->get_property<param_type>(); \
114 #include <CL/sycl/detail/properties_traits.def>
116 #undef __SYCL_PARAM_TRAITS_SPEC
132 context::context(std::shared_ptr<detail::context_impl> Impl) : impl(Impl) {}