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

space-time-stack: allow demangled names #225

Merged
merged 1 commit into from
Jan 23, 2024
Merged

Conversation

romintomasetti
Copy link
Contributor

@romintomasetti romintomasetti commented Dec 21, 2023

As promised in #218, this PR extracts the part relevant to demangling names.

  1. The demangling function is now shared in common/utils/demangle.hpp.
  2. The space time stack tool now demangles the names.

This is how the report looks like with the changes:

9: <average time> <percent of total time> <percent time in Kokkos> <percent MPI imbalance> <remainder> <kernels per second> <number of calls> <name> [type]
9: ===================
9: |-> 1.49e-02 sec 43.8% 100.0% 0.0% ------ 1 Tester<Kokkos::OpenMP, 5ul> [for]
9: |-> 1.48e-02 sec 43.5% 100.0% 0.0% ------ 2 named kernel [for]
9: |-> 4.15e-03 sec 12.2% 100.0% 0.0% ------ 1 Tester<Kokkos::OpenMP, 5ul>/Tester<Kokkos::OpenMP, 5ul>::TagUnnamed [for]

and how it looks without the changes:

<average time> <percent of total time> <percent time in Kokkos> <percent MPI imbalance> <remainder> <kernels per second> <number of calls> <name> [type]
===================
|-> 1.79e-02 sec 59.4% 100.0% 0.0% ------ 2 named kernel [for]
|-> 7.90e-03 sec 26.2% 100.0% 0.0% ------ 1 6TesterIN6Kokkos6OpenMPELm5EE [for]
|-> 4.20e-03 sec 13.9% 100.0% 0.0% ------ 1 6TesterIN6Kokkos6OpenMPELm5EE/N6TesterIN6Kokkos6OpenMPELm5EE10TagUnnamedE [for]

@romintomasetti
Copy link
Contributor Author

@vlkale @dalg24 @masterleinad

CMakeLists.txt Outdated Show resolved Hide resolved
common/utils/demangle.hpp Outdated Show resolved Hide resolved
Copy link
Contributor

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

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

Please make sure that the pull request title and description reflect all the changes you make here.

common/utils/demangle.hpp Outdated Show resolved Hide resolved
profiling/simple-kernel-timer/kp_json_writer.cpp Outdated Show resolved Hide resolved
@masterleinad
Copy link
Contributor

You have to fix the indentation as well.

Copy link
Contributor

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

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

Fine with me.

CMakeLists.txt Outdated Show resolved Hide resolved
int kernelIndex = find_index(kernelInfo, new_kernel->getName());
if (!new_kernel->getName().empty()) {
int kernelIndex =
find_index(kernelInfo, new_kernel->getName().c_str());
Copy link
Member

Choose a reason for hiding this comment

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

This is silly, please update find_index and take the trailing argument as a string const ref.

Copy link
Contributor Author

@romintomasetti romintomasetti Dec 29, 2023

Choose a reason for hiding this comment

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

Indeed, and done.

By the way, I think find_index is useless if the variable kernelInfo, which is a std::vector, is changed to being a std::set whose comparator compares the time (see what compareKernelPerformanceInfo does).

I think the code would be much easier to read.

If you agree I can make the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dalg24 I guess you'll want to make the change in another PR 😉

Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Please post a before/after tool output snippet in the description.

common/utils/demangle.hpp Show resolved Hide resolved
@romintomasetti
Copy link
Contributor Author

@dalg24 @masterleinad

I added a test for the space time stack tool that checks how kernels appear in the report.

So I had to modify slightly the code such that Kokkos Tools can also parse unnamed kernels launched with a work tag. See the changes for more details.

common/utils/demangle.hpp Outdated Show resolved Hide resolved
@romintomasetti
Copy link
Contributor Author

@dalg24 @masterleinad Could you please review this one one last time ? 🔍 Thanks!

Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Although obviously adding tests in an improvement but you had almost reached consensus and expanding the scope of your PR will delay merging.

CMakeLists.txt Outdated Show resolved Hide resolved
tests/space-time-stack/test_demangling.cpp Outdated Show resolved Hide resolved
tests/space-time-stack/test_demangling.cpp Outdated Show resolved Hide resolved
tests/space-time-stack/test_demangling.cpp Outdated Show resolved Hide resolved

#include "utils/demangle.hpp"

template <typename execution_space, size_t size = 5>
Copy link
Member

Choose a reason for hiding this comment

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

Why would you want to template the whole struct?
Get rid of apply(), move the test to the constructor that you template on ExecutionSpace. Also there is no point on making the number of iteration a template parameter.

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 think I templated the struct over the execution_space type to check what the tool would output when looking at kernels defined in templated classes. If you think it is unnecessary, I can get rid of the execution_space template.
  • For the number of iterations, I think I wanted to have a compile-time range, but I guess it is useless for this test. I'll use a range from 0 to 1 now 😉

@vlkale
Copy link
Contributor

vlkale commented Jan 18, 2024

@romintomasetti Sorry to not get back sooner - I was away and on vacation + holiday since this time until late last week, and I am still catching up. The idea of demangle.hpp from your initial post and the current code and CMake in your PR makes sense and looks good to me. My top-level comment is whether you want to test this demangling functionality for a couple of other tools, e.g., kernel-logger, simple-kernel-timer? You put this in the common subdirectory, so am I correct that it can be used for those too?

Edit: I see that you have used simple-kernel-timer, so that's great!

Right now, I think
@dalg24 (and @masterleinad) have a better handle on this than me. The PR looks good to me overall. I am good with approving merging this if they are, in order to move things forward.

Copy link
Contributor

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

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

I would prefer to give the functor with a tag a different name. Otherwise, this looks good to me.

tests/space-time-stack/test_demangling.cpp Outdated Show resolved Hide resolved
@dalg24 dalg24 merged commit b3ab0cb into kokkos:develop Jan 23, 2024
7 checks passed
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.

4 participants