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

Reenable compilation tests for P4Smith. #4791

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

zzmic
Copy link
Contributor

@zzmic zzmic commented Jul 9, 2024

This is a draft PR that aims to re-enable $COMPILER_BIN $TEST_DIR/out.p4 and test whether there is any generation or compilation error occurred while executing backends/p4tools/modules/smith/scripts/compilation-test.sh.

@zzmic zzmic force-pushed the compilation-test-support branch from b3cf81e to d34f60e Compare July 9, 2024 17:47
@zzmic zzmic changed the title Compilation test support Compilation test support for P4Smith Jul 9, 2024
@fruffy fruffy added the p4tools Topics related to the P4Tools back end label Jul 9, 2024
@zzmic zzmic force-pushed the compilation-test-support branch 3 times, most recently from d841ca5 to 21561a7 Compare July 11, 2024 01:48
@zzmic zzmic force-pushed the compilation-test-support branch 3 times, most recently from 3b29458 to 1423109 Compare July 14, 2024 05:33
@zzmic zzmic force-pushed the compilation-test-support branch from 257c5aa to 889db85 Compare July 16, 2024 19:21
@zzmic zzmic force-pushed the compilation-test-support branch 2 times, most recently from 0d4fbea to f778c51 Compare July 23, 2024 05:55
@zzmic zzmic force-pushed the compilation-test-support branch 2 times, most recently from dae791c to e7a47c0 Compare July 25, 2024 03:46
backends/p4tools/modules/smith/common/expressions.cpp Outdated Show resolved Hide resolved
backends/p4tools/modules/smith/common/expressions.h Outdated Show resolved Hide resolved
backends/p4tools/modules/smith/common/expressions.cpp Outdated Show resolved Hide resolved
backends/p4tools/modules/smith/common/expressions.cpp Outdated Show resolved Hide resolved
backends/p4tools/modules/smith/common/scope.cpp Outdated Show resolved Hide resolved
backends/p4tools/modules/smith/common/scope.cpp Outdated Show resolved Hide resolved
backends/p4tools/modules/smith/common/scope.h Outdated Show resolved Hide resolved
backends/p4tools/modules/smith/common/scope.h Outdated Show resolved Hide resolved
backends/p4tools/modules/smith/common/statements.cpp Outdated Show resolved Hide resolved
@zzmic zzmic force-pushed the compilation-test-support branch from 1075a03 to d8d0fde Compare July 26, 2024 03:47
@zzmic zzmic force-pushed the compilation-test-support branch 4 times, most recently from bf4a750 to 418b981 Compare August 6, 2024 15:40
Copy link
Collaborator

@fruffy fruffy left a comment

Choose a reason for hiding this comment

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

Great! Seems like we are almost done. The error is related to the maximum bit-width.

backends/p4tools/modules/smith/common/expressions.cpp Outdated Show resolved Hide resolved
@zzmic zzmic force-pushed the compilation-test-support branch from 50eaced to 4d79e83 Compare August 9, 2024 07:45
@fruffy fruffy force-pushed the compilation-test-support branch 2 times, most recently from 9071b41 to 34b6ed5 Compare August 13, 2024 07:36
@zzmic zzmic marked this pull request as ready for review August 13, 2024 15:06
@zzmic zzmic force-pushed the compilation-test-support branch from 34b6ed5 to 29739fc Compare August 13, 2024 15:10
@fruffy fruffy force-pushed the compilation-test-support branch from 8622d4c to e42213e Compare August 20, 2024 10:49
@fruffy fruffy changed the title Compilation test support for P4Smith Reenable compilation tests for P4Smith. Aug 20, 2024
@fruffy fruffy force-pushed the compilation-test-support branch from e42213e to c4203c4 Compare August 20, 2024 11:35
zzmic and others added 3 commits August 26, 2024 09:59
Change $TEST_DIR/out.p4 to $TEST_DIR/out_$i.p4 to generate different programs with different seeds (to inspect the behavior of the generation and compilation process in a finer/smaller granularity)

Switch the order of --arch and --target

Revert the version of backends/p4tools/modules/smith/scripts/compilation-test.sh back to the commit d34f60e, and switch the order of core and generic in backends/p4tools/modules/smith/targets/generic/test/P4Tests.cmake

Modify the argument settings for multiple targets and architectures

Attempt to make sure that only primitive-type parameters are used when generating the parameter list for the BMv2 portion of the fuzzer

Fix the previous erroneous treatment of "bmv2" from archName to deviceName

Add TODOs to remind myself to revert `out_$i.p4` back to `out.p4` to
avoid dumping too many generated files after the debugging process

