Skip to content

Commit 11795f3

Browse files
committed
Merge branch 'sycl' into cperkins-windows-shutdown-fix
2 parents fc42629 + 042b307 commit 11795f3

30 files changed

+737
-639
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
= SYCL(TM) Proposals: Platform Default Contexts
2+
James Brodman <james[email protected]>
3+
v0.1
4+
:source-highlighter: pygments
5+
:icons: font
6+
:y: icon:check[role="green"]
7+
:n: icon:times[role="red"]
8+
:dpcpp: pass:[DPC++]
9+
10+
== Platform Default Contexts
11+
12+
== Status
13+
14+
This extension has been deprecated. Although it is still supported in {dpcpp},
15+
we expect that the interfaces defined in this specification will be removed in
16+
an upcoming {dpcpp} release. *Shipping software products should stop using
17+
APIs defined in this specification and use an alternative instead.*
18+
19+
== Overview
20+
21+
This extension adds the notion of a default SYCL context per SYCL platform. The default context for each platform contains all devices in the platform.
22+
23+
The platform class gains one new method:
24+
25+
[cols="^60a,40"]
26+
|===
27+
| Member Function | Description
28+
29+
|
30+
[source,c++]
31+
----
32+
context ext_oneapi_get_default_context()
33+
----
34+
35+
| Returns the current default context for this `platform`
36+
37+
|===
38+
39+
This extension also modifies the behavior of `queue` constructors. Queues will no longer create a new `context` upon construction. Instead, they will use the default context from the device's platform.
40+
41+
== Feature Test Macro
42+
43+
This extension defines the macro `SYCL_EXT_ONEAPI_DEFAULT_CONTEXT` to `1` to indicate that it is enabled.
44+

sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -485,53 +485,52 @@ a!
485485
----
486486
namespace sycl::ext::oneapi::experimental {
487487
488-
struct registered_kernel_names {
489-
registered_kernel_names(); (1)
490-
registered_kernel_names(const std::string &name); (2)
491-
registered_kernel_names(const std::vector<std::string> &names); (3)
492-
void add(const std::string &name); (4)
488+
struct registered_names {
489+
registered_names(); (1)
490+
registered_names(const std::string &name); (2)
491+
registered_names(const std::vector<std::string> &names); (3)
492+
void add(const std::string &name); (4)
493493
};
494-
using registered_kernel_names_key = registered_kernel_names;
494+
using registered_names_key = registered_names;
495495
496496
template<>
497-
struct is_property_key<registered_kernel_names_key> : std::true_type {};
497+
struct is_property_key<registered_names_key> : std::true_type {};
498498
499499
} // namespace sycl::ext::oneapi::experimental
500500
----
501501
!====
502502

503-
This property is useful when the source language represents kernel names
504-
differently in the source code and the generated code.
505-
For example, {cpp} function names in the generated code are "mangled" in an
506-
implementation-defined way.
503+
This property is useful when the source language represents names differently in
504+
the source code and the generated code.
505+
For example, {cpp} function names and the names of static variables at global
506+
scope are "mangled" in an implementation-defined way in the generated code.
507507
The precise meaning of this property is defined by each source language, but in
508-
general it allows the application to supply a list of kernel names as they
509-
appear in the source code.
508+
general it allows the application to supply a list of names as they appear in
509+
the source code.
510510
The application can then get the corresponding raw (i.e. mangled) names after
511511
the code is compiled.
512512
See the section below "Obtaining a kernel when the language is ``sycl``" for a
513513
description of how this property is used with the `source_language::sycl`
514514
language.
515515

516-
_Effects (1):_ Creates a new `registered_kernel_names` property with no
517-
registered kernel names.
516+
_Effects (1):_ Creates a new `registered_names` property with no registered
517+
names.
518518

519-
_Effects (2):_ Creates a new `registered_kernel_names` property with a single
520-
registered kernel name.
519+
_Effects (2):_ Creates a new `registered_names` property with a single
520+
registered name.
521521

522-
_Effects (3):_ Creates a new `registered_kernel_names` property from a vector
523-
of kernel names.
522+
_Effects (3):_ Creates a new `registered_names` property from a vector of names.
524523

525-
_Effects (4):_ Adds `name` to the property's list of registered kernel names.
524+
_Effects (4):_ Adds `name` to the property's list of registered names.
526525

527-
_Preconditions (2-4):_ Each source language defines its own requirements for
528-
the registered kernel names.
526+
_Preconditions (2-4):_ Each source language defines its own requirements for the
527+
registered names.
529528
For the language `source_language::sycl`, each name must be a {cpp} expression
530529
for a pointer to a kernel function as defined below under "Obtaining a kernel
531530
when the language is ``sycl``".
532531

533-
[_Note:_ It is not an error to have duplicate names in a
534-
`registered_kernel_names` property, but the duplicates have no effect.
532+
[_Note:_ It is not an error to have duplicate names in a `registered_names`
533+
property, but the duplicates have no effect.
535534
_{endnote}_]
536535
|====
537536

@@ -643,8 +642,8 @@ _Constraints:_ This function is not available when `State` is
643642

644643
_Returns:_ If the kernel bundle was created from a bundle of state
645644
`bundle_state::ext_oneapi_source` and `name` was registered via
646-
`registered_kernel_names`, returns the compiler-generated (e.g. mangled) name
647-
for this kernel function.
645+
`registered_names`, returns the compiler-generated (e.g. mangled) name for this
646+
kernel function.
648647
If the kernel bundle was created from a bundle of state
649648
`bundle_state::ext_oneapi_source` and `name` is the same as a
650649
compiler-generated name for a kernel defined in that bundle, that same
@@ -661,7 +660,7 @@ _Throws:_
661660
When the kernel is defined in the language `source_language::sycl`, the host
662661
code may query for the kernel or obtain the `kernel` object using either the
663662
kernel's name as it is generated by the compiler (i.e. the {cpp} mangled name)
664-
or by using the `registered_kernel_names` property.
663+
or by using the `registered_names` property.
665664

666665
==== Using the compiler-generated name
667666

@@ -691,11 +690,10 @@ sycl::kernel_bundle<sycl::bundle_state::executable> kb = /*...*/;
691690
sycl::kernel k = kb.ext_oneapi_get_kernel("foo");
692691
----
693692

694-
==== Using the `registered_kernel_names` property
693+
==== Using the `registered_names` property
695694

696695
When the kernel is not declared as `extern "C"`, the compiler generates a
697-
mangled name, so it is more convenient to use the `registered_kernel_names`
698-
property.
696+
mangled name, so it is more convenient to use the `registered_names` property.
699697
Each string in the property must be the {cpp} expression for a pointer to a
700698
kernel function.
701699
These expression strings are conceptually compiled at the bottom of source
@@ -724,7 +722,7 @@ The host code can compile this and get the kernel's `kernel` object like so:
724722
sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source> kb_src = /*...*/;
725723
726724
sycl::kernel_bundle<sycl::bundle_state::executable> kb = syclexp::build(kb_src,
727-
syclexp::properties{syclexp::registered_kernel_names{"mykernels::bar"}});
725+
syclexp::properties{syclexp::registered_names{"mykernels::bar"}});
728726
729727
sycl::kernel k = kb.ext_oneapi_get_kernel("mykernels::bar");
730728
----
@@ -744,21 +742,21 @@ the kernel by calling `ext_oneapi_get_raw_kernel_name` like this:
744742
sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source> kb_src = /*...*/;
745743
746744
sycl::kernel_bundle<sycl::bundle_state::executable> kb = syclexp::build(kb_src,
747-
syclexp::properties{syclexp::registered_kernel_names{"mykernels::bar"}});
745+
syclexp::properties{syclexp::registered_names{"mykernels::bar"}});
748746
749747
std::string mangled_name = kb.ext_oneapi_get_raw_kernel_name("mykernels::bar");
750748
----
751749

752750
Again, the string passed to `ext_oneapi_get_raw_kernel_name` must have exactly
753-
the same content as the string that was used to construct the
754-
`registered_kernel_names` property.
751+
the same content as the string that was used to construct the `registered_names`
752+
property.
755753
The application may also pass this compiler-generated (i.e. mangled) name to
756754
`ext_oneapi_get_kernel` in order to get the `kernel` object.
757755

758756
==== Instantiating templated kernel functions
759757

760-
The `registered_kernel_names` property can also be used to instantiate a
761-
kernel that is defined as a function template.
758+
The `registered_names` property can also be used to instantiate a kernel that is
759+
defined as a function template.
762760
For example, consider source code that defines a kernel function template like
763761
this:
764762

@@ -774,8 +772,8 @@ std::string source = R"""(
774772
)""";
775773
----
776774

777-
The application can use the `registered_kernel_names` property to instantiate
778-
the template for specific template arguments.
775+
The application can use the `registered_names` property to instantiate the
776+
template for specific template arguments.
779777
For example, this host code instantiates the template twice and gets a `kernel`
780778
object for each instantiation:
781779

