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] Propagate attributes of original kernel to wrapper kernel generated for range-rounding #3306

Merged
merged 4 commits into from
Mar 16, 2021

Conversation

rdeodhar
Copy link
Contributor

@rdeodhar rdeodhar commented Mar 4, 2021

This change propagates attributes of a user-written SYCL kernel to the kernel generated as a wrapper around the original kernel. The wrapped kernel is executed with the original range rounded-up, which improves work group formation on CPUs and GPUs.

Signed-off-by: rdeodhar rajiv.deodhar@intel.com

Signed-off-by: rdeodhar <rajiv.deodhar@intel.com>
bader
bader previously requested changes Mar 5, 2021
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

Please, cherry-pick 496f9a0 to this pull request to fix the checks.

…s when rounding up the range (intel#3154)

Parallel_for range rounding creates a wrapped version of the original kernel.
Kernel attributes need to be copied from original kernel to new wrapped kernel.

Signed-off-by: rdeodhar <rajiv.deodhar@intel.com>
@rdeodhar rdeodhar requested a review from a team as a code owner March 5, 2021 16:55
@rdeodhar rdeodhar requested a review from s-kanaev March 5, 2021 16:55
@elizabethandrews
Copy link
Contributor

@rdeodhar please fix the conflicts

Signed-off-by: rdeodhar <rajiv.deodhar@intel.com>
@elizabethandrews
Copy link
Contributor

@rdeodhar please update commit message and title to reflect the re-landing of this patch. Thanks!

@rdeodhar rdeodhar changed the title [SYCL] This test change accompanies PR 3154 [SYCL] Propagate attributes of original kernel to wrapper kernel generated for range-rounding Mar 8, 2021
@rdeodhar rdeodhar requested a review from bader March 8, 2021 22:46
@bader bader requested a review from AaronBallman March 9, 2021 07:03
@bader bader dismissed their stale review March 9, 2021 07:04

No objections from my side, I'd like @AaronBallman to take a look.

@@ -306,6 +306,36 @@ static int64_t getIntExprValue(const Expr *E, ASTContext &Ctx) {
return E->getIntegerConstantExpr(Ctx)->getSExtValue();
}

// Collect function attributes related to SYCL
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a period at the end of the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

clang/lib/Sema/SemaSYCL.cpp Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Show resolved Hide resolved
// For a wrapped parallel_for, copy attributes from original
// kernel to wrapped kernel.
void Sema::copySYCLKernelAttrs(const CXXRecordDecl *KernelObj) {
// Get the operator() function of the wrapper
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a period to the end of the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

@bader bader removed their request for review March 9, 2021 12:45
Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM

clang/lib/Sema/SemaSYCL.cpp Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Show resolved Hide resolved
@@ -0,0 +1,54 @@
// RUN: %clang_cc1 %s -fsyntax-only -ast-dump -fsycl -fsycl-is-device -triple spir64 | FileCheck %s
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know how we typically organize test, but in community, tests for -ast-dump typically live in the AST directory.

@@ -6,7 +6,7 @@
using namespace cl::sycl;
queue q;

[[intel::use_stall_enable_clusters]] void test() {} //expected-warning{{'use_stall_enable_clusters' attribute ignored}}
[[intel::use_stall_enable_clusters]] void test() {} // expected-warning{{'use_stall_enable_clusters' attribute allowed only on a function directly called from a SYCL kernel}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use the full attribute diagnostic here (it drops the attribute ignored part, which made me think the diagnostic text was a problem)?

@keryell
Copy link
Contributor

keryell commented Mar 9, 2021

At some point we need to consider replacing most of the fancy comfort attributes by just using the C++ type system, for example like http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2183r0.html

So instead of hacking the compiler for each magical class, it is mostly metaprogramming in the C++ run-time library.

@AaronBallman
Copy link
Contributor

At some point we need to consider replacing most of the fancy comfort attributes by just using the C++ type system, for example like http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2183r0.html

So instead of hacking the compiler for each magical class, it is mostly metaprogramming in the C++ run-time library.

Strong +1 (many of these attributes feel a bit suspect to me).

@bader bader requested a review from elizabethandrews March 10, 2021 16:29
Copy link
Contributor

@romanovvlad romanovvlad left a comment

Choose a reason for hiding this comment

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

sycl/test/kernel_param/attr.cpp LGTM

@romanovvlad romanovvlad merged commit 25b482b into intel:sycl Mar 16, 2021
alexbatashev pushed a commit to alexbatashev/llvm that referenced this pull request Mar 19, 2021
* upstream/sycl: (1804 commits)
  [SYCL] SYCL 2020 backend interoperability part 1 (intel#3354)
  [Driver][SYCL] Address issue when unbundling for non-FPGA archive (intel#3366)
  [SYCL][Doc] Update compiler options descriptions (intel#3340)
  [SYCL] Update ABI dump tool to disable checks with libcxx by default (intel#3370)
  [SYCL] Update the way we handle -sycl-std= based on community review feedback (intel#3371)
  [SYCL] Move tests to llvm-test-suite (intel#3359)
  [SYCL][PI][L0] Revert copy batching from intel#3232 (intel#3363)
  [SYCL] Remove unsupported option.
  [SYCL] Fix pragma setting in sycl-post-link (intel#3358)
  [SYCL] Add ITT annotation instructions (intel#3299)
  [SYCL] Propagate attributes of original kernel to wrapper kernel generated for range-rounding (intel#3306)
  [BuildBot] Uplift GPU RT version for Linux to 21.09.19150 (intel#3316)
  [SYCL] Retain PI events until they have signaled (intel#3350)
  [SYCL] Add caching when using interop constructor (intel#3327)
  Add ITT stubs and wrappers for SPIR-V devices (intel#3279)
  [SYCL] Add zero argument version of buffer::reinterpret() for SYCL 2020 (intel#3333)
  [SYCL] Restore old behavior of get() method (intel#3356)
  [Driver][SYCL][FPGA] Improve FPGA AOT when using Triple (intel#3330)
  [SYCL] Revert support for pinned_host_memory extension in Level-Zero backend. Make it a NOP (intel#3349)
  [SYCL] Remove redundant build options processing (intel#3342)
  ...
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.

6 participants