Skip to content

[SYCL] Fix indirect hier-par not marking intermediate functions. - #23765

Open
inteltdelisle wants to merge 4 commits into
intel:syclfrom
inteltdelisle:work/pfwg/indirect_fix
Open

inteltdelisle wants to merge 4 commits into
intel:syclfrom
inteltdelisle:work/pfwg/indirect_fix

Conversation

@inteltdelisle

Copy link
Copy Markdown
Contributor

Code inside parallel_for_work_group(pfwg) must be lowered so that the side-effects only happen on the leader. However, some functions must not be called on divergent control flow, particularly parallel_for_work_item(pfwi). Previously, calls to pfwi tagged the caller as needing lowering, but the rest of the call-stack was not tagged. This could duplicate side-effects in intermediate functions. This changes the tagging to mark the entire stack.

Fixes #23700.

Code inside parallel_for_work_group(pfwg) must be lowered so that the
side-effects only happen on the leader. However, some functions must not
be called on divergent control flow, particularly
parallel_for_work_item(pfwi). Previously, calls to pfwi tagged the
caller as needing lowering, but the rest of the call-stack was not
tagged. This could duplicate side-effects in intermediate functions.
This changes the tagging to mark the entire stack.

Fixes intel#23700.

Signed-off-by: Delisle, Thierry <thierry.delisle@intel.com>
@inteltdelisle

Copy link
Copy Markdown
Contributor Author

Ping @intel/dpcpp-cfe-reviewers @intel/dpcpp-tools-reviewers @intel/llvm-reviewers-runtime

Comment thread clang/lib/Sema/SemaSYCL.cpp Resolved
Signed-off-by: Delisle, Thierry <thierry.delisle@intel.com>
// A helper which does not reach parallel_for_work_item is not marked:
// CHECK-DAG: define {{.*}}spir_func void @_Z5plainPi({{.*}}) #{{[0-9]+}} {{[{]$}}

// The SYCL kernel function is not emitted in device IR, so check its AST

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You don't need this test. I think the KERNEL check above is sufficient. Sorry I gave an incorrect answer earlier in chat.

Also, AST tests should never be added in a CodeGen file. This however did remind me that you should add a Sema test for this PR. Can you check if scope attribute has an existing Sema or AST test? Can you add tests for this PR there?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seconded.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried to address this. But I admit I wasn't exactly sure what you were looking for so I relied on Claude much more heavily. Do my changes in 1f21d1f address your concerns?

Signed-off-by: Delisle, Thierry <thierry.delisle@intel.com>
Signed-off-by: Delisle, Thierry <thierry.delisle@intel.com>

This branch has not been deployed

No deployments
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.

[SYCL] Indirect call to hierarchical parallelism causes work-group code to be called per work-item

4 participants