You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class MyKernel; // Forward declaration of the name of the lambda functor cl::sycl::queue myQueue;
cl::sycl::program MyProgram(myQueue.get_context());
/* use the name of the kernel to obtain the associated program */
MyProgram.build_from_name<MyKernel>();
myQueue.submit([&](handler& commandGroup) { commandgroup.parallel_for<class MyKernel>(
cl::sycl::nd_range<2>(4, 4),
MyProgram.get_kernel<MyKernel>(), // execute the kernel as compiled in MyProgram
([=](cl::sycl::nd_item<2> index) {
//[kernel code]
})); });
Could anyone tell me what just happened about above code? What is the signature of the parallel_for?
parallel_for(range r, kernel k, MyKernel (lambda)), I'm I correct?
The text was updated successfully, but these errors were encountered:
Could anyone tell me what just happened about above code?
By default, when you submit some kernel into a queue, SYCL RT will automatically create a program object under the hood, build it and select a kernel corresponding to SYCL Kernel Function passed to parallel_for.
In some cases, you might want to adjust the program object used for kernel submission: for example you might want to build the program with different build options, or you might want to link your program with some other program.
There is a set of APIs that allows to do so: in addition to ordinary range and SYCL Kernel Function they also accept kernel object so you can control which exact program object is being used for this particular kernel.
What is the signature of the parallel_for? parallel_for(range r, kernel k, MyKernel (lambda)), I'm I correct?
Yes, this is correct. You can find other interfaces accepting kernel around here and below:
To me this seems like a bug in the spec, i.e. missing description of parallel_for(range r, kernel k, MyKernel (lambda)), method.
Also, build_from_name method doesn't exists :) It should be build_with_kernel_type
Personally, I think that this syntax looks a bit ugly and confusing. One more downside of it is that build_with_kernel_type guarantees that only one particular kernel will be included into a program. That means that if you have several kernels and would like to launch them using parallel_for(range r, kernel k, MyKernel (lambda)) API, in order to be sure you need to create and build separate program for each of them.
I got an example in SYCL spec.
Could anyone tell me what just happened about above code? What is the signature of the parallel_for?
parallel_for(range r, kernel k, MyKernel (lambda)), I'm I correct?
The text was updated successfully, but these errors were encountered: