DPC++ Runtime
Runtime libraries for oneAPI DPC++
queue_v3.cpp
Go to the documentation of this file.
1 //==-------------- queue_v3.cpp --------------------------------------------==//
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 // This file implements queue constructors for earlier releases and file
10 // queue.cpp implements queue constructors for the current release. This enables
11 // different default queue implementations for old and current user code, a
12 // feature needed on some platforms. This temporary and will be removed in the
13 // next release.
14 
15 #define __SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO_V3
16 #include <detail/backend_impl.hpp>
17 #include <detail/event_impl.hpp>
18 #include <detail/queue_impl.hpp>
19 #include <sycl/detail/common.hpp>
20 #include <sycl/event.hpp>
21 #include <sycl/exception_list.hpp>
23 #include <sycl/handler.hpp>
24 #include <sycl/queue.hpp>
25 
26 #include <algorithm>
27 
28 namespace sycl {
29 inline namespace _V1 {
30 
31 queue::queue(const context &SyclContext, const device_selector &DeviceSelector,
32  const async_handler &AsyncHandler, const property_list &PropList) {
33 
34  const std::vector<device> Devs = SyclContext.get_devices();
35 
36  auto Comp = [&DeviceSelector](const device &d1, const device &d2) {
37  return DeviceSelector(d1) < DeviceSelector(d2);
38  };
39 
40  const device &SyclDevice = *std::max_element(Devs.begin(), Devs.end(), Comp);
41 
42  impl = std::make_shared<detail::queue_impl>(
43  detail::getSyclObjImpl(SyclDevice), detail::getSyclObjImpl(SyclContext),
44  AsyncHandler, PropList, true);
45 }
46 
47 queue::queue(const context &SyclContext, const device &SyclDevice,
48  const async_handler &AsyncHandler, const property_list &PropList) {
49  impl = std::make_shared<detail::queue_impl>(
50  detail::getSyclObjImpl(SyclDevice), detail::getSyclObjImpl(SyclContext),
51  AsyncHandler, PropList, true);
52 }
53 
54 queue::queue(const device &SyclDevice, const async_handler &AsyncHandler,
55  const property_list &PropList) {
56  impl = std::make_shared<detail::queue_impl>(
57  detail::getSyclObjImpl(SyclDevice), AsyncHandler, PropList, true);
58 }
59 
60 queue::queue(const context &SyclContext, const device_selector &deviceSelector,
61  const property_list &PropList)
62  : queue(SyclContext, deviceSelector,
63  detail::getSyclObjImpl(SyclContext)->get_async_handler(),
64  PropList) {}
65 
66 queue::queue(const context &SyclContext, const device &SyclDevice,
67  const property_list &PropList)
68  : queue(SyclContext, SyclDevice,
69  detail::getSyclObjImpl(SyclContext)->get_async_handler(),
70  PropList) {}
71 
72 } // namespace _V1
73 } // namespace sycl
const property_list & PropList
Definition: queue.hpp:203
queue(const property_list &PropList={})
Constructs a SYCL queue instance using the device returned by an instance of default_selector.
Definition: queue.hpp:125
const device_selector const async_handler & AsyncHandler
Definition: queue.hpp:257
const device_selector & DeviceSelector
Definition: queue.hpp:243
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: impl_utils.hpp:30
std::function< void(sycl::exception_list)> async_handler
Definition: access.hpp:18