Skip to content

Commit 5f85662

Browse files
committed
Use C++ source blocks
1 parent 1d5cf11 commit 5f85662

File tree

1 file changed

+46
-34
lines changed

1 file changed

+46
-34
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ supports.
109109
This extension adds the `ext_oneapi_source` enumerator to `sycl::bundle_state`
110110
to identify a kernel bundle that is represented as a source code string.
111111

112-
```
112+
[source,c++]
113+
----
113114
namespace sycl {
114115
115116
enum class bundle_state : /*unspecified*/ {
@@ -118,22 +119,23 @@ enum class bundle_state : /*unspecified*/ {
118119
};
119120
120121
} // namespace sycl
121-
```
122+
----
122123

123124
=== New enumerator of kernel source languages
124125

125126
This extension adds the `source_language` enumeration, which identifies
126127
possible languages for a kernel bundle that is in `ext_oneapi_source` state:
127128

128-
```
129+
[source,c++]
130+
----
129131
namespace sycl::ext::oneapi::experimental {
130132
131133
enum class source_language : /*unspecified*/ {
132134
sycl
133135
};
134136
135137
} // namespace sycl::ext::oneapi::experimental
136-
```
138+
----
137139

138140
The only enumerator defined by this extension is `sycl`, which indicates that
139141
the kernel is written in SYCL using the "free function kernel" syntax defined
@@ -151,7 +153,7 @@ a|
151153
[frame=all,grid=none]
152154
!====
153155
a!
154-
[source]
156+
[source,c++]
155157
----
156158
class device {
157159
@@ -175,7 +177,7 @@ a|
175177
[frame=all,grid=none]
176178
!====
177179
a!
178-
[source]
180+
[source,c++]
179181
----
180182
namespace sycl::ext::oneapi::experimental {
181183
@@ -246,7 +248,7 @@ a|
246248
[frame=all,grid=none]
247249
!====
248250
a!
249-
[source]
251+
[source,c++]
250252
----
251253
namespace sycl::ext::oneapi::experimental {
252254
@@ -322,7 +324,7 @@ a|
322324
[frame=all,grid=none]
323325
!====
324326
a!
325-
[source]
327+
[source,c++]
326328
----
327329
namespace sycl::ext::oneapi::experimental {
328330
@@ -396,7 +398,7 @@ a|
396398
[frame=all,grid=none]
397399
!====
398400
a!
399-
[source]
401+
[source,c++]
400402
----
401403
namespace sycl::ext::oneapi::experimental {
402404
@@ -438,7 +440,7 @@ a|
438440
[frame=all,grid=none]
439441
!====
440442
a!
441-
[source]
443+
[source,c++]
442444
----
443445
namespace sycl::ext::oneapi::experimental {
444446
@@ -480,7 +482,7 @@ a|
480482
[frame=all,grid=none]
481483
!====
482484
a!
483-
[source]
485+
[source,c++]
484486
----
485487
namespace sycl::ext::oneapi::experimental {
486488
@@ -570,7 +572,8 @@ of `kernel_id` objects if the kernel bundle was created from a bundle of state
570572

571573
This extensions adds the following new `kernel_bundle` member functions:
572574

573-
```
575+
[source,c++]
576+
----
574577
namespace sycl {
575578
576579
template <bundle_state State>
@@ -583,14 +586,14 @@ class kernel_bundle {
583586
};
584587
585588
} // namespace sycl
586-
```
589+
----
587590

588591
|====
589592
a|
590593
[frame=all,grid=none]
591594
!====
592595
a!
593-
[source]
596+
[source,c++]
594597
----
595598
bool ext_oneapi_has_kernel(const std::string &name)
596599
----
@@ -609,7 +612,7 @@ a|
609612
[frame=all,grid=none]
610613
!====
611614
a!
612-
[source]
615+
[source,c++]
613616
----
614617
kernel ext_oneapi_get_kernel(const std::string &name)
615618
----
@@ -630,7 +633,7 @@ a|
630633
[frame=all,grid=none]
631634
!====
632635
a!
633-
[source]
636+
[source,c++]
634637
----
635638
std::string ext_oneapi_get_raw_kernel_name(const std::string &name)
636639
----
@@ -669,7 +672,8 @@ Therefore, it is easy to query for the kernel by using the compiler-generated
669672
name.
670673
For example, if the kernel is defined like this in the source code string:
671674

672-
```
675+
[source,c++]
676+
----
673677
std::string source = R"""(
674678
#include <sycl/sycl.hpp>
675679
namespace syclex = sycl::ext::oneapi::experimental;
@@ -678,14 +682,15 @@ std::string source = R"""(
678682
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclex::range_kernel<1>))
679683
void foo(int *in, int *out) {/*...*/}
680684
)""";
681-
```
685+
----
682686

683687
Then the application's host code can query for the kernel like this:
684688

685-
```
689+
[source,c++]
690+
----
686691
sycl::kernel_bundle<sycl::bundle_state::executable> kb = /*...*/;
687692
sycl::kernel k = kb.ext_oneapi_get_kernel("foo");
688-
```
693+
----
689694

690695
==== Using the `registered_kernel_names` property
691696

@@ -698,7 +703,8 @@ These expression strings are conceptually compiled at the bottom of source
698703
code.
699704
To illustrate, consider source code that defines a kernel like this:
700705

701-
```
706+
[source,c++]
707+
----
702708
std::string source = R"""(
703709
#include <sycl/sycl.hpp>
704710
namespace syclex = sycl::ext::oneapi::experimental;
@@ -710,18 +716,19 @@ std::string source = R"""(
710716
711717
} // namespace mykernels
712718
)""";
713-
```
719+
----
714720

715721
The host code can compile this and get the kernel's `kernel` object like so:
716722

717-
```
723+
[source,c++]
724+
----
718725
sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source> kb_src = /*...*/;
719726
720727
sycl::kernel_bundle<sycl::bundle_state::executable> kb = syclex::build(kb_src,
721728
syclex::properties{syclex::registered_kernel_names{"mykernels::bar"}});
722729
723730
sycl::kernel k = kb.ext_oneapi_get_kernel("mykernels::bar");
724-
```
731+
----
725732

726733
The {cpp} expression `"mykernels::bar"` computes the address of the kernel
727734
function `bar`.
@@ -733,14 +740,15 @@ construct the property, without even any whitespace differences.
733740
The application can also obtain the compiler-generated (i.e. mangled) name for
734741
the kernel by calling `ext_oneapi_get_raw_kernel_name` like this:
735742

736-
```
743+
[source,c++]
744+
----
737745
sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source> kb_src = /*...*/;
738746
739747
sycl::kernel_bundle<sycl::bundle_state::executable> kb = syclex::build(kb_src,
740748
syclex::properties{syclex::registered_kernel_names{"mykernels::bar"}});
741749
742750
std::string mangled_name = kb.ext_oneapi_get_raw_kernel_name("mykernels::bar");
743-
```
751+
----
744752

745753
Again, the string passed to `ext_oneapi_get_raw_kernel_name` must have exactly
746754
the same content as the string that was used to construct the
@@ -755,7 +763,8 @@ kernel that is defined as a function template.
755763
For example, consider source code that defines a kernel function template like
756764
this:
757765

758-
```
766+
[source,c++]
767+
----
759768
std::string source = R"""(
760769
#include <sycl/sycl.hpp>
761770
namespace syclex = sycl::ext::oneapi::experimental;
@@ -764,22 +773,23 @@ std::string source = R"""(
764773
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclex::range_kernel<1>))
765774
void bartmpl(T *in, T *out) {/*...*/}
766775
)""";
767-
```
776+
----
768777

769778
The application can use the `registered_kernel_names` property to instantiate
770779
the template for specific template arguments.
771780
For example, this host code instantiates the template twice and gets a `kernel`
772781
object for each instantiation:
773782

774-
```
783+
[source,c++]
784+
----
775785
sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source> kb_src = /*...*/;
776786
777787
sycl::kernel_bundle<sycl::bundle_state::executable> kb = syclex::build(kb_src,
778788
syclex::properties{syclex::registered_kernel_names{{"bartmpl<float>", "bartmpl<int>"}});
779789
780790
sycl::kernel k_float = kb.ext_oneapi_get_kernel("bartmpl<float>");
781791
sycl::kernel k_int = kb.ext_oneapi_get_kernel("bartmpl<int>");
782-
```
792+
----
783793

784794

785795
== Examples
@@ -789,7 +799,8 @@ sycl::kernel k_int = kb.ext_oneapi_get_kernel("bartmpl<int>");
789799
The following example demonstrates how a SYCL application can define a kernel
790800
as a string and then compile and launch it.
791801

792-
```
802+
[source,c++]
803+
----
793804
#include <sycl/sycl.hpp>
794805
namespace syclex = sycl::ext::oneapi::experimental;
795806
static constexpr size_t NUM = 1024;
@@ -835,14 +846,15 @@ int main() {
835846
cgh.parallel_for({NUM}, iota);
836847
}).wait();
837848
}
838-
```
849+
----
839850

840851
=== Disambiguating overloaded kernel functions
841852

842853
This example demonstrates how to use the `registered_kernel_names` property to
843854
disambiguate a kernel function that has several overloads.
844855

845-
```
856+
[source,c++]
857+
----
846858
#include <sycl/sycl.hpp>
847859
namespace syclex = sycl::ext::oneapi::experimental;
848860
static constexpr size_t NUM = 1024;
@@ -896,7 +908,7 @@ int main() {
896908
cgh.parallel_for({NUM}, iota);
897909
}).wait();
898910
}
899-
```
911+
----
900912

901913

902914
== Issues

0 commit comments

Comments
 (0)