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

merge kp-kernels-timers #235

Merged
merged 9 commits into from
Feb 15, 2024
Merged

Conversation

blegouix
Copy link
Contributor

@blegouix blegouix commented Jan 30, 2024

Environment flag "KOKKOS_TOOLS_TIMER_JSON" determines if export is done in .dat or .json format.

Regions are also exported in the .json (it was not the case previously)

@masterleinad
Copy link
Contributor

Can you please describe the behavior when setting KP_KERNEL_TIMER_JSON and when you are not setting it? Is something exported? What is printed? How did the behavior change in both cases?

@blegouix
Copy link
Contributor Author

blegouix commented Jan 30, 2024

KP_KERNEL_TIMER_JSON=1, True or true leads to the behavior of previous kp_kernel_timer_json.cpp file (export of a .json file giving the timings), KP_KERNEL_TIMER_JSON with any other value or unset gives the behavior of previous kp_kernel_timer.cpp (export of a .dat file, readable with kp_reader)

Moreover, regions timings was not implemented in kp_kernel_timer_json.cpp. Now they are.

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.

avoid duplicating code and explore sharing the implementation with JSON writer.

profiling/simple-kernel-timer/kp_kernel_timer.cpp Outdated Show resolved Hide resolved
profiling/simple-kernel-timer/kp_kernel_timer.cpp Outdated Show resolved Hide resolved
@vlkale
Copy link
Contributor

vlkale commented Feb 1, 2024

Thanks @blegouix

I would like to request changing the environment variable name to 'KOKKOS_TOOLS_TIMER_JSON so as to be uniform with the other Kokkos Tools environment variables.

The format for tools environment variables is KOKKOS_TOOLS_<nameofTool>_<Variable>. It looks like this is not clear in the documentation of Kokkos Tools, and I will update this from my end.

@vlkale
Copy link
Contributor

vlkale commented Feb 1, 2024

@blegouix

I just want to point it out that there seems to be an error in one of the CI build tests. It comes from PAPI connector. The error is in the screenshot below. The CI simple-build (without Kokkos) passes.

Screenshot 2024-02-01 at 9 24 21 AM

@blegouix
Copy link
Contributor Author

blegouix commented Feb 1, 2024

I think the PAPI thing is just a warning, but there is indeed an error there:

/usr/bin/ld: ../profiling/all/libkokkostools.so: undefined reference to KokkosTools::KernelTimerJSON::get_event_set()'`

I'll check it, it is possible that namespace changed or something

@vlkale
Copy link
Contributor

vlkale commented Feb 1, 2024

I think the PAPI thing is just a warning, but there is indeed an error there:

/usr/bin/ld: ../profiling/all/libkokkostools.so: undefined reference to KokkosTools::KernelTimerJSON::get_event_set()'`

I'll check it, it is possible that namespace changed or something

Great, thanks!

Yeah, the Kokkos Tools CI tests don’t pass unless all warnings are eliminated.

@blegouix
Copy link
Contributor Author

blegouix commented Feb 2, 2024

Can you run the CI again ?

@blegouix
Copy link
Contributor Author

blegouix commented Feb 5, 2024

Can you run the CI again ? Also, I do not think I have the right version of clang-format, could you format it for me ?

Thx,

@vlkale
Copy link
Contributor

vlkale commented Feb 6, 2024

Can you run the CI again ?

Done.

Also, I do not think I have the right version of clang-format, could you format it for me ?

Thx,

Use clang-format-8.

On a Mac (if you have it), you can use homebrew and do brew install clang-format@8. Otherwise, can you download it from there on clang.llvm.org? I think it will help you to get clang-format-8 for PR contribution to Kokkos Tools. If you can't get this to work easily, I can do this for you.

for (auto kernel_itr = count_map.begin(); kernel_itr != count_map.end();
kernel_itr++) {
kernel_itr->second->writeToBinaryFile(output_data);
fprintf(output_data, "}\n}");
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to have a test for this. Otherwise, how could a reviewer be sure that nothing broke ?

@blegouix
Copy link
Contributor Author

blegouix commented Feb 7, 2024

I have no idea why the remaining test fails :(

@blegouix
Copy link
Contributor Author

Hello, can we merge this or do you think there are remaining things to do ?

@vlkale
Copy link
Contributor

vlkale commented Feb 13, 2024

Started CI workflow.

I am OK with not sorting the times. I see a broader motivation though - this is how CUDA nvtx tools display timing output, and so there is an expectation by a Kokkos user for this may be similar.

I think the environment variable mentioned in your last message is a good temporary solution.

Thanks a lot for your help and work here!

@blegouix
Copy link
Contributor Author

The environment variable is not in the scope of this MR right ?

Im on holidays next week so would be great if we can merge before that

Comment on lines +103 to +109
fprintf(output_data, " \"total-kernel-times\" : %10.3f,\n",
kernelTimes);
fprintf(output_data, " \"total-non-kernel-times\" : %10.3f,\n",
(totalExecuteTime - kernelTimes));

const double percentKokkos = (kernelTimes / totalExecuteTime) * 100.0;
fprintf(output_data, " \"percent-in-kernels\" : %6.2f,\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure that aggregates should be part of the JSON report.

It makes sense that "console" reports do aggregate times so the user is presented with a nice summary.

But IMO JSON output should be as raw as possible, since I guess the sole purpose of JSON format is to post-process results somewhere else in a user-specific way.

I think it is not valuable that Kokkos Tools adds aggregated metrics in the JSON output...

Copy link
Contributor Author

@blegouix blegouix Feb 15, 2024

Choose a reason for hiding this comment

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

Maybe but it is not in the scope of the MR. It was already there in the timer_json.cpp

(but actually as a user I would say that if you remove aggregated metrics in the output you should provide an easy way to post-process automatically (like execute python script when kokkos finalizes), otherwise it makes things more complicated than they should for people who just want to monitor the performance of their code in development stage)

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.

This is good enough for now.

As a follow up I want us to consider using an environment variable (and command-line argument) to select the output format instead of the KOKKOS_TOOLS_TIMER_JSON boolean option.
I also want us to reuse the JSON writing code from kp_json_writer.cpp instead of duplicating.
And finally we need to add tests for that tool.

@dalg24 dalg24 merged commit 38831c3 into kokkos:develop Feb 15, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants