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

Add pure/localState/packetStata annotations #2121

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ChrisDodd
Copy link
Contributor

  • add annotations in appropriate places in v1mode.p4 and psa.p4
  • fix resolveReferences to look at parameters

@@ -340,6 +348,7 @@ enum HashAlgorithm {
}

@deprecated("Please use mark_to_drop(standard_metadata) instead.")
@packetState
Copy link
Contributor

Choose a reason for hiding this comment

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

To be nit-picky here, the reason this is deprecated in v1model is because it isn't a legal P4_16 extern function at all. It violates the one restriction that externs have -- it accesses P4_16 program variables that are not parameters.

Copy link
Contributor

@mihaibudiu mihaibudiu left a comment

Choose a reason for hiding this comment

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

I like this, but I think we should discuss @packetState prior to merging.

p4include/psa.p4 Outdated
@@ -517,12 +526,15 @@ extern Checksum<W> {
/// time the object is instantiated, that is, whenever the parser or control
/// containing the Checksum object are applied.
/// All state maintained by the Checksum object is independent per packet.
@packetState
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks to me like we may want this annotation to be on the extern itself rather than on each method.
Does it ever make sense to have only some methods of an extern be @packetState?

@jafingerhut
Copy link
Contributor

In the interests of moving things forward here, if @pure and @noSideEffects are the only two annotations that we really have good use cases for taking advantage of in compiler optimization passes, would it be better to only add those two, and leave out all of the others?

I apologize if I introduced confusion by describing the other kinds of annotations -- just my over-exuberance in looking for other broader kinds of categories that extern functions/methods fit into, regardless of whether they enabled compiler optimizations.

@jafingerhut jafingerhut mentioned this pull request Apr 9, 2020
@jafingerhut
Copy link
Contributor

The parts of these changes that add the @pure annotation, and changes to v1model.p4 and psa.p4 architectures to add @pure and @noSideEffects annotations, have been merged with this commit: 301411d

As of this writing, there is currently no PR that makes the rest of these changes. I do not know if such a thing is of interest, either, until and unless there is a known compiler optimization use case for additional similar annotations.

@jafingerhut
Copy link
Contributor

@ChrisDodd @mihaibudiu Does it seem reasonable to close this, since @pure and @noSideEffects have been in the P4 spec and p4c implementation for a couple of years now, and no one seems interested in pursuing other annotations like packetState since then?

@mihaibudiu
Copy link
Contributor

I have no problem closing this, but it is Chris' PR.

- add annotations in appropriate places in v1mode.p4 and psa.p4
- fix resolveReferences to look at parameters
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.

3 participants