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

[flang][OpenMP] Support host_eval for target teams loop #228

Open
wants to merge 1 commit into
base: amd-trunk-dev
Choose a base branch
from

Conversation

ergawy
Copy link

@ergawy ergawy commented Dec 11, 2024

Extends host_eval support for the currently supported form of the generic loop directive.

Extends `host_eval` support for the currently supported form of the
generic `loop` directive.
@ergawy ergawy requested review from skatrak and agozillon December 11, 2024 09:24
Copy link

@skatrak skatrak 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 Kareem for working on this! I've got a couple of small comments, but I think it's almost there.

Comment on lines +575 to +579
case OMPD_loop:
case OMPD_teams_loop:
case OMPD_target_teams_loop:
cp.processCollapse(loc, eval, hostInfo.ops, hostInfo.iv);
break;
Copy link

Choose a reason for hiding this comment

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

Here we need to also make sure thread_limit and num_teams are processed when applicable.

Suggested change
case OMPD_loop:
case OMPD_teams_loop:
case OMPD_target_teams_loop:
cp.processCollapse(loc, eval, hostInfo.ops, hostInfo.iv);
break;
case OMPD_teams_loop:
cp.processThreadLimit(stmtCtx, hostInfo.ops);
[[fallthrough]];
case OMPD_target_teams_loop:
cp.processNumTeams(stmtCtx, hostInfo.ops);
[[fallthrough]];
case OMPD_loop:
cp.processCollapse(loc, eval, hostInfo.ops, hostInfo.iv);
break;

@@ -1909,7 +1909,7 @@ llvm::omp::OMPTgtExecModeFlags TargetOp::getKernelExecFlags() {

// Detect Generic-SPMD: target-teams-distribute[-simd].
if (numWrappers == 1) {
if (!isa<DistributeOp>(innermostWrapper))
if (!isa<DistributeOp>(innermostWrapper) && !isa<LoopOp>(innermostWrapper))
Copy link

Choose a reason for hiding this comment

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

This is slightly incorrect, because it will cause target teams loop to be tagged as Generic-SPMD instead of SPMD. Perhaps you can set a local llvm::omp::OMPTgtExecModeFlags variable to OMP_TGT_EXEC_MODE_GENERIC_SPMD or OMP_TGT_EXEC_MODE_SPMD based on whether the wrapper is omp.distribute or omp.loop and return it if all conditions below are met, instead of it always being OMP_TGT_EXEC_MODE_GENERIC_SPMD.

Also update the comment above, to prevent it from becoming misleading.

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