Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Add SYCL clang frontend doc #177

Merged
merged 3 commits into from
Jun 9, 2019
Merged

Conversation

Fznamznon
Copy link
Contributor

No description provided.

@Fznamznon Fznamznon requested a review from bader May 29, 2019 18:00
Copy link
Contributor

@keryell keryell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding some documentation.
Just a few typos.

@agozillon we need a native English speaker for the proofreading of the documentation.

sycl/doc/SYCL_compiler_and_runtime_design.md Outdated Show resolved Hide resolved
sycl/doc/SYCL_compiler_and_runtime_design.md Outdated Show resolved Hide resolved
sycl/doc/SYCL_compiler_and_runtime_design.md Outdated Show resolved Hide resolved
sycl/doc/SYCL_compiler_and_runtime_design.md Outdated Show resolved Hide resolved
sycl/doc/SYCL_compiler_and_runtime_design.md Outdated Show resolved Hide resolved
sycl/doc/SYCL_compiler_and_runtime_design.md Outdated Show resolved Hide resolved

All SYCL memory objects shared between host and device (buffers/images,
these objects map to OpenCL buffers and images) must be accessed through special
`accessor` classes. The "device" side implementation of these classes contain pointers to the device memory. There is no
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contains (+ end-of-line to split the too long line)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in the context of this sentence contain is correct grammar

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way in OpenCL -> As there is no way in OpenCL

I think this keeps the original intent of the sentence but flows better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote it with addition that in OpenCL all memory objects shared between host and device must be passed to the kernel as raw pointers.


// Kernel wrapper
__kernel wrapper(global int* a) {
lambda; // Actually lambda declaration doesn't have a name in AST
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this "lambda"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lambda it's unnamed function object declared by lambda expression passed to parallel_for. I added type and comment with clarification.


```C++
// SYCL kernel is defined in SYCL headers
__attribute__((sycl_kernel)) someSYCLKernel(lambda) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the meaning of this "lambda"? Where is the type?
Do you mean something like this:

template <typename Lambda>
 __attribute__((sycl_kernel)) someSYCLKernel(Lambda lambda) {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I added type.

device, if in OpenCL you need to call `clSetKernelArg`, in SYCL all
kernel arguments are captures/fields of lambda/functor which is passed to
`parallel_for` (in code snippet above one kernel argument - `accessor A`).
To map to OpenCL kernel arguments setting mechanism we added generation of
Copy link
Contributor

@agozillon agozillon May 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"To map to OpenCL kernel arguments setting mechanism we added generation of "kernel wrapper" function inside the compiler."

Sorry, I have a hard time understanding this sentence (perhaps that's just me though). Is it perhaps better worded to something like the following (without losing your original point):

"To facilitate the mapping of the captures/fields of lambdas/functors to OpenCL kernel arguments we added the generation of a "kernel wrapper" function inside the compiler."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually kernel wrapper not only "To facilitate the mapping of the captures/fields of lambdas/functors to OpenCL kernel arguments" but also to overcome OpenCL limitations about pointers inside structures, so I rewrote using your comment and little addition.

@agozillon
Copy link
Contributor

Overall well written and I can understand it, I did add some suggested rewording and corrections which you can ignore/use/or cherry pick parts from. I think in most cases it will aid people unfamiliar with the codebase or SYCL, so hopefully it's helpful suggestions rather than irritating or too pedantic! Thanks for the great work.

@Fznamznon
Copy link
Contributor Author

Overall well written and I can understand it, I did add some suggested rewording and corrections which you can ignore/use/or cherry pick parts from. I think in most cases it will aid people unfamiliar with the codebase or SYCL, so hopefully it's helpful suggestions rather than irritating or too pedantic! Thanks for the great work.

Thank you for your comments, It really helps make this document sound better, I appreciate it.

@agozillon
Copy link
Contributor

This looks fantastic, just added a few final very minor comments that you can change if you feel like it.

Fznamznon and others added 2 commits May 31, 2019 09:44
Signed-off-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
Signed-off-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>

Co-Authored-By: Sergey Semenov <sergey.semenov@intel.com>
Co-Authored-By: Alexey Bader <alexey.bader@intel.com>
bader
bader previously approved these changes May 31, 2019
@bader bader dismissed their stale review May 31, 2019 15:35

Let's see if buildbot checks will stop if I dismiss the review.

@agozillon
Copy link
Contributor

LGTM, thank you for the great documentation addition!

Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for the science. Reverted.

@MrSidims MrSidims self-requested a review June 3, 2019 08:38
sycl/doc/SYCL_compiler_and_runtime_design.md Outdated Show resolved Hide resolved
sycl/doc/SYCL_compiler_and_runtime_design.md Outdated Show resolved Hide resolved
sycl/doc/SYCL_compiler_and_runtime_design.md Outdated Show resolved Hide resolved
The SYCL runtime library can't mark foo as "device" code - this is a compiler
job: to traverse all symbols accessible from kernel functions and add them to
the "device part" of the code marking them with the new SYCL device attribute.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should clarify the requirements we put on the function, which SYCL runtime can mark with sycl_kernel attribute.
I can remember at least these off the top of my head:

  • Must be template function with at least two template parameters.
    • First parameter must represent "unique kernel name"
    • Second parameter must be the function object type
  • Must have only one function parameter.
    • Parameter type must be second template parameter
  template <typename KernelName, typename KernelType/*, ...*/>
  __attribute__((sycl_kernel)) void sycl_kernel_function(KernelType KernelFuncObj) {
    KernelFuncObj();
  }

Other requirements can be extracted from the SemaSYCL.cpp.
It's some informal API, which we should document somewhere.
Maybe it would be better to document in comments. What do you think?

Copy link
Contributor Author

@Fznamznon Fznamznon Jun 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add some documentation to comments and this document both. But IMO requirements for function marked with sycl_kernel attribute aren't related to the "device code oulining" feature but related to generation of kernel wrapper from this function. So I suggest adding it to the "SYCL kernel function object (functor or lambda) lowering" section.

sycl/doc/SYCL_compiler_and_runtime_design.md Outdated Show resolved Hide resolved
sycl/doc/SYCL_compiler_and_runtime_design.md Show resolved Hide resolved
Signed-off-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
@bader bader dismissed MrSidims’s stale review June 9, 2019 17:59

Please, provide more information on what exact changes do you request.

@bader bader merged commit 1614b8f into intel:sycl Jun 9, 2019
@bader bader added the upstream This change is related to upstreaming SYCL support to llorg. label Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream This change is related to upstreaming SYCL support to llorg.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants