-
Notifications
You must be signed in to change notification settings - Fork 1.1k
xe: jit: gemm: improve debugability #3110
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
base: main
Are you sure you want to change the base?
Conversation
5e4bfd6 to
00a7fca
Compare
|
make test |
| emul32High(1, dst.ud(), src0, src1, loc); | ||
| else | ||
| mul(1, dst, src0, src1); | ||
| mul(1, dst, src0, src1, loc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should be thinking about a more general mechanism for "scoping" location information in this way, instead of passing around lots of SourceLocation objects. Something like this:
auto mulHigh = [&](..., SourceLocationScoper scoper = {this}) {
// rest of code as before
};And then SourceLocationScoper is defined something like:
template <HW hw>
class SourceLocationScoper {
SourceLocation loc;
BinaryCodeGenerator *generator = nullptr;
public:
explicit SourceLocationScoper(ngen::BinaryCodeGenerator<hw> *g)
: loc{std::source_location::current()}, generator(g) {
g->enterLocationScope(loc);
}
~SourceLocationScoper() {
generator->exitLocationScope();
}
}The new generator methods {enter,exit}LocationScope would set/clear a location override (new variable in the generator class). You'd have a counter as well to properly support nested scopes (only the outermost is honored).
You could also use this method internally inside nGEN (e.g. pseudo-instructions, etc.) to avoid lots of passing around of loc objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite see what the benefit is here. Is this just supposed to be a performance optimization? For release builds, Source Location will be an empty object, so I expect it would mostly be optimized away anyway. If the goal is to just avoid forwarding loc in the source code, I don't see much benefit as forwarding the same location for a "large" operation seems misguided anyway.
In general, I agree we could use some improvement here, I just haven't been able to come up with a good mechanism. The core problem is that we have multiple source locations that we could reasonably map to each instruction, so I don't see a general mechanism we could use to pick the "right" location as it depends on the use and what is normally being debugged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's for better readability/easier programmability, rather than performance. The idea is that you only need to change one line to combine location information:
auto mulHigh = [&](..., SourceLocationScoper scoper = {this}) {
emul32High(...); // don't have to pass loc here
mul(...); // don't have to pass loc here
};instead of modifying every single instruction:
auto mulHigh = [&](..., SourceLocation loc = {}) {
emul32High(..., loc); // have to pass loc here
mul(..., loc); // have to pass loc here
};When there are a lot of nested instructions, it's easy to miss a loc and just a lot of code changes to make. Since this pattern is appearing in lots of places, it'd be nice to simplify.
Enables source location forwarding for some simple wrapper functionality. This enables better debugging by enabling developers to focus on the higher level details when using a debugger.