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] Forbid declaration of static non-const variable inside kernel. #1133

Closed
wants to merge 1 commit into from

Conversation

fadeeval
Copy link
Contributor

Adding the error, that forbid declaration of static variable inside kernel, if the variable is not const.

Signed-off-by: Aleksander Fadeev aleksander.fadeev@intel.com

@@ -6945,6 +6945,14 @@ NamedDecl *Sema::ActOnVariableDeclarator(
NewVD->setTSCSpec(TSCS);
}

// Varification, that if a static variable has been declared, then it is
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Varification, that if a static variable has been declared, then it is
// Static variables declared inside SYCL device code must be const or constexpr

@@ -6945,6 +6945,14 @@ NamedDecl *Sema::ActOnVariableDeclarator(
NewVD->setTSCSpec(TSCS);
}

// Varification, that if a static variable has been declared, then it is
// constant
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// constant

// Varification, that if a static variable has been declared, then it is
// constant
if (getLangOpts().SYCLIsDevice && SCSpec == DeclSpec::SCS_static &&
!R.isConstant(Context)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
!R.isConstant(Context)) {
!R.isConstant(Context))

!R.isConstant(Context)) {
SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_sycl_restrict)
<< Sema::KernelNonConstStaticDataVariable;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}

@@ -35,7 +36,7 @@ __attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
int main() {
kernel_single_task<class kernel>([]() {
ret_char();
ret_arr();
ret_arr();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ret_arr();
ret_arr();

static int m;
}

template <typename name, typename Func>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
template <typename name, typename Func>
template <typename Name, typename Func>

@fadeeval fadeeval force-pushed the private/fadeeval/const-static_declaration branch 2 times, most recently from e25a4ac to 7db72a0 Compare February 17, 2020 08:23
…ernel, ifthe variable is not const.

Signed-off-by: Aleksander Fadeev <aleksander.fadeev@intel.com>
@fadeeval fadeeval force-pushed the private/fadeeval/const-static_declaration branch from 7db72a0 to 8b5af68 Compare February 17, 2020 08:25
@fadeeval fadeeval closed this Feb 18, 2020
@bader bader deleted the private/fadeeval/const-static_declaration branch February 18, 2020 17:36
vmaksimo pushed a commit to vmaksimo/llvm that referenced this pull request Sep 1, 2021
The BuiltIn variable/call name in SPV-IR should stick to
"__spirv_BuiltIn*", no matter what the SPIR-V linkage name is.

This is a regression of PR intel#1133.

Signed-off-by: Yilong Guo <yilong.guo@intel.com>

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@894f95b
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.

2 participants