485
485
----
486
486
namespace sycl::ext::oneapi::experimental {
487
487
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)
493
493
};
494
- using registered_kernel_names_key = registered_kernel_names ;
494
+ using registered_names_key = registered_names ;
495
495
496
496
template<>
497
- struct is_property_key<registered_kernel_names_key > : std::true_type {};
497
+ struct is_property_key<registered_names_key > : std::true_type {};
498
498
499
499
} // namespace sycl::ext::oneapi::experimental
500
500
----
501
501
!====
502
502
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 .
507
507
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.
510
510
The application can then get the corresponding raw (i.e. mangled) names after
511
511
the code is compiled.
512
512
See the section below "Obtaining a kernel when the language is ``sycl``" for a
513
513
description of how this property is used with the `source_language::sycl`
514
514
language.
515
515
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.
518
518
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.
521
521
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.
524
523
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.
526
525
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.
529
528
For the language `source_language::sycl`, each name must be a {cpp} expression
530
529
for a pointer to a kernel function as defined below under "Obtaining a kernel
531
530
when the language is ``sycl``".
532
531
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.
535
534
_{endnote}_]
536
535
|====
537
536
@@ -643,8 +642,8 @@ _Constraints:_ This function is not available when `State` is
643
642
644
643
_Returns:_ If the kernel bundle was created from a bundle of state
645
644
`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.
648
647
If the kernel bundle was created from a bundle of state
649
648
`bundle_state::ext_oneapi_source` and `name` is the same as a
650
649
compiler-generated name for a kernel defined in that bundle, that same
@@ -661,7 +660,7 @@ _Throws:_
661
660
When the kernel is defined in the language `source_language::sycl`, the host
662
661
code may query for the kernel or obtain the `kernel` object using either the
663
662
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.
665
664
666
665
==== Using the compiler-generated name
667
666
@@ -691,11 +690,10 @@ sycl::kernel_bundle<sycl::bundle_state::executable> kb = /*...*/;
691
690
sycl::kernel k = kb.ext_oneapi_get_kernel("foo");
692
691
----
693
692
694
- ==== Using the `registered_kernel_names ` property
693
+ ==== Using the `registered_names ` property
695
694
696
695
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.
699
697
Each string in the property must be the {cpp} expression for a pointer to a
700
698
kernel function.
701
699
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:
724
722
sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source> kb_src = /*...*/;
725
723
726
724
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"}});
728
726
729
727
sycl::kernel k = kb.ext_oneapi_get_kernel("mykernels::bar");
730
728
----
@@ -744,21 +742,21 @@ the kernel by calling `ext_oneapi_get_raw_kernel_name` like this:
744
742
sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source> kb_src = /*...*/;
745
743
746
744
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"}});
748
746
749
747
std::string mangled_name = kb.ext_oneapi_get_raw_kernel_name("mykernels::bar");
750
748
----
751
749
752
750
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.
755
753
The application may also pass this compiler-generated (i.e. mangled) name to
756
754
`ext_oneapi_get_kernel` in order to get the `kernel` object.
757
755
758
756
==== Instantiating templated kernel functions
759
757
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.
762
760
For example, consider source code that defines a kernel function template like
763
761
this:
764
762
@@ -774,8 +772,8 @@ std::string source = R"""(
774
772
)""";
775
773
----
776
774
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.
779
777
For example, this host code instantiates the template twice and gets a `kernel`
780
778
object for each instantiation:
781
779
@@ -784,7 +782,7 @@ object for each instantiation:
784
782
sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source> kb_src = /*...*/;
785
783
786
784
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>"}});
788
786
789
787
sycl::kernel k_float = kb.ext_oneapi_get_kernel("bartmpl<float>");
790
788
sycl::kernel k_int = kb.ext_oneapi_get_kernel("bartmpl<int>");
@@ -830,7 +828,7 @@ int main() {
830
828
syclexp::source_language::sycl,
831
829
source);
832
830
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 "
834
832
// property because the kernel is declared extern "C".
835
833
sycl::kernel_bundle<sycl::bundle_state::executable> kb_exe =
836
834
syclexp::build(kb_src);
@@ -852,7 +850,7 @@ int main() {
852
850
853
851
=== Disambiguating overloaded kernel functions
854
852
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
856
854
disambiguate a kernel function that has several overloads.
857
855
858
856
[source,c++]
@@ -896,11 +894,11 @@ int main() {
896
894
// use a C++ cast to disambiguate between them. Here, we are selecting the
897
895
// "int" overload.
898
896
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}});
901
899
902
900
// Get the kernel by passing the same string we used to construct the
903
- // "registered_kernel_names " property.
901
+ // "registered_names " property.
904
902
sycl::kernel iota = kb_exe.ext_oneapi_get_kernel(iota_name);
905
903
906
904
int *ptr = sycl::malloc_shared<int>(NUM, q);
0 commit comments