DPC++ Runtime
Runtime libraries for oneAPI DPC++
handler_impl.hpp
Go to the documentation of this file.
1 //==---------------- handler_impl.hpp - SYCL handler -----------------------==//
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 
12 
13 namespace sycl {
15 namespace detail {
16 
17 using KernelBundleImplPtr = std::shared_ptr<detail::kernel_bundle_impl>;
18 
19 enum class HandlerSubmissionState : std::uint8_t {
20  NO_STATE = 0,
23 };
24 
25 class handler_impl {
26 public:
27  handler_impl(std::shared_ptr<queue_impl> SubmissionPrimaryQueue,
28  std::shared_ptr<queue_impl> SubmissionSecondaryQueue)
29  : MSubmissionPrimaryQueue(std::move(SubmissionPrimaryQueue)),
30  MSubmissionSecondaryQueue(std::move(SubmissionSecondaryQueue)){};
31 
33  if (MSubmissionState == HandlerSubmissionState::SPEC_CONST_SET_STATE)
34  throw sycl::exception(
35  make_error_code(errc::invalid),
36  "Kernel bundle cannot be explicitly set after a specialization "
37  "constant has been set");
38  MSubmissionState = HandlerSubmissionState::EXPLICIT_KERNEL_BUNDLE_STATE;
39  }
40 
42  if (MSubmissionState ==
43  HandlerSubmissionState::EXPLICIT_KERNEL_BUNDLE_STATE)
44  throw sycl::exception(make_error_code(errc::invalid),
45  "Specialization constants cannot be set after "
46  "explicitly setting the used kernel bundle");
47  MSubmissionState = HandlerSubmissionState::SPEC_CONST_SET_STATE;
48  }
49 
51  return MSubmissionState ==
52  HandlerSubmissionState::EXPLICIT_KERNEL_BUNDLE_STATE;
53  }
54 
56  HandlerSubmissionState MSubmissionState = HandlerSubmissionState::NO_STATE;
57 
61  std::shared_ptr<queue_impl> MSubmissionPrimaryQueue;
62 
67  std::shared_ptr<queue_impl> MSubmissionSecondaryQueue;
68 
69  // Stores auxiliary resources used by internal operations.
70  std::vector<std::shared_ptr<const void>> MAuxiliaryResources;
71 
72  std::shared_ptr<detail::kernel_bundle_impl> MKernelBundle;
73 
75 };
76 
77 } // namespace detail
78 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
79 } // namespace sycl
std::shared_ptr< queue_impl > MSubmissionSecondaryQueue
Shared pointer to the secondary queue implementation.
std::vector< std::shared_ptr< const void > > MAuxiliaryResources
handler_impl(std::shared_ptr< queue_impl > SubmissionPrimaryQueue, std::shared_ptr< queue_impl > SubmissionSecondaryQueue)
std::shared_ptr< queue_impl > MSubmissionPrimaryQueue
Shared pointer to the primary queue implementation.
std::shared_ptr< detail::kernel_bundle_impl > MKernelBundle
#define __SYCL_INLINE_VER_NAMESPACE(X)
std::shared_ptr< detail::kernel_bundle_impl > KernelBundleImplPtr
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
Definition: exception.cpp:91
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
_pi_mem_advice
Definition: pi.h:429