[P4-dev] Floating point support in P4

Zhenyu Zhou zzy at cs.duke.edu
Mon Sep 3 12:04:22 EDT 2018


Hello Hemant,

Thanks for the fantastic explanation! It helps me understand P4 perfectly
and totally makes sense to me!

Zhenyu





On Mon, Sep 3, 2018 at 11:56 AM <hemant at mnkcg.com> wrote:

> Zhenyu,
>
>
>
> The P4 compiler (p4c) has a backend which is platform-specific.  A
> hardware platform (e.g. switching asic) implements the p4c backend.  If a
> platform does not support certain operations, the p4c backend should raise
> an error and fail to compile the P4 program.
>
>
>
> Hemant
>
>
>
> *From:* P4-dev <p4-dev-bounces at lists.p4.org> *On Behalf Of *Zhenyu Zhou
> *Sent:* Monday, September 03, 2018 10:42 AM
> *To:* mbudiu at vmware.com
> *Cc:* p4-dev at lists.p4.org
> *Subject:* Re: [P4-dev] Floating point support in P4
>
>
>
> Hello Mihai,
>
>
>
> Thank you so much for the reply! It sounds like that even integer division
> and multiplication cannot be guaranteed. So may I ask what if it is not
> supported? How can we know whether it's supported or not, and if not, what
> happens if we still install such P4 program? (I believe this should be
> common knowledge for the P4 community, please forgive my stupid question.)
>
>
>
> Zhenyu
>
>
>
>
>
>
>
> On Sun, Sep 2, 2018 at 11:54 PM Mihai Budiu <mbudiu at vmware.com> wrote:
>
> There is no fp datatype in p4. Even in C you can do integer divison and
> multiplication using these operators. Note that in p4 these are only
> guaranteed to be compile-time integer operations, a specific device may not
> support them at all.
>
>
>
> Mihai
>
>
> ------------------------------
>
> *From:* P4-dev <p4-dev-bounces at lists.p4.org> on behalf of Zhenyu Zhou <
> zzy at cs.duke.edu>
> *Sent:* Sunday, September 2, 2018 8:52:17 PM
> *To:* p4-dev at lists.p4.org
> *Subject:* [P4-dev] Floating point support in P4
>
>
>
> Hello,
>
>
>
> I'm new to p4 and have a question regarding p4: does it support floating
> point calculations? Say, floating point multiplication and division (eg.
> 0.9*0.3 = 0.27).
>
>
>
> I find this video (https://www.youtube.com/watch?v=U3Mn6o2j4zQ
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__na01.safelinks.protection.outlook.com_-3Furl-3Dhttps-253A-252F-252Fwww.youtube.com-252Fwatch-253Fv-253DU3Mn6o2j4zQ-26data-3D02-257C01-257Cmbudiu-2540vmware.com-257C203b3da1ffe346d6e62008d611505c3a-257Cb39138ca3cee4b4aa4d6cd83d9dd62f0-257C1-257C0-257C636715434173849832-26sdata-3DXkk7MFkZvboyKMd46IQJSzvQU46Mspv6oGhnCKbi-252FH8-253D-26reserved-3D0&d=DwMFJg&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=Kqghso_RsUpNgH0awiGhJw&m=DJmsXirKLZPmsnwmI3sdkzcYhbfwyFd48S_ocqxhqCk&s=2e8ro9WbESLO-6R8_UYomP0M9BquE7ReYCLk67kYXGY&e=>,
> 16min20s) suggesting that floating point is not supported. But the spec (
> https://p4.org/p4-spec/docs/P4-16-v1.0.0-spec.html#sec-expr-eval-order
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__na01.safelinks.protection.outlook.com_-3Furl-3Dhttps-253A-252F-252Fp4.org-252Fp4-2Dspec-252Fdocs-252FP4-2D16-2Dv1.0.0-2Dspec.html-2523sec-2Dexpr-2Deval-2Dorder-26data-3D02-257C01-257Cmbudiu-2540vmware.com-257C203b3da1ffe346d6e62008d611505c3a-257Cb39138ca3cee4b4aa4d6cd83d9dd62f0-257C1-257C0-257C636715434173849832-26sdata-3Dy5t1pIn8tHnfHtDgVJKYNAZyY3I8mVr2ZMg4Va-252BR1Jw-253D-26reserved-3D0&d=DwMFJg&c=imBPVzF25OnBgGmVOlcsiEgHoG1i6YHLR0Sj_gZ4adc&r=Kqghso_RsUpNgH0awiGhJw&m=DJmsXirKLZPmsnwmI3sdkzcYhbfwyFd48S_ocqxhqCk&s=kla6ekUJOGUV-sIyh3MP5NvJWjK8wV2KV6weH7XkQoY&e=>)
> says:
>
> expression
>
>     ......
>
>     | expression '*' expression
>
>     | expression '/' expression
>
>
>
> I'm kind of confused here. Any insights for this? Can I achieve
> such arithmetic?
>
>
>
> Thanks in advance!
>
>
>
> Zhenyu
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20180903/bf8b4034/attachment.html>


More information about the P4-dev mailing list