[P4-dev] Floating point support in P4

hemant at mnkcg.com hemant at mnkcg.com
Mon Sep 3 11:56:11 EDT 2018


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 <mailto: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 <mailto:p4-dev-bounces at lists.p4.org> > on behalf of Zhenyu Zhou <zzy at cs.duke.edu <mailto:zzy at cs.duke.edu> >
Sent: Sunday, September 2, 2018 8:52:17 PM
To: p4-dev at lists.p4.org <mailto: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, 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) 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/7747b744/attachment.html>


More information about the P4-dev mailing list