1. Instead of adding target-specific check in the target-independent core, preliminarily override the virtual method in the BMv2 backend (still hasn't worked yet)

2. Get rid of  and expand the function signature of

Refactor the implemented inheritance pattern

Clang-format some source file

Fix a linter issue

Implement a mechanism to maintain a list of "known" bugs and not fail the test if those bugs occur

Modify the output-printing mechanism

Add another element to `KNOWN_BUGS`

Add an echo statement to display the encounted bug using the `is_known_bug` function

Modify echo statements

Preliminarily add code to generate an approriate return statement for `pna_pre_output_metadata_t`

Fix a linter issue

Add a TODO to fix the casting bug

Make use of `new IR::Type_Name`

Hard-code to attempt to resolve the casting issue

The current type casting is still erroneous

Add commented-out code that doesn't work and add TODOs

Fix linter issues

Resolve the infinite recursing issue

Improve the implementation to be modular (but still doesn't work)

Fix some auxillary issues

Refine type resolving

Refine recursive type resolving

Fix the "Arch '<null>' not supported by P4Runtime serializer" error

Specify the compiler binary with extentions in the corresponding P4Tests.cmake file instead of the bash script

Simplify the constructor Bmv2V1ModelDeclarationGenerator

Remove 128 from the accepted bitwidths in the Expression Generator for the dpdk taget

Activate `byte_align_headers` to `true` to support bit alignments

Add a known bug: `terminate called after throwing an instance of 'Util::CompilerBug'`

Modify the previously documented known bug to a fine-grained version

Make further attempts to resolve type resolving

Resolve a typo made previously

Further refine type resolving and remove redundant code

Implement explicit casting for `SecurityAssocId_t` for both assignment and return statements

Revert the type signature of `genStructListExpr` from `IR::Expression` back to `IR::ListExpression`

Revert the type signature of `getTypeByName` from `IR::Type` back to `IR::Type_Declaration`

Revert the type signature of `genStructListExpr` from `IR::Expression` back to `IR::ListExpression`

Preliminarily modify the previous type resolving/casting mechanism

Remove the previous added, redundant `genBitType` with different arguments than the default `genBitType`

Add print-outs to address the tuple-wrapping issue

Resolve the typing issue of `SecurityAssocId_t` in a more generic way

Make the bug documented in `KNOWN_BUGS` more generic

Experimentally migrate the `Bmv2V1ModelDeclarationGenerator` class and its constructor and (overridden) member function to declarations.cpp and declarations.h in the `bmv2` target

Experimentally migrate the `Bmv2V1ModelDeclarationGenerator` class and its constructor and (overridden) member function to declarations.cpp and declarations.h in the `bmv2` target

Fix linter issues from the previous commit(s)

Fix the issue caused by erroneously formatting backends/p4tools/modules/smith/targets/bmv2/CMakeLists.txt

Set `byte_align_headers` true for the `nic` target

Prohibit `128` from being a valid bit size for the `nic` target

Document a known bug in the script

Fix the previous linter issue(s)

Support to generate well-typed parameter lists for the `nic` target

Remove the hard-coded rhs-casting(s) of assignment generations

Add a TODO (to make the bitwidth a generic parameter)

1. Preliminarily make the bitwidth a generic parameter (by implementing a template function)

2. Document a known bug

Revert backends/p4tools/modules/smith/scripts/compilation-test.sh back to its original form since it is cluelessly `clang-format`ed

Reactivate the executable permission of backends/p4tools/modules/smith/scripts/compilation-test.sh

Preliminarily implement `pna_main_parser_input_metadata_t`'s field generations (although `enum` is not supported right now)

Rename the previous `Bmv2V1ModelDeclarationGenerator` class to `Bmv2ModelDeclarationGenerator` and apply it (and its members) to the `psa` arch

1. Add a struct member in the `Constraints` struct to limit the maximum bit width (default value: 128)

2. Set it to 64 for the pna arch, dpdk target

Fixups.

Signed-off-by: zzmic <100326374+zzmic@users.noreply.github.com>
Signed-off-by: fruffy <fruffy@nyu.edu>
Signed-off-by: fruffy <fruffy@nyu.edu>
@fruffy fruffy force-pushed the compilation-test-support branch from c4203c4 to e230835 Compare August 26, 2024 07:59
@fruffy fruffy added this pull request to the merge queue Aug 26, 2024
Merged via the queue into p4lang:main with commit ceb8a9e Aug 26, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4tools Topics related to the P4Tools back end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants