Navigation Menu

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

Profile externally loaded mechanisms #1691

Merged
merged 6 commits into from Jan 24, 2022

Conversation

noraabiakar
Copy link
Contributor

@noraabiakar noraabiakar commented Sep 29, 2021

  • Add support for profiling externally loaded mechanisms.
  • Move the profiler calls out of the generated C++ code into the arb::mechanism methods.
  • Remove the --profile flag from the modcc flags.
  • Replace _ delimiter with : in profiler.
  • Replace const char* with const std::string& for profiler region representation.
  • Profiler may now contain empty regions that were registered but not profiled, so add some code to filer those out when generating final profile.

Copy link
Contributor

@thorstenhater thorstenhater left a comment

Choose a reason for hiding this comment

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

Two suggestions, rest looks good.

@@ -55,8 +57,8 @@ class mechanism {

// Forward to interface methods
void initialize() { ppack_.vec_t = *time_ptr_ptr; iface_.init_mechanism(&ppack_); }
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably not as useful, but I would suggest -- just for completeness -- to instrument all methods here.

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 reason they are not is because they're included in another section of the profiler. I agree though, I'll see what I can move around.

@@ -68,6 +70,21 @@ class mechanism {
arb_mechanism_interface iface_;
arb_mechanism_ppack ppack_;
arb_value_type** time_ptr_ptr = nullptr;

private:
#ifdef ARB_PROFILE_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like these two snippets would be useful elsewhere. I would therefore suggest moving them to arb::profile.

However, I am a wary of the static, it means that id is initialised once and only the first region is tagged. See here for a minimal example
https://gcc.godbolt.org/z/f3GPeWaW6

Therefore my final suggestion would be this

#ifdef ARB_PROFILE_ENABLED
#define PROFILE_ENTER(x) do { static auto id = arb::profile::profiler_region_id(x); arb::profile::profiler_enter(id); } while(0)
#else
#define PROFILE_ENTER(x) do {} while(0)
#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.

You're right about static, all the instances of the mechanism class end up having the same name, and the profiler doesn't work. Does your suggestion fix this? I went a different route.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since it basically pastes in the static id = once per invocation, it must fix it, yes.

@noraabiakar noraabiakar marked this pull request as draft September 30, 2021 11:09
Copy link
Contributor

@thorstenhater thorstenhater 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.

@thorstenhater
Copy link
Contributor

👋 Any updates? It seems this is mergeable?

@noraabiakar noraabiakar changed the title Profile externally loaded mechanisms 🚧 Profile externally loaded mechanisms 🚧 Oct 8, 2021
@noraabiakar
Copy link
Contributor Author

I pieced this together in a bit of a rush and it needs a bit of fine tuning. For example, this fix doesn't very well for mechanisms that have _ in their name which are quite common. I think I will implement your suggestion for using :: or something similar for indicating subsections to the profiler.

@noraabiakar noraabiakar marked this pull request as ready for review November 3, 2021 10:19
@noraabiakar noraabiakar changed the title 🚧 Profile externally loaded mechanisms 🚧 Profile externally loaded mechanisms Nov 3, 2021
@noraabiakar noraabiakar marked this pull request as draft December 7, 2021 09:52
Copy link
Member

@bcumming bcumming left a comment

Choose a reason for hiding this comment

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

lgtm

@noraabiakar noraabiakar marked this pull request as ready for review January 21, 2022 16:00
@noraabiakar
Copy link
Contributor Author

bors try

@bors
Copy link

bors bot commented Jan 21, 2022

try

Already running a review

bors bot added a commit that referenced this pull request Jan 21, 2022
@bors
Copy link

bors bot commented Jan 21, 2022

try

Build failed:

@noraabiakar
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Jan 21, 2022
@bors
Copy link

bors bot commented Jan 21, 2022

try

Build failed:

@noraabiakar
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Jan 22, 2022
@bors
Copy link

bors bot commented Jan 22, 2022

try

Build succeeded:

@noraabiakar noraabiakar merged commit 44b67f3 into arbor-sim:master Jan 24, 2022
max9901 pushed a commit to max9901/arbor that referenced this pull request Feb 3, 2022
- Add support for profiling externally loaded mechanisms.
- Move the profiler calls out of the generated C++ code into the `arb::mechanism` methods. 
- Remove the `--profile` flag from the modcc flags. 
- Replace `_` delimiter with `:` in profiler. 
- Replace `const char*` with `const std::string&` for profiler region representation.
- Profiler may now contain empty regions that were registered but not profiled, so add some code to filer those out when generating final profile.
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.

None yet

3 participants