From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: <dev@dpdk.org>
Subject: Re: [PATCH v7 2/3] cmdline: add floating point support
Date: Thu, 8 May 2025 12:09:04 +0200 [thread overview]
Message-ID: <dbdebfcc-0ba5-4ca2-8040-0ee347de175c@intel.com> (raw)
In-Reply-To: <e80092cfd3ce9f28a3c720a0f0ffca0c511ec0e2.1746698489.git.anatoly.burakov@intel.com>
On 5/8/2025 12:01 PM, Anatoly Burakov wrote:
> Add support for parsing floating point numbers in cmdline library, as well
> as unit tests for the new functionality. Use C library for parsing.
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>
> Notes:
v6 -> v7:
- Fixed a bug in float compare in unit tests where a bigger epsilon
value than necessary was "needed" because we were comparing float
result to a double result
> v5 -> v6:
> - Small refactor to reduce amount of noise
> - Use strtof for parsing single precision floats
> - More unit tests
>
> v4 -> v5:
> - Reworked to use standard C library functions as much as possible,
> keeping near-100% compatibility with earlier versions (the only
> difference is that strings like "+4" are now considered valid)
>
> v3 -> v4:
> - Removed unnecessary check for integer overflow when parsing negative
> floats (as we convert to double before changing sign)
> - Make naming of float exponent states more consistent
>
> v2 -> v3:
> - Fixed a bug where a free-standing negative exponent ("1e-") would attempt to be
> parsed, and added unit tests for this case
> - Added support for floats in dpdk-cmdline-gen script
> - Added documentation updates to call out float support
>
> app/test/test_cmdline_num.c | 284 ++++++++++++++++++++++++-
> buildtools/dpdk-cmdline-gen.py | 24 ++-
> doc/guides/prog_guide/cmdline.rst | 3 +
> doc/guides/rel_notes/release_25_07.rst | 5 +
> lib/cmdline/cmdline_parse_num.c | 67 +++++-
> lib/cmdline/cmdline_parse_num.h | 4 +-
> 6 files changed, 368 insertions(+), 19 deletions(-)
>
...but forgot to remove the comment:
> +static int
> +float_cmp(double expected, void *actual_p, enum cmdline_numtype type)
> +{
> + double eps;
> + double actual_d;
> +
> + if (type == RTE_FLOAT_SINGLE) {
> + /* read as float, convert to double */
> + actual_d = (double)*(float *)actual_p;
> + /* downcast expected to float as well */
> + expected = (double)(float)expected;
> + /* FLT_EPSILON is too small for some tests */
Please fix this on apply if there is no v8, thanks :)
> + eps = FLT_EPSILON;
> + } else {
> + /* read as double */
> + actual_d = *(double *)actual_p;
> + eps = DBL_EPSILON;
> + }
> + /* compare using epsilon value */
> + if (fabs(expected - actual_d) < eps)
> + return 0;
> + /* not equal */
> + return expected < actual_d ? -1 : 1;
> +}
> +
--
Thanks,
Anatoly
next prev parent reply other threads:[~2025-05-08 10:10 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 12:27 [PATCH v1 1/1] app/testpmd: add sleep command Anatoly Burakov
2025-05-02 12:37 ` Bruce Richardson
2025-05-02 14:35 ` Burakov, Anatoly
2025-05-02 14:43 ` Bruce Richardson
2025-05-02 15:33 ` Morten Brørup
2025-05-02 15:42 ` Stephen Hemminger
2025-05-06 12:36 ` Burakov, Anatoly
2025-05-06 13:08 ` [PATCH v2 1/2] cmdline: add floating point support Anatoly Burakov
2025-05-06 13:08 ` [PATCH v2 2/2] app/testpmd: add sleep command Anatoly Burakov
2025-05-06 13:38 ` [PATCH v2 1/2] cmdline: add floating point support Bruce Richardson
2025-05-07 9:02 ` Burakov, Anatoly
2025-05-07 9:50 ` [PATCH v3 " Anatoly Burakov
2025-05-07 9:50 ` [PATCH v3 2/2] app/testpmd: add sleep command Anatoly Burakov
2025-05-07 9:53 ` [PATCH v3 1/2] cmdline: add floating point support Burakov, Anatoly
2025-05-07 10:01 ` [PATCH v4 " Anatoly Burakov
2025-05-07 10:01 ` [PATCH v4 2/2] app/testpmd: add sleep command Anatoly Burakov
2025-05-07 10:35 ` [PATCH v4 1/2] cmdline: add floating point support Konstantin Ananyev
2025-05-07 11:06 ` Burakov, Anatoly
2025-05-07 12:24 ` Konstantin Ananyev
2025-05-07 14:06 ` Burakov, Anatoly
2025-05-07 15:22 ` [PATCH v5 1/3] cmdline: use C standard library as number parser Anatoly Burakov
2025-05-07 15:22 ` [PATCH v5 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-07 15:22 ` [PATCH v5 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-08 7:27 ` [PATCH v5 1/3] cmdline: use C standard library as number parser Bruce Richardson
2025-05-08 8:35 ` Burakov, Anatoly
2025-05-08 9:53 ` [PATCH v6 " Anatoly Burakov
2025-05-08 9:53 ` [PATCH v6 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-08 9:53 ` [PATCH v6 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-08 10:01 ` [PATCH v7 1/3] cmdline: use C standard library as number parser Anatoly Burakov
2025-05-08 10:01 ` [PATCH v7 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-08 10:09 ` Burakov, Anatoly [this message]
2025-05-08 10:01 ` [PATCH v7 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-08 13:16 ` [PATCH v8 1/3] cmdline: use C standard library as number parser Anatoly Burakov
2025-05-08 13:16 ` [PATCH v8 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-08 13:16 ` [PATCH v8 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-09 13:02 ` [PATCH v8 1/3] cmdline: use C standard library as number parser Burakov, Anatoly
2025-05-09 13:08 ` Burakov, Anatoly
2025-05-09 13:27 ` Burakov, Anatoly
2025-05-09 13:39 ` [PATCH v9 " Anatoly Burakov
2025-05-09 13:39 ` [PATCH v9 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-09 13:39 ` [PATCH v9 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-09 13:42 ` [PATCH v9 1/3] cmdline: use C standard library as number parser Burakov, Anatoly
2025-05-09 14:41 ` [PATCH v10 " Anatoly Burakov
2025-05-09 14:41 ` [PATCH v10 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-09 14:41 ` [PATCH v10 3/3] app/testpmd: add sleep command Anatoly Burakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dbdebfcc-0ba5-4ca2-8040-0ee347de175c@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).