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

Translation Validation for the P4 compiler #35

Open
fruffy opened this issue Feb 5, 2025 · 2 comments
Open

Translation Validation for the P4 compiler #35

fruffy opened this issue Feb 5, 2025 · 2 comments
Labels
bigtask A task that appears to require a big amount of work

Comments

@fruffy
Copy link
Collaborator

fruffy commented Feb 5, 2025

Gauntlet (cough) has show that it is possible to use translation validation at scale and effectively for P4 programs. This is because the P4 language itself is restricted enough that you can easily convert it to pure SMT expressions and then use these expressions for equality checks in a solver like Z3.

The problem with Gauntlet is that it is an external tool, and not well integrated with the current P4 compiler. Particularly because Gauntlet uses its own type inference and state tracking it is difficult to maintain with developments to the P4 language.

Ideally, we should have a translation validation library as part of P4C, which we can call into to convert a particular P4 construct (e.g., IR:Expression, IR::P4Control, IR::P4Parser) into SMT logic and then use this representation for various validation tasks.

Use case 1: You could use this representation to check whether a particular language construction is "semantically equivalent" before and after a compiler transformation. This is similar to Credible Compilation, which validates that a particular compile step is semantically correct.

Use case 2: Another use case is superoptimization. We can use this SMT representation to transform basic blocks into "better", and semantically equivalent structures.

@fruffy fruffy added the bigtask A task that appears to require a big amount of work label Feb 5, 2025
@jnfoster
Copy link

jnfoster commented Feb 5, 2025

Cool ideas! Would any of the p4testgen infrastructure be useful for this?

@fruffy
Copy link
Collaborator Author

fruffy commented Feb 6, 2025

Cool ideas! Would any of the p4testgen infrastructure be useful for this?

I think so, but it requires work. One problem is that the P4Testgen is build as a monolith, it is designed to consume a P4 program as a whole. Ideally, we want to check single basic blocks.

The symbolic executor interface requires ProgramInfo, which in turn requires compiler information.

Carrying this information along could be onerous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bigtask A task that appears to require a big amount of work
Projects
None yet
Development

No branches or pull requests

2 participants