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

Support for 128 bit bitwise operation #4952

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

Conversation

Sosutha
Copy link
Contributor

@Sosutha Sosutha commented Oct 9, 2024

  • Added movh statement definition
  • Added support for 128 bitwise operation
  • Updated testcase and output

Copy link
Contributor

@psivanup psivanup left a comment

Choose a reason for hiding this comment

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

Please check the comments

}
}
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it valid input to have operand1 of 128 bits and operand2 less than 128 bits at this stage?
If true, isValidOperandSize in line number 1106 may issue error for operand being greater than 64 bits.
IMO, isValidOperandSize function can be parameterized to check limit of 128 bits in exceptional cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only operations where both operands are of size 128 bits are being supported for now.

Copy link
Contributor

@ChrisDodd ChrisDodd Oct 9, 2024

Choose a reason for hiding this comment

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

Typechecking will ensure that the operands to any binary operation like these are the exact same type, so there's really no need to check both. The only binops that can have different types for their operands are shifts, array index, and concat. If you want to be paranoid, you can BUG_CHECK(src1Op->type == src2Op->type, ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the code.

backends/dpdk/dpdkHelpers.cpp Outdated Show resolved Hide resolved
fields->push_back(new IR::StructField("tmp", IR::Type_Bits::get(64)));
const IR::Type_Header *headerStruct = new IR::Type_Header(IR::ID("tmp128_t"), *fields);
auto name = new cstring("tmp128_t");
structure->header_types.emplace(*name, headerStruct);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
structure->header_types.emplace(*name, headerStruct);
structure->header_types.emplace(cstring("tmp128_t"), headerStruct);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the code

@Sosutha Sosutha force-pushed the dpdk_128_bit_support branch 3 times, most recently from e20762a to 30b7c86 Compare October 9, 2024 10:45
@fruffy fruffy added the dpdk Topics related to the DPDK back end label Oct 9, 2024
@KrisNey-MSFT
Copy link

KrisNey-MSFT commented Oct 9, 2024

Suggest to try to compile DASH code as a test of completeness to see if the code compiles/builds? If DASH has other than bitwise operations, it may fail. Do not support additions to IPv6 addresses (we would likely not do this), but all else s/be supported. Can we add @jafingerhut as a reviewer please?

@Sosutha Sosutha force-pushed the dpdk_128_bit_support branch 5 times, most recently from 015e0a9 to 80518e8 Compare October 10, 2024 12:50
@jafingerhut
Copy link
Contributor

jafingerhut commented Oct 10, 2024

Updated on 2024-Oct-10 to correct the p4c-dpdk command line options. I still get errors saying 'Unupported bitwidth 128' in them with the updated command line.

I tried checking out this modified branch of the code, and built p4c-dpdk, then tried the following commands:

git clone https://github.com/sonic-net/DASH
cd DASH/dash-pipeline/bmv2
mkdir -p output
p4c-dpdk -DTARGET_DPDK_PNA -DPNA_CONNTRACK --pp output/dash_pipeline.pp.p4 \
        -o output/dash_pipeline.spec --arch pna \
        --bf-rt-schema output/dash_pipeline.p4.bfrt.json \
        --p4runtime-files output/dash_pipeline.p4.p4info.txt \
        dash_pipeline.p4

I see many warnings, which are unrelated to these changes, but I also see 7 errors "Unsupported bitwidth 128" as copied below:

stages/../dash_routing_types.p4(130): [--Werror=target-error] error: Unsupported bitwidth 128 in underlay_sip
                            underlay_sip = underlay_sip == 0 ? hdr.u0_ipv4.src_addr : (IPv4Addres...
                                           ^^^^^^^^^^^^
stages/../dash_routing_types.p4(130): [--Werror=target-error] error: Unsupported bitwidth 128 in 128w0
...                underlay_sip = underlay_sip == 0 ? hdr.u0_ipv4.src_addr : (IPv4Address)underla...
                                                  ^
stages/../dash_routing_types.p4(131): [--Werror=target-error] error: Unsupported bitwidth 128 in underlay_dip
                            underlay_dip = underlay_dip == 0 ? hdr.u0_ipv4.dst_addr : (IPv4Addres...
                                           ^^^^^^^^^^^^
stages/../dash_routing_types.p4(131): [--Werror=target-error] error: Unsupported bitwidth 128 in 128w0
...                underlay_dip = underlay_dip == 0 ? hdr.u0_ipv4.dst_addr : (IPv4Address)underla...
                                                  ^
stages/../dash_routing_types.p4(203): [--Werror=target-error] error: Unsupported bitwidth 128 in overlay_sip_mask
...( (IPv6Address)hdr.u0_ipv4.src_addr & ~overlay_sip_mask) | overlay_sip) & ~meta.eni_data.pl_si...
                                          ^^^^^^^^^^^^^^^^
[--Werror=target-error] error: Unsupported bitwidth 128 in meta._eni_data_pl_sip_mask20
dash_pipeline.p4(229): [--Werror=target-error] error: Unsupported bitwidth 128 in meta._overlay_data_dip_mask112
        routing_action_apply.apply(hdr, meta);
                                        ^^^^
dash_pipeline.p4(229): [--Werror=target-error] error: Unsupported bitwidth 128 in meta._overlay_data_sip_mask111
        routing_action_apply.apply(hdr, meta);
                                        ^^^^

Do you see these as well, Sosutha?

It would be good to understand why these errors occur, and if possible, either modify this PR so that those errors do not occur, or figure out a modified version of the DASH program that behaves as it is written today, but does not give those errors.

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.

This PR should not be merged until the compilator for https://github.com/p4lang/p4c/blob/main/testdata/p4_16_samples/dash/dash-pipeline-pna-dpdk.p4 passes

Signed-off-by: Sosutha Sethuramapandian
<sosutha.sethuramapandian@intel.com>

* Added movh statement definition
* Added support for 128 bitwise operation
* Updated testcase and output
@Sosutha
Copy link
Contributor Author

Sosutha commented Oct 11, 2024

p4_16_samples/dash/dash-pipeline-pna-dpdk.p4

Andy, I am getting same errors as you. This PR addresses only 128 bitwise operations. I can add implementation for comparison operations to this same PR. So errors related to that will be solved with that implementation. For error in apply statement, I will have to check and revert back

@fruffy
Copy link
Collaborator

fruffy commented Oct 12, 2024

p4_16_samples/dash/dash-pipeline-pna-dpdk.p4

Andy, I am getting same errors as you. This PR addresses only 128 bitwise operations. I can add implementation for comparison operations to this same PR. So errors related to that will be solved with that implementation. For error in apply statement, I will have to check and revert back

We can also add the failing compilation to XFails for now. The important part is that this program is added as a test that is checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dpdk Topics related to the DPDK back end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants