-
Notifications
You must be signed in to change notification settings - Fork 16
Flop counting #623
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
base: main
Are you sure you want to change the base?
Flop counting #623
Conversation
31da603 to
83629d9
Compare
|
@inducer I think this is ready for a first look, apart from some basedpyright errors that I don't understand. Probably best to go commit by commit. |
|
@inducer I ran into a complication with the flop counting for conditionals. When mirgecom projects something from interior/boundary faces to all faces, meshmode's direct connection code creates an Since the flop counting currently evaluates flops for |
5236448 to
72b69ac
Compare
|
@inducer Do you know what's causing these basedpyright errors for Also, about the |
72b69ac to
f6d34b8
Compare
789e7ac to
f077dd1
Compare
f077dd1 to
61aed37
Compare
| _visited_functions=self._visited_functions) | ||
|
|
||
| def post_visit(self, expr: Any) -> None: | ||
| def post_visit(self, expr: ArrayOrNames | FunctionDefinition) -> None: |
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.
Would it make sense to define ArrayOrNamesOrFunction?
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.
Yeah, probably. This shows up all over the place, though, so maybe best for a standalone PR?
pytato/utils.py
Outdated
| return ( | ||
| isinstance(expr, Array) | ||
| and not isinstance(expr, ( | ||
| # FIXME: Is there a nice way to generalize this? |
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.
I'm not sure I understand the intent of this.
For example, DistributedRecv is always materialized (it ends up in a buffer after all).
What is this function trying to accomplish?
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.
I'm using this in the flop counting code to tell me a couple of things:
- Am I allowed to materialize/unmaterialize this expression? (Can't for things like
NamedArrayandDistributedSendRefHolder.) - Can this expression be lowered to an index lambda? (Can't for things like
InputArgumentBaseandDistributedRecv.)
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.
Is 2e9fedd any better? It still has some isinstance() checks that seem kind of fragile, but I'm not sure how to avoid them.
pytato/transform/calls.py
Outdated
| return frozenset(expr.bindings.values()) | ||
|
|
||
|
|
||
| class _CallMaterializer(CopyMapper): |
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.
I'm not sure I understand this. This appears to enforce a specific view of whether function arguments and/or return values are materialized, when I would prefer that pytato have no opinion in the matter. They could/could not be materialized; they're just expressions, just like everyone else.
Could you explain the intent behind this?
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.
I was trying to look at the flop counting from the perspective of "if I immediately generated code from this DAG". In that sense, any function calls remaining in the DAG would (in theory) be emitted as kernel functions, right? So the inputs/outputs would get materialized?
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.
I removed the call materialization and made the flop counting require function calls to be inlined beforehand for now.
| op_name_to_num_flops: Mapping[str, int] | None = None, | ||
| ) -> ArrayOrScalar: | ||
| """ | ||
| Count the total number of floating point operations in the DAG *expr*. |
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.
Explain more precisely how this interacts with materialization.
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.
Something like 9284664?
| Returns a dictionary mapping materialized nodes in DAG *expr* to their floating | ||
| point operation count. |
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.
Explain more precisely how this interacts with materialization.
8164074 to
75e5dbe
Compare

Very WIP right now.
cc @majosm