-
Notifications
You must be signed in to change notification settings - Fork 62
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
Changes from all commits
01ffc3c
a44cd99
10af578
5a49cca
d203984
a6a2972
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
#include <arbor/fvm_types.hpp> | ||
#include <arbor/mechanism_abi.h> | ||
#include <arbor/mechinfo.hpp> | ||
#include <arbor/profile/profiler.hpp> | ||
#include <arbor/version.hpp> | ||
|
||
namespace arb { | ||
|
||
|
@@ -32,6 +34,8 @@ class mechanism { | |
mechanism(const arb_mechanism_type m, | ||
const arb_mechanism_interface& i): mech_{m}, iface_{i}, ppack_{} { | ||
if (mech_.abi_version != ARB_MECH_ABI_VERSION) throw unsupported_abi_error{mech_.abi_version}; | ||
state_prof_id = profile::profiler_region_id("advance:integrate:state:"+internal_name()); | ||
current_prof_id = profile::profiler_region_id("advance:integrate:current:"+internal_name()); | ||
} | ||
mechanism() = default; | ||
mechanism(const mechanism&) = delete; | ||
|
@@ -55,8 +59,8 @@ class mechanism { | |
|
||
// Forward to interface methods | ||
void initialize() { ppack_.vec_t = *time_ptr_ptr; iface_.init_mechanism(&ppack_); } | ||
void update_current() { ppack_.vec_t = *time_ptr_ptr; iface_.compute_currents(&ppack_); } | ||
void update_state() { ppack_.vec_t = *time_ptr_ptr; iface_.advance_state(&ppack_); } | ||
void update_current() { prof_enter(current_prof_id); ppack_.vec_t = *time_ptr_ptr; iface_.compute_currents(&ppack_); prof_exit(); } | ||
void update_state() { prof_enter(state_prof_id); ppack_.vec_t = *time_ptr_ptr; iface_.advance_state(&ppack_); prof_exit(); } | ||
void update_ions() { ppack_.vec_t = *time_ptr_ptr; iface_.write_ions(&ppack_); } | ||
void post_event() { ppack_.vec_t = *time_ptr_ptr; iface_.post_event(&ppack_); } | ||
void deliver_events(arb_deliverable_event_stream& stream) { ppack_.vec_t = *time_ptr_ptr; iface_.apply_events(&ppack_, &stream); } | ||
|
@@ -68,6 +72,21 @@ class mechanism { | |
arb_mechanism_interface iface_; | ||
arb_mechanism_ppack ppack_; | ||
arb_value_type** time_ptr_ptr = nullptr; | ||
|
||
private: | ||
#ifdef ARB_PROFILE_ENABLED | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 However, I am a wary of the 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right about static, all the instances of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it basically pastes in the |
||
void prof_enter(profile::region_id_type id) { | ||
profile::profiler_enter(id); | ||
} | ||
void prof_exit() { | ||
profile::profiler_leave(); | ||
} | ||
#else | ||
void prof_enter(profile::region_id_type) {} | ||
void prof_exit() {} | ||
#endif | ||
profile::region_id_type state_prof_id; | ||
profile::region_id_type current_prof_id; | ||
}; | ||
|
||
struct mechanism_layout { | ||
|
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 probably not as useful, but I would suggest -- just for completeness -- to instrument all methods here.
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.
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.