@@ -784,7 +782,7 @@ object for each instantiation:
784782
sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source> kb_src = /*...*/;
785783
786784
sycl::kernel_bundle<sycl::bundle_state::executable> kb = syclexp::build(kb_src,
787-
syclexp::properties{syclexp::registered_kernel_names{{"bartmpl<float>", "bartmpl<int>"}});
785+
syclexp::properties{syclexp::registered_names{{"bartmpl<float>", "bartmpl<int>"}});
788786
789787
sycl::kernel k_float = kb.ext_oneapi_get_kernel("bartmpl<float>");
790788
sycl::kernel k_int = kb.ext_oneapi_get_kernel("bartmpl<int>");
@@ -830,7 +828,7 @@ int main() {
830828
syclexp::source_language::sycl,
831829
source);
832830
833-
// Compile the kernel. There is no need to use the "registered_kernel_names"
831+
// Compile the kernel. There is no need to use the "registered_names"
834832
// property because the kernel is declared extern "C".
835833
sycl::kernel_bundle<sycl::bundle_state::executable> kb_exe =
836834
syclexp::build(kb_src);
@@ -852,7 +850,7 @@ int main() {
852850

853851
=== Disambiguating overloaded kernel functions
854852

855-
This example demonstrates how to use the `registered_kernel_names` property to
853+
This example demonstrates how to use the `registered_names` property to
856854
disambiguate a kernel function that has several overloads.
857855

858856
[source,c++]
@@ -896,11 +894,11 @@ int main() {
896894
// use a C++ cast to disambiguate between them. Here, we are selecting the
897895
// "int" overload.
898896
std::string iota_name{"(void(*)(int, int*))iota"};
899-
sycl::kernel_bundle<sycl::bundle_state::executable> kb_exe = syclexp::build(kb_src,
900-
syclexp::properties{syclexp::registered_kernel_names{iota_name}});
897+
sycl::kernel_bundle<sycl::bundle_state::executable> kb_exe =
898+
syclexp::build(kb_src, syclexp::properties{syclexp::registered_names{iota_name}});
901899
902900
// Get the kernel by passing the same string we used to construct the
903-
// "registered_kernel_names" property.
901+
// "registered_names" property.
904902
sycl::kernel iota = kb_exe.ext_oneapi_get_kernel(iota_name);
905903
906904
int *ptr = sycl::malloc_shared<int>(NUM, q);
Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,2 @@
1-
= SYCL(TM) Proposals: Platform Default Contexts
2-
James Brodman <james[email protected]>
3-
v0.1
4-
:source-highlighter: pygments
5-
:icons: font
6-
:y: icon:check[role="green"]
7-
:n: icon:times[role="red"]
8-
9-
== Platform Default Contexts
10-
11-
This extension adds the notion of a default SYCL context per SYCL platform. The default context for each platform contains all devices in the platform.
12-
13-
The platform class gains one new method:
14-
15-
[cols="^60a,40"]
16-
|===
17-
| Member Function | Description
18-
19-
|
20-
[source,c++]
21-
----
22-
context ext_oneapi_get_default_context()
23-
----
24-
25-
| Returns the current default context for this `platform`
26-
27-
|===
28-
29-
This extension also modifies the behavior of `queue` constructors. Queues will no longer create a new `context` upon construction. Instead, they will use the default context from the device's platform.
30-
31-
== Feature Test Macro
32-
33-
This extension defines the macro `SYCL_EXT_ONEAPI_DEFAULT_CONTEXT` to `1` to indicate that it is enabled.
34-
1+
This extension has been deprecated, but the specification is still available
2+
link:../deprecated/sycl_ext_oneapi_default_context.asciidoc[here].

sycl/include/sycl/detail/generic_type_traits.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ template <typename T> auto convertToOpenCLType(T &&x) {
172172
} else if constexpr (std::is_same_v<no_ref, ext::oneapi::bfloat16>) {
173173
// On host, don't interpret BF16 as uint16.
174174
#ifdef __SYCL_DEVICE_ONLY__
175-
using OpenCLType = sycl::ext::oneapi::detail::Bfloat16StorageT;
175+
using OpenCLType = sycl::ext::oneapi::bfloat16::Bfloat16StorageT;
176176
return sycl::bit_cast<OpenCLType>(x);
177177
#else
178178
return std::forward<T>(x);

0 commit comments

Comments
 (0)