Skip to content

Commit b400aa4

Browse files
committed
Merge from 'sycl' to 'sycl-web' (2 commits)
CONFLICT (content): Merge conflict in libclc/CMakeLists.txt CONFLICT (content): Merge conflict in libclc/clc/include/clc/clcfunc.h CONFLICT (content): Merge conflict in libclc/cmake/modules/AddLibclc.cmake CONFLICT (content): Merge conflict in libclc/generic/include/config.h CONFLICT (content): Merge conflict in libclc/generic/include/core/clc_core.h CONFLICT (content): Merge conflict in libclc/generic/include/math/math.h CONFLICT (content): Merge conflict in libclc/generic/lib/math/math.h CONFLICT (content): Merge conflict in libclc/native_cpu-unknown-linux/libspirv/math/helpers.h
2 parents e68e2fc + 4602c16 commit b400aa4

File tree

11 files changed

+206
-13
lines changed

11 files changed

+206
-13
lines changed

libclc/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
3535
r600/libspirv/SOURCES;
3636
spirv/lib/SOURCES;
3737
spirv64/lib/SOURCES;
38-
native_cpu-unknown-linux/libspirv/SOURCES
38+
native_cpu-unknown-linux/libspirv/SOURCES;
3939
# CLC internal libraries
4040
clc/lib/generic/SOURCES;
4141
clc/lib/clspv/SOURCES;
@@ -534,8 +534,9 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
534534
LIB_FILES ${libspirv_lib_files}
535535
GEN_FILES ${libspirv_gen_files}
536536
ALIASES ${${d}_aliases}
537-
GENERATE_TARGET "generate_convert_spirv.cl" "generate_convert_core.cl"
538537
PARENT_TARGET libspirv-builtins
538+
# Link in the CLC builtins and internalize their symbols
539+
INTERNAL_LINK_DEPENDENCIES $<TARGET_PROPERTY:builtins.link.clc-${arch_suffix},TARGET_FILE>
539540
)
540541

541542
add_libclc_builtin_set(
@@ -547,7 +548,6 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
547548
LIB_FILES ${opencl_lib_files}
548549
GEN_FILES ${opencl_gen_files}
549550
ALIASES ${${d}_aliases}
550-
GENERATE_TARGET "generate_convert_clc.cl"
551551
PARENT_TARGET libopencl-builtins
552552
# Link in the CLC builtins and internalize their symbols
553553
INTERNAL_LINK_DEPENDENCIES $<TARGET_PROPERTY:builtins.link.clc-${arch_suffix},TARGET_FILE>

libclc/clc/include/clc/clcfunc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
#define _CLC_OVERLOAD __attribute__((overloadable))
55
#define _CLC_DECL
6+
#define _CLC_INLINE __attribute__((always_inline)) inline
7+
#define _CLC_CONVERGENT __attribute__((convergent))
8+
#define _CLC_PURE __attribute__((pure))
9+
#define _CLC_CONSTFN __attribute__((const))
10+
611
// avoid inlines for SPIR-V related targets since we'll optimise later in the
712
// chain
813
#if defined(CLC_SPIRV) || defined(CLC_SPIRV64)

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ function(add_libclc_builtin_set)
361361

362362
set( builtins_link_lib_tgt builtins.link.${ARG_ARCH_SUFFIX} )
363363

364-
365364
if( NOT ARG_INTERNAL_LINK_DEPENDENCIES )
366365
link_bc(
367366
TARGET ${builtins_link_lib_tgt}

libclc/generic/include/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* THE SOFTWARE.
2121
*/
2222

23-
#include "clc/clcfunc.h"
23+
#include <clc/clcfunc.h>
2424

2525
_CLC_DECL bool __clc_subnormals_disabled();
2626
_CLC_DECL bool __clc_fp16_subnormals_supported();

libclc/generic/include/core/clc_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
#include <as_type.h>
3232
#include <clc/clcfunc.h>
33-
#include <macros.h>
3433
#include <clc/clctypes.h>
34+
#include <macros.h>
3535

3636
#include <clc/float/definitions.h>
3737
#include <clc/integer/definitions.h>

libclc/generic/include/math/math.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "as_type.h"
1313
#include "config.h"
14-
#include "clc/clcfunc.h"
14+
#include <clc/clcfunc.h>
1515

1616
#define SNAN 0x001
1717
#define QNAN 0x002

libclc/generic/lib/math/math.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
#ifndef __CLC_MATH_H_
2424
#define __CLC_MATH_H_
2525

26-
#include "clc/clcfunc.h"
2726
#include "as_type.h"
2827
#include "config.h"
28+
#include <clc/clcfunc.h>
2929

3030
#define SNAN 0x001
3131
#define QNAN 0x002

libclc/native_cpu-unknown-linux/libspirv/math/helpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include "clc/clcfunc.h"
2-
#include "clc/clctypes.h"
1+
#include <clc/clcfunc.h>
2+
#include <clc/clctypes.h>
33

44
#ifdef cl_khr_fp16
55
#pragma OPENCL EXTENSION cl_khr_fp16 : enable

sycl/doc/extensions/experimental/sycl_ext_oneapi_enqueue_functions.asciidoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ namespace sycl::ext::oneapi::experimental {
233233
template <typename CommandGroupFunc>
234234
void submit(sycl::queue q, CommandGroupFunc&& cgf);
235235
236+
template <typename CommandGroupFunc, typename Properties>
237+
void submit(sycl::queue q, Properties properties, CommandGroupFunc&& cgf);
238+
236239
}
237240
----
238241
!====
@@ -250,6 +253,10 @@ namespace sycl::ext::oneapi::experimental {
250253
template <typename CommandGroupFunc>
251254
sycl::event submit_with_event(sycl::queue q, CommandGroupFunc&& cgf);
252255
256+
template <typename CommandGroupFunc, typename Properties>
257+
sycl::event submit_with_event(sycl::queue q, Properties properties,
258+
CommandGroupFunc&& cgf);
259+
253260
}
254261
----
255262
!====
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
= sycl_ext_intel_event_mode
2+
3+
:source-highlighter: coderay
4+
:coderay-linenums-mode: table
5+
6+
// This section needs to be after the document title.
7+
:doctype: book
8+
:toc2:
9+
:toc: left
10+
:encoding: utf-8
11+
:lang: en
12+
:dpcpp: pass:[DPC++]
13+
:endnote: &#8212;{nbsp}end{nbsp}note
14+
15+
// Set the default source code type in this document to C++,
16+
// for syntax highlighting purposes. This is needed because
17+
// docbook uses c++ and html5 uses cpp.
18+
:language: {basebackend@docbook:c++:cpp}
19+
20+
:common_ref_sem: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:reference-semantics
21+
22+
== Notice
23+
24+
[%hardbreaks]
25+
Copyright (C) 2024 Intel Corporation. All rights reserved.
26+
27+
Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks
28+
of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by
29+
permission by Khronos.
30+
31+
32+
== Contact
33+
34+
To report problems with this extension, please open a new issue at:
35+
36+
https://github.com/intel/llvm/issues
37+
38+
39+
== Dependencies
40+
41+
This extension is written against the SYCL 2020 revision 9 specification. All
42+
references below to the "core SYCL specification" or to section numbers in the
43+
SYCL specification refer to that revision.
44+
45+
This extension also depends on the following other SYCL extensions:
46+
47+
* link:../experimental/sycl_ext_oneapi_enqueue_functions.asciidoc[
48+
sycl_ext_oneapi_enqueue_functions]
49+
* link:../experimental/sycl_ext_oneapi_properties.asciidoc[
50+
sycl_ext_oneapi_properties]
51+
52+
53+
== Status
54+
55+
This is a proposed extension specification, intended to gather community
56+
feedback. Interfaces defined in this specification may not be implemented yet
57+
or may be in a preliminary state. The specification itself may also change in
58+
incompatible ways before it is finalized. *Shipping software products should
59+
not rely on APIs defined in this specification.*
60+
61+
62+
== Overview
63+
64+
On some backends, calling `wait()` on an `event` will synchronize using a
65+
busy-waiting implementation. Though this comes at a low latency for the
66+
synchronization of the event, it has the downside of consuming high amounts of
67+
CPU time for no meaningful work. This extension introduces a new property for
68+
SYCL commands that allow users to pick modes for the associated events, one of
69+
these modes being a "low-power" event. These new low-power events will, if
70+
possible, yield the thread that the `wait()` member function is called on and
71+
only wake up occasionally to check if the event has finished. This reduces the
72+
time the CPU spends checking finish condition of the wait, at the cost of
73+
latency.
74+
75+
76+
== Specification
77+
78+
=== Feature test macro
79+
80+
This extension provides a feature-test macro as described in the core SYCL
81+
specification. An implementation supporting this extension must predefine the
82+
macro `SYCL_EXT_INTEL_EVENT_MODE` to one of the values defined in the table
83+
below. Applications can test for the existence of this macro to determine if
84+
the implementation supports this feature, or applications can test the macro's
85+
value to determine which of the extension's features the implementation
86+
supports.
87+
88+
[%header,cols="1,5"]
89+
|===
90+
|Value
91+
|Description
92+
93+
|1
94+
|The APIs of this experimental extension are not versioned, so the
95+
feature-test macro always has this value.
96+
|===
97+
98+
99+
=== Event mode property
100+
101+
This extension adds a new property `event_mode` which can be used with the
102+
`submit_with_event` free function from
103+
link:../experimental/sycl_ext_oneapi_enqueue_functions.asciidoc[sycl_ext_oneapi_enqueue_functions],
104+
allowing the user some control over how the resulting event is created and
105+
managed.
106+
107+
```
108+
namespace sycl::ext::intel::experimental {
109+
110+
enum class event_mode_enum { none, low_power };
111+
112+
struct event_mode {
113+
event_mode(event_mode_enum mode);
114+
115+
event_mode_enum value;
116+
};
117+
118+
using event_mode_key = event_mode;
119+
120+
} // namespace sycl::ext::intel::experimental
121+
```
122+
123+
124+
=== Low power event mode
125+
126+
Passing the `event_mode` property with `event_mode_enum::low_power` to
127+
`submit_with_event` will act as a hint to the `event` created from the
128+
corresponding commands to do low-power synchronization. If the backend is able
129+
to handle low-power events, calling `event::wait()` or `event::wait_and_throw()`
130+
will cause the thread to yield and only do occasional wake-ups to check the
131+
event progress.
132+
133+
[_Note:_ The low-power event mode currently only has an effect on `barrier` and
134+
`partial_barrier` commands enqueued on queues that return
135+
`backend::ext_oneapi_level_zero` from `queue::get_backend()`.
136+
_{endnote}_]
137+
138+
139+
=== New property usage example
140+
141+
As an example of how to use the new `event_mode` property using the
142+
`event_mode_enum::low_power` mode, see the following code:
143+
144+
```
145+
#include <sycl/sycl.hpp>
146+
147+
namespace oneapiex = sycl::ext::oneapi::experimental;
148+
namespace intelex = sycl::ext::intel::experimental;
149+
150+
int main() {
151+
sycl::queue Q;
152+
153+
// Submit some work to the queue.
154+
oneapiex::submit(Q, [&](sycl::handler &CGH) {...});
155+
156+
// Submit a command with the low-power event mode.
157+
oneapiex::properties Props{intelex::event_mode{intelex::event_mode_enum::low_power}};
158+
sycl::event E = oneapiex::submit_with_event(Q, Props, [&](sycl::handler &CGH) {
159+
...
160+
});
161+
162+
// Waiting for the resulting event will use low-power waiting if possible.
163+
E.wait();
164+
}
165+
```

sycl/include/sycl/ext/oneapi/experimental/enqueue_functions.hpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,38 @@ void submit_impl(queue &Q, CommandGroupFunc &&CGF,
9595
}
9696
} // namespace detail
9797

98-
template <typename CommandGroupFunc>
99-
void submit(queue Q, CommandGroupFunc &&CGF,
98+
template <typename CommandGroupFunc, typename PropertiesT>
99+
void submit(queue Q, PropertiesT Props, CommandGroupFunc &&CGF,
100100
const sycl::detail::code_location &CodeLoc =
101101
sycl::detail::code_location::current()) {
102+
std::ignore = Props;
102103
sycl::ext::oneapi::experimental::detail::submit_impl(
103104
Q, std::forward<CommandGroupFunc>(CGF), CodeLoc);
104105
}
105106

106107
template <typename CommandGroupFunc>
107-
event submit_with_event(queue Q, CommandGroupFunc &&CGF,
108+
void submit(queue Q, CommandGroupFunc &&CGF,
109+
const sycl::detail::code_location &CodeLoc =
110+
sycl::detail::code_location::current()) {
111+
submit(Q, empty_properties_t{}, std::forward<CommandGroupFunc>(CGF), CodeLoc);
112+
}
113+
114+
template <typename CommandGroupFunc, typename PropertiesT>
115+
event submit_with_event(queue Q, PropertiesT Props, CommandGroupFunc &&CGF,
108116
const sycl::detail::code_location &CodeLoc =
109117
sycl::detail::code_location::current()) {
118+
std::ignore = Props;
110119
return Q.submit(std::forward<CommandGroupFunc>(CGF), CodeLoc);
111120
}
112121

122+
template <typename CommandGroupFunc>
123+
event submit_with_event(queue Q, CommandGroupFunc &&CGF,
124+
const sycl::detail::code_location &CodeLoc =
125+
sycl::detail::code_location::current()) {
126+
return submit_with_event(Q, empty_properties_t{},
127+
std::forward<CommandGroupFunc>(CGF), CodeLoc);
128+
}
129+
113130
template <typename KernelName = sycl::detail::auto_name, typename KernelType>
114131
void single_task(handler &CGH, const KernelType &KernelObj) {
115132
CGH.single_task<KernelName>(KernelObj);

0 commit comments

Comments
 (0)