-
Notifications
You must be signed in to change notification settings - Fork 69
space-time-stack: allow API access to the stack #236
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: develop
Are you sure you want to change the base?
Conversation
784dc5c to
18c026a
Compare
94932ac to
1bcc5e5
Compare
|
@vlkale @dalg24 @masterleinad Would you have some time to give your feedback on this one ? Thanks 🙏 |
masterleinad
left a comment
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.
You are combining two independent ideas. Please split them or provide some justification as to why this is not possible.
|
@masterleinad I could indeed separate them. I could first introduce Google Test. But I need the "moved to header file" feature to effectively use Google Test in Is there any way I can load the space-time-stack tool in a test setup and unload it in the test tear down ? |
|
@masterleinad If not, you've got 2 options IMO:
Your choice 😉 |
Why can't you just convert the existing test (and mimic the way we use |
|
The existing test looks at the output of the Currently, it works like this: initialize Kokkos
redirect std::cout to std::ostringstream
launch kernels
fnialize kokkos
look at what we received in the bufferSo I guess it is not easy to make the current test use something like you're mentioning (https://github.com/kokkos/kokkos/blob/master/core/unit_test/UnitTestMainInit.cpp). As an alternative (that I don't really like), we could do: TEST(SpaceTimeStack, demangle) {
//! Initialize @c Kokkos.
Kokkos::initialize(argc, argv);
//! Redirect output for later analysis.
std::cout.flush();
std::ostringstream output;
std::streambuf* coutbuf = std::cout.rdbuf(output.rdbuf());
//! Run tests. @todo Replace this with Google Test.
Tester tester(Kokkos::DefaultExecutionSpace{});
//! Finalize @c Kokkos.
Kokkos::finalize();
//! Restore output buffer.
<here comes the test assertions using Google Test>
}So basically we would never initialize |
|
@masterleinad Let's move the discussion to #237 😉 (wherein only Google Test is added) |
@masterleinad Is this good with you? |
a912bc8 to
7cf80c8
Compare
671f8fc to
7d4fb37
Compare
|
@vlkale @masterleinad I added the
|
6ce77f4 to
0618fc0
Compare
0618fc0 to
ac0c80d
Compare
|
@vlkale @masterleinad Have you had a chance to look at this yet ? 😄 |
|
Thanks for your work on this. I have a couple of quick comments.
|
The use case is described in details in the PR description. In summary, allow for code reuse and allow user to make API requests to the
Not sure I understand the point. I've extracted the Google Test related stuff from this PR to #237. This PR is now only concerned with modifying and testing the
I guess thinking of how the vendor connectors can be tested is a bigger picture question. As a reminder, the CICD of this repo still runs on GitHub runners. So testing vendor connectors for GPUs is not even possible for now. I would also propose that this PR does not get blocked by such a bigger picture question. |
dalg24
left a comment
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 really don't like exposing the internals of the tool for the sake of testing it.
In the end we still need some testing of the actual output.
Why did you do chose this approach over running a dummy program and asserting that the right things get printed to the screen?
I expect it is fairly easy for regions. You could use std::this_thread::sleep_for if you want some control over their ballpark duration.
As for kernels, you can check that short running that are below the threshold do not show. Things like that.
| Space get_space(Kokkos::Tools::SpaceHandle const& handle); | ||
| const char* get_space_name(const Space space); | ||
|
|
||
| enum { NSPACES = 5 }; |
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.
How about you declare it as last enumerator in Space?
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.
(to be clear I don't think you should change anything in the tool, In think you should consider a different approach for testing)
| } | ||
|
|
||
| const char* get_space_name(int space) { | ||
| const char* get_space_name(const Space space) { |
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 looked over the implementation and can't help asking what is the benefit of the switch case over a simple
char *space_names[] = {
"HOST",
"CUDA",
...
};especially now that you pin their value in the enumeration declaration?
(not asking you to change here)
masterleinad
left a comment
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.
So a user that today uses
Teuchostimers can simply change withKokkosprofile regions and scoped regions and enjoy a unified approach, and can make queries to theState, e.g. during a benchmark in which manual timers are used.
What is actually missing to replace Teuchos::TimeMonitor with some Kokkos Tools? I don't think that exposing State to Trilinos users is a good idea. I could see that it could make sense to expose it for a different tool to use it, though. Or you would just add missing functionality to SpaceTimeStack directly.
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.
Why do you change this test? The common use case is to use KOKKOS_TOOLS_LIBS.
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.
@romintomasetti I think we want to maintain the test from #237, which uses KOKKOS_TOOLS_LIBS.
If you want to do this, maybe we put back the original Google TEST (that doesn't use the new feature from this PR) in this .cpp file?
Or, maybe this file should not actually not be touched for this PR and can put the TEST fixture (TEST_F) in another .cpp file?
|
@romintomasetti Thanks for your replies. Replies inline. To summarize:
OK, thanks for that. I think the reason to do that is so that Kokkos Tools users and developers can more easily test space-time-stack. In any case, I think the second sentence is a good opening of a new Github Issue. As per Kokkos Tools development convention (I want to create a contributing.md), we should write this and then put at the top of this PR 'Fix Github Issue # xyz'). The PR #237 was a good one that addressed the testing github issue well (#191). This PR has some motivation for it and is related, but this is separate from that. At least, when I wrote that Github Issue, this PR was not my intention.
OK. I would still say this is a priority given user's often go to these connectors, but this is not to demote priority of space-time-stack, as it is one of the most useful non-vendor-connectors to users. And yes, you are right on the CICD github runners. That said, let me suggest something more focused to this PR: Should all tests of space-time-stack developed be required to run on the Github runners? Do we provide some tests for space-time-stack as-is in Kokkos Tools, which are only applicable and pertinent to GPUs? I think your allowing the API access to the stack addresses this problem, but maybe there is a different solution to the problem.
OK. We can leave nvtx-connector out. I would assume the changes you propose should be considered for other connectors. It's not my intention to block this PR and I see after thinking about it that we don't need to. |
Summary
This PR:
Adds Google Test from a git tag iif tests are enabledDone in tests: add Google Test and use it to testspace-time-stackconnector #237kp_space_time_stack.cpptokp_space_time_stack.hppto enable users make API-driven requests to theStatestd::chrono::steady_clockfor recording the duration of the frames as generally recommendedDescription
Google Test was needed for better testing. See for instance #195.
The need for moving declarations to a dedicated header file is driven by:
StackNodeis also used inkp_chrome_tracing.cppThe second point is worth explaining in more details.
In fact, we think that
space-time-stackcould be a replacement forTeuchos::TimeMonitor. Indeed, the approach withTeuchostimers is generally to enable them via a compile definition (HAVE_TPETRA_MMM_TIMINGSfor instance) or using some sort of parameter. These approaches are not easy:Moreover
Teuchostimers are not easily made "compatible" withKokkos Toolscallbacks.Having API access to
space-time-stackhelps in that:So a user that today uses
Teuchostimers can simply change withKokkosprofile regions and scoped regions and enjoy a unified approach, and can make queries to theState, e.g. during a benchmark in which manual timers are used.Related