Skip to content

Conversation

@eme64
Copy link
Contributor

@eme64 eme64 commented Jan 26, 2024

Subtask of #16620

I got approval to remove VectorizeDebugOption: JDK-8320668

I want a more general flag for AutoVectorization, that can trace different components of AutoVectorization.
It should be a CompileCommand, so that it can select which methods it traces for.

TraceSuperWord should still look similar, and select a subset of the TraceAutoVectorization components (those for SuperWord), but still apply to all classes/methods.

With more refactoring later in JDK-8315361, this flag should become more usable and interpretable. Especially, the idea is that different components of the VLoop / VLoopAnalyzer can have tracing enabled / disabled.

How to use the flag:
Get "help", i.e. see all available tags:
./java -Xcomp -XX:CompileCommand=TraceAutoVectorization,*::*,help --version

See "rejections" (i.e. failures where we don't vectorize) and successes (using TraceNewVectors):
./java -Xcomp -XX:CompileCommand=TraceAutoVectorization,*::*,SW_REJECTIONS -XX:+TraceNewVectors --version
The results are currently underwhealming. I will have to track many more failures, and I will do that with the bigger refactoring, when I move around the code and require error code returning everywhere, and then I can use that error code for printing.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8317572: C2 SuperWord: refactor/improve TraceSuperWord, replace VectorizeDebugOption with TraceAutoVectorization (Sub-task - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17586/head:pull/17586
$ git checkout pull/17586

Update a local copy of the PR:
$ git checkout pull/17586
$ git pull https://git.openjdk.org/jdk.git pull/17586/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17586

View PR using the GUI difftool:
$ git pr show -t 17586

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17586.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 26, 2024

👋 Welcome back epeter! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot changed the title 8317572 8317572: C2 SuperWord: refactor/improve TraceSuperWord, replace VectorizeDebugOption with TraceAutoVectorization Jan 26, 2024
@openjdk
Copy link

openjdk bot commented Jan 26, 2024

@eme64 The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Jan 26, 2024
_vector_loop_debug = phase->C->directive()->VectorizeDebugOption;
}

#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: initialization now happens via _vtrace field, and is constructed implicitly.

}
}
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was only printed if _do_vector_loop was on, i.e. if OptionVectorize enabled (kinda odd anyway).
And we already do print_bb, which prints all relevant nodes (enabled with SW_INFO or TraceSuperWord).

_nlist.at(j)->dump();
}
}
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already print the mem slice in mem_slice_preds.

uint vlen = p->size();
uint vlen_in_bytes = 0;
Node* vn = nullptr;
NOT_PRODUCT(if(is_trace_cmov()) {tty->print_cr("VPointer::output: %d executed first, %d executed last in pack", first->_idx, n->_idx); print_pack(p);})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was behind the wrong flag is_trace_cmov, and I think it was never used anyway.

_nstack(nstack), _analyze_only(analyze_only), _stack_idx(0)
#ifndef PRODUCT
, _tracer((phase->C->directive()->VectorizeDebugOption & 2) > 0)
, _tracer(phase->C->directive()->traceautovectorization_tags().at(TraceAutoVectorizationTag::POINTER_ANALYSIS))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I now do the ugly thing. Later, with the bigger refactoring, I will pass VLoop into the VPointer, and then we can access the flag via VPointer -> VLoop -> VTrace.

}
};
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea is that this is going to be a "component" of VLoop, once I do the bigger refactoring.

@eme64 eme64 marked this pull request as ready for review January 26, 2024 13:27
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 26, 2024
@mlbridge
Copy link

mlbridge bot commented Jan 26, 2024

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Generally looks good! I have some comments.

// Return a memory slice (node list) in predecessor order starting at "start"
void SuperWord::mem_slice_preds(Node* start, Node* stop, GrowableArray<Node*> &preds) {
assert(preds.length() == 0, "start empty");
Node* n = start;
Copy link
Member

Choose a reason for hiding this comment

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

There is still a usage of TraceSuperWord on L927. Should this also be replaced?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be removed with #17585 anyway ;)

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

It is good. Two comments.

jio_snprintf(errorbuf, buf_size, "Unrecognized intrinsic detected in %s: %s", option2name(option), validator.what());
}
}
#ifndef PRODUCT
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing #ifdef COMPILER2 for this and PrintIdealPhase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

if (!valid) {
error(VALUE_ERROR, "Unrecognized intrinsic detected in DisableIntrinsic: %s", validator.what());
}
} else if (strncmp(option_key->name, "TraceAutoVectorization", 22) == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing #ifndef PRODUCT and #ifdef COMPILER2 for this and for PrintIdealPhase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Looks good.

@openjdk
Copy link

openjdk bot commented Jan 27, 2024

@eme64 This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8317572: C2 SuperWord: refactor/improve TraceSuperWord, replace VectorizeDebugOption with TraceAutoVectorization

Reviewed-by: chagedorn, kvn

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 4 new commits pushed to the master branch:

  • 72ba817: 8324236: compiler/ciReplay/TestInliningProtectionDomain.java failed with RuntimeException: should only dump inline information for ... expected true, was false
  • b39b876: 8324304: RISC-V: add hw probe flags
  • 69586e7: 8322996: BoxLockNode creation fails with assert(reg < CHUNK_SIZE) failed: sanity
  • f0bae79: 8324750: C2: rename Matcher methods using "superword" -> "autovectorization"

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 27, 2024
Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the updates!

Comment on lines 25 to 26
#ifndef SHARE_OPTO_TRACE_AUTO_VECTORIZATION_TAG_HPP
#define SHARE_OPTO_TRACE_AUTO_VECTORIZATION_TAG_HPP
Copy link
Member

Choose a reason for hiding this comment

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

I think for this define, you should keep SHARE_OPTO_TRACEAUTOVECTORIZATIONTAG_HPP to follow the convention of other files where we do not insert underlines in the filename.

@eme64
Copy link
Contributor Author

eme64 commented Jan 29, 2024

@chhagedorn @vnkozlov thanks for the reviews and helpful suggestions!
/integrate

@openjdk
Copy link

openjdk bot commented Jan 29, 2024

Going to push as commit 3066d49.
Since your change was applied there have been 6 commits pushed to the master branch:

  • 7a300b6: 8324213: C1: There is no need for Canonicalizer to handle IfOp
  • 628348d: 8324186: Use "dmb.ishst+dmb.ishld" for release barrier
  • 72ba817: 8324236: compiler/ciReplay/TestInliningProtectionDomain.java failed with RuntimeException: should only dump inline information for ... expected true, was false
  • b39b876: 8324304: RISC-V: add hw probe flags
  • 69586e7: 8322996: BoxLockNode creation fails with assert(reg < CHUNK_SIZE) failed: sanity
  • f0bae79: 8324750: C2: rename Matcher methods using "superword" -> "autovectorization"

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 29, 2024
@openjdk openjdk bot closed this Jan 29, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 29, 2024
@openjdk
Copy link

openjdk bot commented Jan 29, 2024

@eme64 Pushed as commit 3066d49.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants