[P4-dev] Floating point support in P4
mbudiu at vmware.com
Sun Sep 2 23:54:42 EDT 2018
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.
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
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://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DU3Mn6o2j4zQ&data=02%7C01%7Cmbudiu%40vmware.com%7C203b3da1ffe346d6e62008d611505c3a%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636715434173849832&sdata=Xkk7MFkZvboyKMd46IQJSzvQU46Mspv6oGhnCKbi%2FH8%3D&reserved=0>, 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://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fp4.org%2Fp4-spec%2Fdocs%2FP4-16-v1.0.0-spec.html%23sec-expr-eval-order&data=02%7C01%7Cmbudiu%40vmware.com%7C203b3da1ffe346d6e62008d611505c3a%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636715434173849832&sdata=y5t1pIn8tHnfHtDgVJKYNAZyY3I8mVr2ZMg4Va%2BR1Jw%3D&reserved=0>) says:
| expression '*' expression
| expression '/' expression
I'm kind of confused here. Any insights for this? Can I achieve such arithmetic？
Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the P4-dev