Skip to content

[SYCL] Diagnose non-forward declarable kernel name types #4945

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

Merged
merged 5 commits into from
Nov 22, 2021

Conversation

Fznamznon
Copy link
Contributor

Add additional error emission in host mode
because only on host with help of integration header possible to
differentiate case like this:

int main() {
  parallel_for<class KernelName>(..);
}

which uses technically non-forward declarable kernel name type but
still allowed by SYCL spec, from case like this:

int main() {
  class KernelName;
  parallel_for<class KernelName>(..);
}

which should be diagnosed, since the errors are emitted in runtime.

Everything works when KernelName typename is used directly in
parallel_for, because in this case when the type KernelName is
forward declared by integration header, host uses ::KernelName
typename to access kernel info.
However when KernelName is forward declared in non-global/namespace
scope it actually produces a separate delclaration main::KernelName
which is not visible for runtime code that submits kernels.

Add additional error emission in host mode
because only on host with help of integration header possible to
differentiate case like this:
```
int main() {
  parallel_for<class KernelName>(..);
}
```
which uses technically non-forward declarable kernel name type but
still allowed by SYCL spec, from case like this:
```
int main() {
  class KernelName;
  parallel_for<class KernelName>(..);
}
```
which should be diagnosed, since the errors are emitted in runtime.

Everything works when `KernelName` typename is used directly in
`parallel_for`, because in this case when the type `KernelName` is
forward declared by integration header, host uses `::KernelName`
typename to access kernel info.
However when `KernelName` is forward declared in non-global/namespace
scope it actually produces a separate delclaration `main::KernelName`
which is not visible for runtime code that submits kernels.
@Fznamznon Fznamznon marked this pull request as ready for review November 15, 2021 10:16
smanna12
smanna12 previously approved these changes Nov 15, 2021
Copy link
Contributor

@smanna12 smanna12 left a comment

Choose a reason for hiding this comment

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

FE changes look good to me.

Copy link
Contributor

@elizabethandrews elizabethandrews left a comment

Choose a reason for hiding this comment

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

I haven't had a chance to review your tests yet. I will later today. Sorry for the delay.

Copy link
Contributor

@elizabethandrews elizabethandrews left a comment

Choose a reason for hiding this comment

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

Changes LGTM

@Fznamznon
Copy link
Contributor Author

It has been approved for 5 days. Is there anything else required to merge this patch?

@dm-vodopyanov dm-vodopyanov merged commit 653bae9 into intel:sycl Nov 22, 2021
Fznamznon added a commit to Fznamznon/llvm that referenced this pull request Nov 29, 2021
intel#4945 introduced a new diagnostic that
works correcly only if integration header is included. However it is
possible that `-fsycl-is-host` flag can be used without integration
header, so the diagnostic should be issued only if integration header is
incuded. This patch adds new cc1 option that helps to understand that.
// }
// The device compiler forward declares both KernelName1 and
// KernelName2 in the integration header as ::KernelName1 and
// ::KernelName2. The problem with the former case is the additional
Copy link
Contributor

Choose a reason for hiding this comment

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

So note that this (the ::KernelName1 and ::KernelName2) isn't exactly true, if the function is in a namespace, we try our best to get the name in as close of a namespace as possible (though your example uses 'main', so thats not exactly a concern).

bader pushed a commit that referenced this pull request Dec 2, 2021
…er (#5044)

#4945 introduced a new diagnostic that
works correctly only if integration header is included. However it is
possible that `-fsycl-is-host` flag can be used without integration
header, so the diagnostic should be issued only if integration header is
included. This patch adds new cc1 option that helps to understand that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants