File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
sycl/include/sycl/ext/oneapi/experimental Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ // ==-------- clock.hpp --- SYCL extension for clock() free function --------==//
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/__spirv/spirv_ops.hpp>
12+ #include < sycl/exception.hpp>
13+
14+ namespace sycl {
15+ inline namespace _V1 {
16+ namespace ext ::oneapi::experimental {
17+
18+ enum class clock_scope : int {
19+ // Aligned with SPIR-V Scope<id> values
20+ device = 1 ,
21+ work_group = 2 ,
22+ sub_group = 3
23+ };
24+
25+ uint64_t clock (clock_scope scope = clock_scope::sub_group) {
26+ #ifdef __SYCL_DEVICE_ONLY__
27+ return __spirv_ReadClockKHR (static_cast <int >(scope));
28+ #else
29+ throw sycl::exception (
30+ make_error_code (errc::runtime),
31+ " sycl::ext::oneapi::experimental::clock() is not supported on host." );
32+ #endif // __SYCL_DEVICE_ONLY__
33+ }
34+
35+ } // namespace ext::oneapi::experimental
36+ } // namespace _V1
37+ } // namespace sycl
You can’t perform that action at this time.
0 commit comments