-
Notifications
You must be signed in to change notification settings - Fork 407
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
V1.1 Tools Interface: incremental, action-based #3812
V1.1 Tools Interface: incremental, action-based #3812
Conversation
Quick note: I've not yet actually removed the hard-coded fences. We can do that if this kind of design looks good, this is just a sketch of what tools need to do |
Retest this please |
Just for yuks I've reimplemented the Apollo autotuning tool for this interface, and it does work, kinda cool to see. So the tuning use case is supported by this |
For an example of a tool that has integrated this, see LLNL/apollo#12 , where fences are enabled up til convergence, at which point they're removed |
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.
Generally I like this much better, in particular since it will actually work :-)
Besides the comment left inline, two naming things:
- How about renaming ToolActions into ToolInvokedActions or so. Make it more clear that these are things where the tool calls stuff provided by Kokkos.
- How about ToolResponses into ToolSettings: Responses sounds a bit like its something we query the tool over and over for. Settings is more clear that its a one time thing, we ask the tool to figure out how to behave on our side.
My plan is to implement Christian's changes once I get a "this works for me" from Kevin and/or Bill. Procuring such a statement would likely require a little bit of testing things, which I'd be more than happy to do |
I enthusiastically endorse this change... I am trying to profile the WDM XGC app, and it uses Kokkos. If I set |
@crtrott : made those changes. If Kevin's happy, I'm happy |
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.
Almost there :-) Try to make for 3.4
// BooleanConstant::value: "if this callback ever needs a fence", AND | ||
// if the tool requires global fencing (default true, but tools can | ||
// overwrite) | ||
if ((BooleanConstant::value) && |
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.
Instead of just a comment, how about replacing BooleanConstant
(which is a description of the type and not its purpose) with something like enum class RequiresGlobalFencing : bool { Yes, No }
. Given that this is inlined, the check will likely always be optimized away (or use a two different functions differentiated by a tag or use RequiresGlobalFencing as a non-type template parameter that we specify explicitly if we are really concerned about this).
I'm also wondering if Callback
and RequiresGlobalFencing
should be switched, as callback
and its args
should be together.
I've addressed the comments from the call. I think I'll leave it at these changes, and improve the implementation details more in a future PR |
Alternative to #3799
Rather than have a different set of callbacks, in which a tool can tell Kokkos what to do (the 3799 approach), this is much more incremental, but probably just as featureful. Basically, at init, Kokkos requests that a tool enumerate its requirements (global fencing), and gives the tool a list of actions (function pointers) it can take (like fence Kokkos)
Still after init, we request that a tool tell us whether it requires the current "global" fence behavior in a new callback (
kokkosp_request_responses
). This callback accepts a pointer to a struct in which the tool can declare settings. Right now it only has one setting (requires_global_fencing
, default true), but this leaves us room to expand. One problem with expanding it, though, is that a tool might be from a newer Kokkos than an application, so I enumerate how many responses are supported by Kokkos. I'll also try to be diligent about updating KOKKOSP_INTERFACE_VERSION, but that's a bit of a crapshoot, so this is an extra guard rail. Speaking of guard rails, if a tool doesn't implement this function, the result is that no settings are overwritten. Since the settings default to current behavior, we guarantee (check me on this) backwards compatibility.As to how the tool fences Kokkos, we have another callback (
kokkosp_transmit_actions
), that takes in aToolActions
struct containing a set of function pointers. At this point, all we have is a "fence" function that takes in a device ID. At the moment, that device ID is ignored, but long term we might change the invoked function from a globalKokkos::fence()
to something more selective. ToolActions is implemented the same as ToolResponses, it has padding and reports the number of implemented callbacks, so tools can reason about what is supported.Personally, at this point I favor this approach over that of 3799, it's powerful, but a very small change.
edit: additionally, replaced the "function_pointer" typedef in the C_Interface.h file with Kokkos_Tools_functionPointer, to avoid name collisions and make the naming scheme a bit more consistent