llvm
[SYCL][Doc] Add spec for "sycl" to kernel compiler
#11985
Merged

[SYCL][Doc] Add spec for "sycl" to kernel compiler #11985

gmlueck
gmlueck1 year ago👍 1

Update the proposed specification for the kernel compiler to allow
kernels to be written in the SYCL language, using the new proposed
"free function kernel" format.

This PR also adds some more features to the kernel compiler for
parity with cuda's nvrtc.

gmlueck [SYCL][Doc] Add spec for "sycl" to kernel compiler
77b3e865
gmlueck Add support for include files
94b08aec
gmlueck Add API to get mangled kernel name
bc84306b
gmlueck Add open issues
56864a88
gmlueck gmlueck requested a review 1 year ago
rolandschulz
rolandschulz commented on 2023-11-22
Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
189202`ctxt`.
190203
204When the source language is `source_language::sycl`, the `source` string must
205
not `#include <sycl/sycl.hpp>`.
rolandschulz1 year ago

Why? That means the string can't include a header which in turn includes sycl.hpp.

gmlueck1 year ago

That's a good point. We could relax this to say that the source string does not need to #include <sycl/sycl.hpp>, while still allowing it.

rolandschulz1 year ago

I think this would be better. But even saying that it isn't needed might have a disadvantage in the future. In the future we might want to split sycl.hpp into different parts to improve compilation speed. And then online compile wouldn't benefit from it because we would need to include all of the device side API to be backward compatible. I'm not sure the convenience of not having to include sycl.hpp is worth this potential downside in the future. It might be best only to say that sycl.hpp is automatically included in include_files so that the user doesn't have to do that part.

Pennycook1 year ago

I think the user's source string should explicitly include #include <sycl/sycl.hpp>. I agree with @rolandschulz that we may want to change the headers in future, and it would be nice to have this flexibility.

I also think that it's weird to make an exception for the SYCL headers, because users may need to include other C++ headers (e.g., #include <cmath>) if they're making use of any std:: functionality inside of their kernels.

I think we should replace this with a note to the effect that the compiler behaves as-if the location of the SYCL headers and standard C++ headers are included in include_files. Do we also need to add something saying that these headers are guaranteed to be the same as those used when the host program was compiled? (Can we actually guarantee that?)

gmlueck1 year ago👍 1

OK, I agree that this makes sense. Changed in d49df13.

gmlueck Change behavior for <sycl/sycl.hpp>
d49df130
keryell
keryell commented on 2023-11-29
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
6365source code for a kernel, which it can then compile and enqueue to a device.
64The APIs allow a kernel to be written in any of several possible languages,
65where support for each of these languages is defined by a separate extension.
66As a result, this extension provides a framework of APIs for online compilation
67of kernels, but it does not define the details for any specific kernel language.
68These details are provided by other extensions.
66This extension provides support for kernels written in SYCL according to the
67"free function kernel" syntax defined in
68
link:../proposed/sycl_ext_oneapi_free_function_kernels.asciidoc[
keryell1 year ago

Is this available somewhere?

gmlueck1 year ago

No, it's not implemented yet. I expect that we will implement that extension at the same time as the new additions to "sycl_ext_oneapi_kernel_compiler" that are described in this PR.

DongBaiYue
DongBaiYue1 year ago

Runtime compilation is an urgently needed feature of SYCL in project development. Thanks for your specification. Also out of curiosity, may the kernel compiler support using inline PTX assembly in SYCL kernel? opencl example. Inline Assembly makes rich low-level hardware features available to programmers.

gmlueck Merge branch 'sycl' into gmlueck/kernel-compiler-sycl
44b2c6fc
Pennycook
Pennycook approved these changes on 2023-12-19
gmlueck Merge branch 'sycl' into gmlueck/kernel-compiler-sycl
4b10b33b
gmlueck Add statement that "sycl" language is text format
7424d2f3
gmlueck Fix merge mistake
21580c60
gmlueck
gmlueck1 year ago (edited 1 year ago)

Runtime compilation is an urgently needed feature of SYCL in project development. Thanks for your specification. Also out of curiosity, may the kernel compiler support using inline PTX assembly in SYCL kernel? opencl example. Inline Assembly makes rich low-level hardware features available to programmers.

Hi @DongBaiYue, I think this is not strongly related to this extension. Runtime compilation should work for kernels that use any of the SYCL features that available in normal kernels. I'm not sure if normal SYCL kernels can contain PTX assembly, but @AerialMantis might know.

gmlueck Add include of <sycl/sycl.hpp> to examples
b98714e5
gmlueck Use properties instead of macros
1b6f57ec
gmlueck
gmlueck1 year ago (edited 1 year ago)

Attention reviewers: I do not plan any more changes to this PR. If you have more comments, please make them soon.

Pennycook
Pennycook approved these changes on 2024-01-10
Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
200202`create_kernel_bundle_from_source` function".
201203
202_Effects:_ Creates a new kernel bundle that represents a kernel that is defined
203by the source code string `source` using the language `lang`.
204_Preconditions:_ There are two overloads of this function: one that reads the
205
source code of the kernel from an `std::string`, and one that reads the source
Pennycook1 year ago😄 1

No changes required here, but an observation: "an std::string" reads better for people who say "an S-T-D string", while "a std::string" reads better for people who say "a stood string". We should give some thought to what style we (and the SYCL specification) want to use. Saying "an object of type std::string" would sidestep it.

gmlueck1 year ago👍 1

It appears that the consensus is to use "a std ..." (not "an std ..."), so I guess people have decided that the pronunciation is "stood" and not "s-t-d".

The C++ spec has 53 occurrences of "a std" and no occurrences of "an std".
The cppreference site has over 1300 occurrences of "a std" and only 71 occurrences of "an std".

I'll start using "a".

gmlueck1 year ago👍 1

These occurrences fixed in #12374. Another occurrence fixed in this PR at 019977c.

gmlueck gmlueck marked this pull request as draft 1 year ago
gmlueck
gmlueck1 year ago

Marking this PR as "draft" only to prevent it from being merged until after these new APIs have been implemented.

This is a new process I'm trying out for cases where we make proposed changes to an extension specification that is already implemented. When these new changes are implemented, we can merge this PR. That way, the extension specification in the repo will always reflect what is currently implemented.

gmlueck Use "a std::" instead of "an std::"
019977c4
cperkinsintel
cperkinsintel commented on 2024-01-16
Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
649 namespace syclex = sycl::ext::oneapi::experimental;
650
651 extern "C"
652
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclex::range_kernel<1>))
cperkinsintel1 year ago

In this design, foo doesn't accept sycl::id<> or sycl::item<> as a parameter, but instead is expected to use the free functions ( for example: sycl::ext::oneapi::experimental::this_id<1>(); ) to get the "index".

So, AFAICT at my initial stage of exploring this, if that's true, then there is no need for any argument for SYCL_EXT_ONEAPI_FUNCTION_PROPERTY. If it were just SYCL_EXT_ONEAPI_KERNEL_FUNCTION that might be enough to designate the following function as something that needs to be wrapped in a kernel call.

gmlueck1 year ago

We actually had a long debate about this. We'd prefer to use the common syntax of compile-time properties, rather than inventing new macros. The macro SYCL_EXT_ONEAPI_FUNCTION_PROPERTY is part of the common syntax for compile-time properties.

FWIW, see 1b6f57e for the way it looked before we decided to use SYCL_EXT_ONEAPI_FUNCTION_PROPERTY.

cperkinsintel
cperkinsintel commented on 2024-01-16
Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
858
859 // Get the kernel by passing the same string we used to construct the
860 // "registered_kernel_names" property.
861
sycl::kernel iota = kb_exe.ext_oneapi_get_kernel(iota_name);
cperkinsintel1 year ago

I was thinking of something like
sycl::kernel iota = kb_exe.ext_oneapi_get_kernel( syclex::get_spirv_kernel_name("iota") );

Where get_spirv_kernel_name would return the mangled kernel name that matches. Of course, this doesn't handle different overloads of iota. A simple solution like that might work, with a fallback to something like iota_name"(void(*)(int*, int*))iota"}; when using overloads. Otherwise, it seems like we are needlessly complicating it for everyone who doesn't use overloads.

cperkinsintel
cperkinsintel commented on 2024-01-16
Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
776 #include <sycl/sycl.hpp>
777 namespace syclex = sycl::ext::oneapi::experimental;
778
779
extern "C"
cperkinsintel1 year ago (edited 1 year ago)

I was having trouble getting this extern "C" approach to work, mostly because we employ a lot of templates in the headers right now and I was trying to minimize the disruption. A demangling helper like syclex::get_kernel_spirv_name("iota") is a straightforward way of avoiding the problem.

gmlueck1 year ago👍 1

I don't understand your comment about extern "C". Why does it matter that we use a lot of templating in our headers? How does this affect the user's ability to declare a function extern "C"?

Regarding, get_kernel_spirv_name("iota"), see the proposed function ext_oneapi_get_raw_kernel_name which provides similar functionality.

cperkinsintel
cperkinsintel commented on 2024-01-19
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
329 include_files(const std::string &name, const std::string &content); (1)
330 include_files(const std::vector<std::string> &names, (2)
331 const std::vector<std::string> &contents);
332
};
cperkinsintel1 year ago

I have some reservations about this include_files struct.

We know for the first implementation that we are likely going to have to write out a temporary .cpp file and invoke clang++ -fsycl on it. So now we have to also write out the include files? What about #include "path/to/file.h" ? Will we then be parsing this and instantiating directories?

I presume we need to disambiguate #include "local/path.h" from #include <system/path.h> ?

Users can't link in libraries ( even if has a header ), and there is only the one TU. Supporting #include suggests the opposite. Maybe a note proscribing it is needed?

I do see the value in that if a user has a simple function that they want to both use in the host application and call from their kernel, this allows them to do so. And, if clang were to ever have an invocation API (like ocloc) then I guess this aligns with that.

gmlueck1 year ago

One of the reasons we added the include_files property is for parity with CUDA, which has a similar feature in NVRTC. By adding the feature to SYCL, we make it easier to migrate code automatically using the SYCLomatic tool.

I was thinking that our implementation could create a temporary "include" directory and then write out the include_files header files into that directory. When we invoke clang, we can add a -I switch pointing at the temporary include directory.

Note that you don't need to parse any #include strings from the source code to get the file name paths. The include_files properties contains a list of (Name, Content) pairs. Each Name is the relative pathname of an include file, so you can just use this Name string verbatim.

cperkinsintel
cperkinsintel approved these changes on 2024-01-19
victor-eds
victor-eds commented on 2024-02-16
Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
201other than those listed below in the section "New properties for the
202`create_kernel_bundle_from_source` function".
203
189204
_Preconditions:_ There are two overloads of this function: one that reads the
190205
source code of the kernel from an `std::string`, and one that reads the source
191206
code of the kernel from an `std::vector` of `std::byte`.
192207
Each source language `lang` specifies whether the language is text format or
193208
binary format, and the application must use the overload that corresponds to
194209
that format.
victor-eds1 year ago

Is this a Precondition, i.e., does using an invalid source language and format result in undefined behavior? Maybe we should move this under Throws instead?

victor-eds1 year ago
This function succeeds even if some devices in `ctxt` do not support the source
language `lang`.
However, the `build` function fails unless _all_ of its devices support `lang`.
Therefore, applications should take care to omit devices that do not support
`lang` when calling `build`.

Should we maybe introduce an aspect to check a device supports a given source language?

gmlueck1 year ago👍 1

Is this a Precondition, i.e., does using an invalid source language and format result in undefined behavior? Maybe we should move this under Throws instead?

Good idea. I added a Throws section in ce3bbbe.

Should we maybe introduce an aspect to check a device supports a given source language?

We don't need an aspect because device::ext_oneapi_can_compile provides this query.

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
347The _Name_ is the name of an include file and the _Content_ is the content of
348that include file.
349
350
When the source language is `source_language::sycl`, the source code can have
351
`#include` statements where the name and content of the include file is
352
defined by this property.
victor-eds1 year ago

I can see instances of "this property is only valid for X source language" in the future. This makes me think whether we want the source language as an argument or as a template argument... Having it as a template argument will enable constructs like:

  • Further restricting properties being passed at compile-time
  • Restricting input format (text or binary) at compile time

I might be missing something, but, what does having the source language as a runtime variable bring to the table? Can we just have users use some kind of dispatching to call create_kernel_bundle_from_source<lang> instead and improve compile-time checks?

gmlueck1 year ago👍 1

I agree that making it a template argument would allow compile-time error checking here. However, I think it is valuable to allow applications to pass lang as a runtime value, and I don't want to require them to code a dispatch table in this case. Therefore, I'm more inclined to diagnose a runtime error if a source language does not support one of the properties.

victor-eds1 year ago (edited 1 year ago)

Okey, sounds good to me. Now, should we add a Throws clause to create_kernel_bundle_from_source in case lang does not support any of the input properties or just state unsupported properties will be omitted?

gmlueck1 year ago

Yup, I just ran out of time yesterday. Done now in 1c3f01b.

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
362content via the `include_files` property:
363
364* `<sycl/sycl.hpp>`;
365
* The {cpp} standard library headers;
victor-eds1 year ago

Does this require sycl-post-link?

gmlueck1 year ago

I don't think I understand. Why would this involve sycl-post-link?

victor-eds1 year ago

My reading from this is that the runtime will query a property set by sycl-post-link to check what SPIR-V fallback libraries are needed. Are you planning on reusing this functionality, reimplement it or is it not needed?

gmlueck1 year ago

I expect the first implementation to be very simplistic. The SYCL runtime will simply write the input string to a temporary file and spawn clang++ -fsycl as a separate process. This will end up spawning sycl-post-link as a subprocess along with all of the other tools that the compiler driver invokes.

I guess the answer to your original question is "yes", we will use sycl-post-link.

victor-eds1 year ago

Perfect. Thanks!

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
374_Effects (1):_ Constructs an `include_files` property with a single (_Name_,
375_Content_) pair.
376
377
_Effects (2):_ Constructs an `include_files` property with a collection of
378
(_Name_, _Content_) pairs.
379
The `names` vector provides the _Name_ strings, and the `contents` vector
380
provides the _Content_ strings.
381
|====
victor-eds1 year ago

Should we add a Throws to handle the case in which input lists have a different size?

Even better IMO. Change this property so that it receives a vector of include structs with name and contents instead of two separate name and content.

victor-eds1 year ago

Should we Constraint a list may only have a single instance of these include property? (or document here how they are to be combined)

victor-eds1 year ago

Should we Throw if a name is duplicate?

gmlueck1 year ago

Good suggestions. See 1d5cf11.

victor-eds1 year ago

I think we are still missing what to do if more than one include property is passed. I am not familiar enough with the compile-time property list extension to know whether that's even allowed, tho. Rest of changes LGTM.

gmlueck1 year ago👍 1

I think we are still missing what to do if more than one include property is passed.

This is a fundamental restriction on the PropertyListT. The sycl_ext_oneapi_properties extension does not allow a property list to contain more than one instance of any single property (even if the property values are different).

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
323----
324namespace sycl::ext::oneapi::experimental {
325
326
struct include_files {
victor-eds1 year ago

I assume a missing include is a compilation error and will be reported by build(?)

gmlueck1 year ago

Yes. I don't think we need to call this out specifically. Attempting to #include a non-existent file is just one of many possible compilation errors.

victor-eds1 year ago

Perfect. Totally agree 👍

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
504_Effects (1):_ Constructs a `registered_kernel_names` property with a single
505kernel name.
506
507
_Effects (2):_ Constructs a `registered_kernel_names` property from a vector of
victor-eds1 year ago

Can we add a Precondition saying the kernel name is a valid qualified identifier? "", "int", "777_invalid_id" might be problematic, so I'd at least say that's UB.

gmlueck1 year ago

Yes. See bb1e69f.

victor-eds1 year ago

Great. Thanks!

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
612
613_Constraints:_ This function is not available when `State` is
614`bundle_state::ext_oneapi_source`.
615
victor-eds1 year ago

Should we have a Precondition saying the kernel is a valid C++ qualified identifier?

gmlueck1 year ago

I think this is handled by the Throws section below. Or maybe I don't understand your concern?

victor-eds1 year ago

Yes, it is indeed covered. I was just thinking of a corner implementation case in which the queried name is not a valid identifier and that may cause issues, but, again, that should be handled by the implementation. My bad. LGTM.

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
468632
469== Example
633When the kernel is defined in the language `source_language::sycl`, the host
634code may query for the kernel or obtain the `kernel` object using either the
635
kernel's name as it is generated by the compiler (i.e. the C++ mangled name) or
victor-eds1 year ago

"Pro tip": Using C++ in asciidoc might be problematic, as ++ are escape characters (everything between ++ and ++ won't be formatted). Add the following to the beginning of the file and use {cpp} instead of C++ to avoid surprises in the future:

:cpp: pass:[C++]

I ran into some instances of C++ rendering as C and it can be annoying...

gmlueck1 year ago

Yes. Done in 002d47b.

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
816This example demonstrates how to use the `registered_kernel_names` property to
817disambiguate a kernel function that has several overloads.
818
819
```
victor-eds1 year ago

Should we format as C++ all the code listings in the proposal?

gmlueck1 year ago

Also yes. Done in 5f85662.

gmlueck Merge branch 'sycl' into gmlueck/kernel-compiler-sycl
ab91afea
gmlueck Language format is not precondition
ce3bbbed
gmlueck Use macro for C++ / DPC++
002d47be
gmlueck Add precondition to registered_kernel_names
bb1e69f7
gmlueck Tweak properties
1d5cf11c
gmlueck Use C++ source blocks
5f856625
gmlueck Clarify behavior of unsupported properties
1c3f01b3
gmlueck Remove trailing whitespace
d3e5f494
victor-eds
victor-eds commented on 2024-02-29
victor-eds1 year ago

Just some minor questions to make sure the extension is robust. Looking really good already

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
186199----
187200!====
188201
189_Preconditions:_ There are two overloads of this function: one that reads the
190source code of the kernel from a `std::string`, and one that reads the source
191code of the kernel from a `std::vector` of `std::byte`.
192Each source language `lang` specifies whether the language is text format or
193binary format, and the application must use the overload that corresponds to
194that format.
202
_Constraints:_ Available only when `PropertyListT` is an instance of
203
`sycl::ext::oneapi::experimental::properties` which contains no properties
204
other than those listed below in the section "New properties for the
205
`create_kernel_bundle_from_source` function".
victor-eds1 year ago

Question: What are the chances extensions to this extension define their own properties? If there is a chance, this constraint may not age well.

gmlueck1 year ago

We don't make extensions to extensions. Instead, we would make a revision to this extension, which adds a new property. In that case, the wording would still be correct.

victor-eds1 year ago

Excellent. Thanks!

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
202213The bundle's set of associated devices is the set of devices contained in
203214`ctxt`.
204215
216
Each source language `lang` specifies whether the language is text format or
217
binary format, and the application must use the overload that corresponds to
218
that format.
219
Applications must use overload (1) when the source language is text format and
220
must use overload (2) when the source language is binary format.
221
The `sycl` language is text format, so application must use overload (1) when
222
when creating a kernel bundle from this language.
victor-eds1 year ago

Question: Could a source language allow both kinds of input in the future?

gmlueck1 year ago

I don't think that is likely. If it does happen, we can revise this extension in a way that remains backward compatible.

victor-eds1 year ago

Excellent. Thanks, Greg!

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
235* Overload (2) throws an `exception` with the `errc::invalid` error code if the
236 source language `lang` is text format.
212237
213238
[_Note:_ Calling this function does not attempt to compile the source code.
214239
As a result, syntactic errors in the source code string are not diagnosed by
victor-eds1 year ago

Not added in this PR, but I'd still drop "string" as the source code might be in different formats.

gmlueck1 year ago👍 1

Makes sense. See d40c117.

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
246271
247272_Constraints:_ Available only when `PropertyListT` is an instance of
248273`sycl::ext::oneapi::experimental::properties` which contains no properties
249other than those listed below in the section "New properties".
274
other than those listed below in the section "New properties for the `build`
275
function".
victor-eds1 year ago

Same: Could extensions add new properties or are all properties gonna be listed here?

gmlueck1 year ago

Same answer as above.

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
367476In general, the log information is intended for human consumption, and the
368477format may not be stable across implementations of this extension.
369478
370479
_Effects (1):_ Constructs a `save_log` property with a pointer to a `std::string`.
victor-eds1 year ago (edited 1 year ago)

NIT: Should we Precondition to is not null and outlives the build call?

gmlueck1 year ago

Yes, this could be tightened. See cd36574.

victor-eds1 year ago

Perfect. Thanks!

victor-eds1 year ago

Just one question: why would we want to allow a nullptr being passed there? Wouldn't that make save_log a NOOP? Maybe passing std::string & makes more sense.

gmlueck1 year ago

I was thinking that it might be useful to allow code like this:

auto props = properties{
  //...
  save_log{(enable_log) ? &log : nullptr},
  //...
};
victor-eds1 year ago

Perfect. Oversaw that. Resolving this now 👍

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
465659 `ext_oneapi_has_kernel(name)` returns `false`.
466660|====
467661
662
=== Obtaining a kernel when the language is `sycl`
victor-eds1 year ago

I am wondering what would be the behavior in case the user query were ambiguous, e.g.:

void foo(int);
void foo(float);

Now, querying for "foo" would be ambiguous, as both void foo(int) and void foo(float) apply. Do we need to document this case?

gmlueck1 year ago👍 1

We use normal C++ rules to disambiguate the two overloads. The formal requirement is that the string passed to registered_kernel_names is an expression for a function pointer. The way to do this in C++ when there are different overloads of the function is to use a cast. This is illustrated in the examples section "Disambiguating overloaded kernel functions" below.

Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
782For example, this host code instantiates the template twice and gets a `kernel`
783object for each instantiation:
784
785
[source,c++]
786
----
787
sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source> kb_src = /*...*/;
788
789
sycl::kernel_bundle<sycl::bundle_state::executable> kb = syclex::build(kb_src,
790
syclex::properties{syclex::registered_kernel_names{{"bartmpl<float>", "bartmpl<int>"}});
791
792
sycl::kernel k_float = kb.ext_oneapi_get_kernel("bartmpl<float>");
793
sycl::kernel k_int = kb.ext_oneapi_get_kernel("bartmpl<int>");
794
----
victor-eds1 year ago

This is really cool. However, what if the user does not instantiate the template? What if they just query the name and try to use it? Would the following code be an error?

sycl::kernel_bundle<sycl::bundle_state::executable> kb = syclex::build(kb_src,
  syclex::properties{syclex::registered_kernel_names{{"bartmpl"}});

sycl::kernel k = kb.ext_oneapi_get_kernel("bartmpl");
gmlueck1 year ago

The section "Using the registered_kernel_names property" says:

Each string in the property must be the C++ expression for a pointer to a kernel function.

Your example violates this requirement, so I think the behavior is undefined. The string "bartmpl" is the name of a function template; it is not a valid expression for a pointer to a function.

I suspect our implementation will fail in the build call because it will try to compile "bartmpl" in a context where a function pointer is expected.

victor-eds1 year ago

Okey, perfect. Thanks, Greg!

gmlueck Tweak wording about syntax errors
d40c1174
gmlueck Tighten description of "save_log"
cd365745
gmlueck
gmlueck commented on 2024-02-29
gmlueck1 year ago

Thanks for the careful review! See responses below.

victor-eds
victor-eds approved these changes on 2024-02-29
victor-eds1 year ago

Current text looks good to me 👍

gmlueck Change "range_kernel" to "nd_range_kernel"
13581a3a
maarquitos14
maarquitos14 commented on 2024-06-28
Conversation is marked as resolved
Show resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
219Applications must use overload (1) when the source language is text format and
220must use overload (2) when the source language is binary format.
221The `sycl` language is text format, so application must use overload (1) when
222
when creating a kernel bundle from this language.
maarquitos14324 days ago
Suggested change
when creating a kernel bundle from this language.
when creating a kernel bundle from this language.

Double when here, as it is already present at the end of the previous line.

gmlueck324 days ago

Thanks. Fixed in e69a5dd.

gmlueck Remove doubled word
e69a5dda
gmlueck Clarify "include_files"
a6d87583
github-actions
github-actions133 days ago

This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days.

github-actions github-actions added Stale
gmlueck gmlueck removed Stale
gmlueck Merge branch 'sycl' into gmlueck/kernel-compiler-sycl
22c0db38
sommerlukas sommerlukas marked this pull request as ready for review 79 days ago
sommerlukas
sommerlukas79 days ago

Merging this extension, as the core functionality is implemented now that #17032 has been merged.

Smaller tweaks to API naming and implementation-specific notes will be added through follow-up PRs.

sommerlukas sommerlukas merged c2c029e9 into sycl 79 days ago

Login to write a write a comment.

Login via GitHub

Assignees
No one assigned
Labels
Milestone