DPC++ Runtime
Runtime libraries for oneAPI DPC++
profiling_tag.hpp
Go to the documentation of this file.
1 //==--------- profiling_tag.hpp --- SYCL profiling tag extension -----------==//
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/aspects.hpp>
12 #include <sycl/event.hpp>
13 #include <sycl/handler.hpp>
15 #include <sycl/queue.hpp>
16 
17 namespace sycl {
18 inline namespace _V1 {
19 namespace ext::oneapi::experimental {
20 
21 inline event submit_profiling_tag(queue &Queue,
22  const sycl::detail::code_location &CodeLoc =
23  sycl::detail::code_location::current()) {
24  if (Queue.get_device().has(aspect::ext_oneapi_queue_profiling_tag)) {
25  return Queue.submit(
26  [=](handler &CGH) {
27  sycl::detail::HandlerAccess::internalProfilingTagImpl(CGH);
28  },
29  CodeLoc);
30  }
31 
32  // If it is not supported natively on the device, we use another path if
33  // profiling is enabled.
34  if (!Queue.has_property<sycl::property::queue::enable_profiling>())
35  throw sycl::exception(
37  "Device must either have aspect::ext_oneapi_queue_profiling_tag or the "
38  "queue must have profiling enabled.");
39  return Queue.ext_oneapi_submit_barrier();
40 }
41 
42 } // namespace ext::oneapi::experimental
43 } // namespace _V1
44 } // namespace sycl
bool has(aspect Aspect) const __SYCL_WARN_IMAGE_ASPECT(Aspect)
Indicates if the SYCL device has the given feature.
Definition: device.cpp:207
Command group handler class.
Definition: handler.hpp:467
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:110
device get_device() const
Definition: queue.cpp:77
event ext_oneapi_submit_barrier(const detail::code_location &CodeLoc=detail::code_location::current())
Prevents any commands submitted afterward to this queue from executing until all commands previously ...
Definition: queue.cpp:223
bool has_property() const noexcept
Definition: queue.hpp:465
std::enable_if_t< std::is_invocable_r_v< void, T, handler & >, event > submit(T CGF, const detail::code_location &CodeLoc=detail::code_location::current())
Submits a command group function object to the queue, in order to be scheduled for execution on the d...
Definition: queue.hpp:340
event submit_profiling_tag(queue &Queue, const sycl::detail::code_location &CodeLoc=sycl::detail::code_location::current())
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
Definition: exception.cpp:65
Definition: access.hpp:18