eal: provide leading and trailing zero bit count
Subsystems (2)
cover eal: provide leading and trailing zero bit count
Provide leading and trailing zero bit count functions to abstract away compiler specific implementations.
Include basic unit test for new leading/trailing zero bit count functions.
Tyler Retzlaff (2):
eal: provide leading and trailing zero bit count abstraction test/bitcount: add bitcount tests
app/test/meson.build | 2 + app/test/test_bitcount.c | 92 +++++++++++++++ lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 257 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 352 insertions(+) create mode 100644 app/test/test_bitcount.c create mode 100644 lib/eal/include/rte_bitcount.h
Signature · 1 line
1.8.3.1
PATCH 1/2 eal: provide leading and trailing zero bit count abstraction
Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
--- lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 257 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 258 insertions(+) create mode 100644 lib/eal/include/rte_bitcount.h
lib/eal/include/meson.build +1 -0
@@ -5,6 +5,7 @@ includes += include_directories('.') headers += files( 'rte_alarm.h', + 'rte_bitcount.h', 'rte_bitmap.h', 'rte_bitops.h', 'rte_branch_prediction.h',
lib/eal/include/rte_bitcount.h new file +257 -0
257 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 15 lines · Tyler Retzlaff
Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>--- lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 257 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 258 insertions(+)create mode 100644
lib/eal/include/rte_bitcount.hlib/eal/include/meson.build +0
-0
lib/eal/include/meson.build includes += include_directories('.') · line 8
Quoted 4 lines
lib/eal/include/meson.build +1
-0@@ -5,6 +5,7 @@ includes += include_directories('.') headers += files( 'rte_alarm.h', + 'rte_bitcount.h',
Maybe rte_bitops.h should be the home of these new wrappers.
Quoted 23 lines
lib/eal/include/meson.build +0
-0'rte_bitmap.h', 'rte_bitops.h', 'rte_branch_prediction.h',lib/eal/include/rte_bitcount.h new file +14
-0@@ -0,0 +1,257 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022 Microsoft Corporation +*/ + +#ifndef EAL_BITCOUNT_H +#define EAL_BITCOUNT_H + +#include <rte_compat.h> + +#ifdef RTE_TOOLCHAIN_MSVC + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
lib/eal/include/rte_bitcount.h line 24
Quoted 10 lines
lib/eal/include/rte_bitcount.h new file +10
-0+* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned
unsigned int
If you want to be __builtin_clz()-compatible, you should stay with "int" as the return type.
If you don't, you might want to change more than just the return type. In particular, it would be useful to have size-specific variants (although in practice they are on most [all?] DPDK-supported platforms).
unsigned intrte_clz(uint32_t v);
or rte_clz32(), to follow the naming convention from some other wrapper RFC you posted.
Quoted 233 lines
lib/eal/include/rte_bitcount.h new file +233
-0+rte_clz(unsigned int v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned +rte_clzl (unsigned long v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned +rte_clzll (unsigned long long v) +{ +unsigned long rv; + + (void )_BitScanReverse64 (&rv, v); + +return (unsigned )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned +rte_ctz (unsigned int v) +{ +unsigned long rv; + + (void )_BitScanForward (&rv, v); + +return (unsigned )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned +rte_ctzl (unsigned long v) +{ +unsigned long rv; + + (void )_BitScanForward (&rv, v); + +return (unsigned )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned +rte_ctzll (unsigned long long v) +{ +unsigned long rv; + + (void )_BitScanForward64 (&rv, v); + +return (unsigned )rv; +} + +#else + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned +rte_clz (unsigned int v) +{ +return (unsigned )__builtin_clz (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned +rte_clzl (unsigned long v) +{ +return (unsigned )__builtin_clzl (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned +rte_clzll (unsigned long v) +{ +return (unsigned )__builtin_clzll (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned +rte_ctz (unsigned int v) +{ +return (unsigned )__builtin_ctz (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned +rte_ctzl (unsigned long v) +{ +return (unsigned )__builtin_ctzl (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned +rte_ctzll (unsigned long v) +{ +return (unsigned )__builtin_ctzll (v); +} + +#endif + +#endif /* EAL_BITCOUNT_H */ +
PATCH 2/2 test/bitcount: add bitcount tests
In reply to Tyler Retzlaffbasic unit test of following functions
rte_clz
rte_clzl
rte_clzll
rte_ctz
rte_ctzl
rte_ctzll
--- app/test/meson.build | 2 ++ app/test/test_bitcount.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 app/test/test_bitcount.c
app/test/meson.build +2 -0
@@ -13,6 +13,7 @@ test_sources = files( 'test_alarm.c', 'test_atomic.c', 'test_barrier.c', + 'test_bitcount.c', 'test_bitops.c', 'test_bitmap.c', 'test_bpf.c',
@@ -160,6 +161,7 @@ test_deps += ['bus_pci', 'bus_vdev'] fast_tests = [ ['acl_autotest', true, true], ['atomic_autotest', false, true], + ['bitcount_autotest', true, true], ['bitmap_autotest', true, true], ['bpf_autotest', true, true], ['bpf_convert_autotest', true, true],
app/test/test_bitcount.c new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
1.8.3.1
v2 cover eal: provide leading and trailing zero bit count
In reply to Tyler RetzlaffProvide leading and trailing zero bit count functions to abstract away compiler specific implementations.
Include basic unit test for new leading/trailing zero bit count functions.
v2:
* use unsigned int instead of unsigned (checkpatches)
* match multiple include guard naming convention to rte_common.h
* add explicit extern "C" linkage to rte_bitcount.h
note: not really needed but checkpatches required
* add missing space around '-'
Tyler Retzlaff (2):
eal: provide leading and trailing zero bit count abstraction test/bitcount: add bitcount tests
app/test/meson.build | 2 + app/test/test_bitcount.c | 92 ++++++++++++++ lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 265 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 360 insertions(+) create mode 100644 app/test/test_bitcount.c create mode 100644 lib/eal/include/rte_bitcount.h
Signature · 1 line
1.8.3.1
PATCH v2 1/2 eal: provide leading and trailing zero bit count abstraction
Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
--- lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 265 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+) create mode 100644 lib/eal/include/rte_bitcount.h
lib/eal/include/meson.build +1 -0
@@ -5,6 +5,7 @@ includes += include_directories('.') headers += files( 'rte_alarm.h', + 'rte_bitcount.h', 'rte_bitmap.h', 'rte_bitops.h', 'rte_branch_prediction.h',
lib/eal/include/rte_bitcount.h new file +265 -0
265 lines not on this page · raw message
Signature · 1 line
1.8.3.1
RE: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 8 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>---
Related functions already exist in lib/eal/include/rte_common.h.
If some functions are missing, it would be good to add them.
Also, it makes sense moving them out of rte_common.h.
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 9 lines · Morten Brørup
Quoted 8 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>---
let me unpack what is being asked for here.
Quoted 1 line
Related functions already exist in
lib/eal/include/rte_common.h.
i don't understand. are you saying these inline functions duplicate existing bit counting functionality? if so i'll relocate any you identify.
Quoted 2 lines
If some functions are missing, it would be good to add them.
the change here is to address a specific family of functions that are impeding portability of the rte_common.h header and nothing more.
i'm open to having a separate mail thread discussing what other functions we might want and whether to relocate code out of rte_common.h since that is likely to be a drawn out discussion it shouldn't be a blocking dependency of this series.
Quoted 2 lines
Also, it makes sense moving them out of
rte_common.h.
thanks!
RE: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 14 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 28 November 2022 18.14Quoted 9 lines · Morten Brørup
Quoted 8 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>---
Quoted 7 lines
let me unpack what is being asked for here.
Quoted 1 line
Related functions already exist in
lib/eal/include/rte_common.h.i don't understand. are you saying these inline functions duplicate existing bit counting functionality? if so i'll relocate any you identify.
Sorry about not being clear about my intentions with the feedback.
I'm not asking for anything; I only wanted to point at the similar family of functions in rte_common.h, to make sure that you were aware of them.
Quoted 4 lines
Quoted 3 lines
If some functions are missing, it would be good to add them.
Quoted 8 lines
the change here is to address a specific family of functions that are impeding portability of the
rte_common.hheader and nothing more.i'm open to having a separate mail thread discussing what other functions we might want and whether to relocate code out of
rte_common.h
since that is likely to be a drawn out discussion it shouldn't be a blocking dependency of this series.
I do not request any new functions; I'll leave it up to you to decide if anything would be good to add.
Quoted 5 lines
Quoted 3 lines
Also, it makes sense moving them out of
rte_common.h.thanks!
Thank you! Cleaning up is always appreciated.
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 18 lines · Morten Brørup
Quoted 18 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 28 November 2022 18.14Quoted 9 lines · Morten Brørup
Quoted 8 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>---
let me unpack what is being asked for here.
Quoted 1 line
Related functions already exist in
lib/eal/include/rte_common.h.
Quoted 7 lines
Quoted 3 lines
i don't understand. are you saying these inline functions duplicate existing bit counting functionality? if so i'll relocate any you identify.
Sorry about not being clear about my intentions with the feedback.
I'm not asking for anything; I only wanted to point at the similar family of functions in
rte_common.h, to make sure that you were aware of them.
oh! not a problem. i'm very keen to catch any mistakes, thought i had missed something.
Quoted 18 lines
Quoted 5 lines
Quoted 4 lines
If some functions are missing, it would be good to add them.
Quoted 8 lines
the change here is to address a specific family of functions that are impeding portability of the
rte_common.hheader and nothing more.i'm open to having a separate mail thread discussing what other functions we might want and whether to relocate code out of
rte_common.h
since that is likely to be a drawn out discussion it shouldn't be a blocking dependency of this series.I do not request any new functions; I'll leave it up to you to decide if anything would be good to add.
Quoted 2 lines
Quoted 2 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Also, it makes sense moving them out of
rte_common.h.thanks!
Thank you! Cleaning up is always appreciated.
yes, if i can get more rapid approvals there is a lot more in the pipeline. i'd like gain some momentum if possible.
ty
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
28/11/2022 18:27, Tyler Retzlaff:
Quoted 21 lines · Morten Brørup
Quoted 20 lines
Quoted 19 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 28 November 2022 18.14Quoted 7 lines · Morten Brørup
Quoted 7 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>let me unpack what is being asked for here.
Quoted 1 line
Related functions already exist in
lib/eal/include/rte_common.h.i don't understand. are you saying these inline functions duplicate existing bit counting functionality? if so i'll relocate any you identify.
Quoted 6 lines
Quoted 3 lines
Sorry about not being clear about my intentions with the feedback.
I'm not asking for anything; I only wanted to point at the similar family of functions in
rte_common.h, to make sure that you were aware of them.oh! not a problem. i'm very keen to catch any mistakes, thought i had missed something.
I think we should move all bit-related functions together. Please could you add another patch to your series moving "ms1b"/"bsf"/"fls" functions in this file?
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 24 lines · Thomas Monjalon
28/11/2022 18:27, Tyler Retzlaff:
Quoted 23 lines · Morten Brørup
Quoted 22 lines
Quoted 12 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 28 November 2022 18.14Quoted 7 lines · Morten Brørup
Quoted 7 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>Quoted 7 lines
let me unpack what is being asked for here.
Quoted 1 line
Related functions already exist in
lib/eal/include/rte_common.h.i don't understand. are you saying these inline functions duplicate existing bit counting functionality? if so i'll relocate any you identify.
Sorry about not being clear about my intentions with the feedback.
Quoted 10 lines
Quoted 4 lines
Quoted 1 line
I'm not asking for anything; I only wanted to point at the similar family of functions in
rte_common.h, to make sure that you were aware of them.oh! not a problem. i'm very keen to catch any mistakes, thought i had missed something.
I think we should move all bit-related functions together. Please could you add another patch to your series moving "ms1b"/"bsf"/"fls" functions in this file?
okay, so there is already a rte_bitops.h. i guess everything should go there including the leading/trailing count functions instead of adding a new header.
i'll introduce a new patch to the series that gathers the existing functions into rte_bitops.h and place the new functions there too.
thanks
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 36 lines · Tyler Retzlaff
Quoted 24 lines · Thomas Monjalon
28/11/2022 18:27, Tyler Retzlaff:
Quoted 23 lines · Morten Brørup
Quoted 22 lines
Quoted 12 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 28 November 2022 18.14Quoted 7 lines · Morten Brørup
Quoted 7 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>Quoted 7 lines
let me unpack what is being asked for here.
Quoted 1 line
Related functions already exist in
lib/eal/include/rte_common.h.i don't understand. are you saying these inline functions duplicate existing bit counting functionality? if so i'll relocate any you identify.
Sorry about not being clear about my intentions with the feedback.
Quoted 10 lines
Quoted 4 lines
Quoted 1 line
I'm not asking for anything; I only wanted to point at the similar family of functions in
rte_common.h, to make sure that you were aware of them.oh! not a problem. i'm very keen to catch any mistakes, thought i had missed something.
I think we should move all bit-related functions together. Please could you add another patch to your series moving "ms1b"/"bsf"/"fls" functions in this file?
Quoted 8 lines
okay, so there is already a
rte_bitops.h. i guess everything should go there including the leading/trailing count functions instead of adding a new header.i'll introduce a new patch to the series that gathers the existing functions into
rte_bitops.hand place the new functions there too.thanks
just as a further follow up, you do understand that this is technically an api break?
moving functions from rte_common.h to rte_bitops.h will make translation units that included only rte_common.h but used these functions will fail to compile without being updated to include rte_bitops.h.
anyway, i'll submit v3 with this change anyway.
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 19 lines · Tyler Retzlaff
Quoted 9 lines · Tyler Retzlaff
Quoted 8 lines
Quoted 2 lines
oh! not a problem. i'm very keen to catch any mistakes, thought i had missed something.
I think we should move all bit-related functions together. Please could you add another patch to your series moving "ms1b"/"bsf"/"fls" functions in this file?
Quoted 8 lines
okay, so there is already a
rte_bitops.h. i guess everything should go there including the leading/trailing count functions instead of adding a new header.i'll introduce a new patch to the series that gathers the existing functions into
rte_bitops.hand place the new functions there too.thanks
Quoted 8 lines
just as a further follow up, you do understand that this is technically an api break?
moving functions from
rte_common.htorte_bitops.hwill make translation units that included onlyrte_common.hbut used these functions will fail to compile without being updated to includerte_bitops.h.anyway, i'll submit v3 with this change anyway.
so when attempting to do this it became immediately obvious that moving just the bit op functions out is going to create a circular dependency between rte_common.h, rte_bitops.h
once the bit ops are moved out of common there are still other inline functions that remain in comman that require bringing bitops back in, but bitops depends on common.
my compromise will be to break log2 and pow2 inline functions into their own files to break the cycle (common no longer depends on bitops). i'll submit patches for this but it ends up touching a lot more of the tree to add back includes for log/pow inline use.
alternatively i can just not move the remaining bit manipulation functions, let me know which is preferred.
thanks
RE: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 45 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 5 January 2023 21.58Quoted 2 lines · Tyler Retzlaff
Quoted 1 line · Tyler Retzlaff
Quoted 1 line
Quoted 1 line
oh! not a problem. i'm very keen to catch any mistakes, thought
i had
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 1 line
missed something.
I think we should move all bit-related functions together. Please could you add another patch to your series moving "ms1b"/"bsf"/"fls" functions in this file?
okay, so there is already a
rte_bitops.h. i guess everything shouldgo
Quoted 1 line
Quoted 1 line
there including the leading/trailing count functions instead of
adding a
Quoted 8 lines
Quoted 6 lines
new header.
i'll introduce a new patch to the series that gathers the existing functions into
rte_bitops.hand place the new functions there too.thanks
just as a further follow up, you do understand that this is
technically
Quoted 3 lines
an api break?
moving functions from
rte_common.htorte_bitops.hwill maketranslation
Quoted 4 lines
units that included only
rte_common.hbut used these functions will fail to compile without being updated to includerte_bitops.h.anyway, i'll submit v3 with this change anyway.
so when attempting to do this it became immediately obvious that moving just the bit op functions out is going to create a circular dependency between
rte_common.h,rte_bitops.honce the bit ops are moved out of common there are still other inline functions that remain in comman that require bringing bitops back in, but bitops depends on common.
Quoted 8 lines
my compromise will be to break log2 and pow2 inline functions into their
own files to break the cycle (common no longer depends on bitops). i'll submit patches for this but it ends up touching a lot more of the tree to add back includes for log/pow inline use.alternatively i can just not move the remaining bit manipulation functions, let me know which is preferred.
It seems that no perfect solution exists, so we will have to live with a compromise. Here is another proposal for a compromise, for yours and Thomas's consideration:
I noticed that rte_bitops.h is mainly for setting/getting bits, used for accessing hardware.
Your functions are mathematical functions, and so are the similar functions in rte_common.h (which is why it makes sense to keep them together with yours). If we cannot clean up rte_common.h by moving them out, perhaps we should accept the current situation (until we find a way to move them out) and just add your mathematical functions where the existing mathematical functions reside, i.e. in rte_common.h.
This proposal only makes the existing mess slightly larger; it doesn't create a new kind of mess.
-Morten
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 54 lines · Morten Brørup
Quoted 45 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 5 January 2023 21.58Quoted 2 lines · Tyler Retzlaff
Quoted 1 line · Tyler Retzlaff
Quoted 1 line
Quoted 1 line
oh! not a problem. i'm very keen to catch any mistakes, thought
i had
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 1 line
missed something.
I think we should move all bit-related functions together. Please could you add another patch to your series moving "ms1b"/"bsf"/"fls" functions in this file?
okay, so there is already a
rte_bitops.h. i guess everything shouldgo
Quoted 1 line
Quoted 1 line
there including the leading/trailing count functions instead of
adding a
Quoted 8 lines
Quoted 6 lines
new header.
i'll introduce a new patch to the series that gathers the existing functions into
rte_bitops.hand place the new functions there too.thanks
just as a further follow up, you do understand that this is
technically
Quoted 3 lines
an api break?
moving functions from
rte_common.htorte_bitops.hwill maketranslation
Quoted 4 lines
units that included only
rte_common.hbut used these functions will fail to compile without being updated to includerte_bitops.h.anyway, i'll submit v3 with this change anyway.
so when attempting to do this it became immediately obvious that moving just the bit op functions out is going to create a circular dependency between
rte_common.h,rte_bitops.honce the bit ops are moved out of common there are still other inline functions that remain in comman that require bringing bitops back in, but bitops depends on common.
Quoted 8 lines
my compromise will be to break log2 and pow2 inline functions into their
own files to break the cycle (common no longer depends on bitops). i'll submit patches for this but it ends up touching a lot more of the tree to add back includes for log/pow inline use.alternatively i can just not move the remaining bit manipulation functions, let me know which is preferred.
Quoted 7 lines
It seems that no perfect solution exists, so we will have to live with a compromise. Here is another proposal for a compromise, for yours and Thomas's consideration:
I noticed that
rte_bitops.his mainly for setting/getting bits, used for accessing hardware.Your functions are mathematical functions, and so are the similar functions in
rte_common.h(which is why it makes sense to keep them together with yours). If we cannot clean uprte_common.hby moving them out, perhaps we should accept the current situation (until we find a way to move them out) and just add your mathematical functions where the existing mathematical functions reside, i.e. inrte_common.h.This proposal only makes the existing mess slightly larger; it doesn't create a new kind of mess.
so i fudged around a bit to see if i could get a happy medium. i ended up with this.
remove include of rte_debug.h from rte_bitops.h
* had to remove the RTE_ASSERT from existing rte_bitops.h functions
* this breaks a good piece of the cycle debug -> log -> common -> bitops -> debug
* deal breaker? i don't think it was right that we were getting all of log, common just for using bitops anyway.
move pow2 functions from rte_common.h -> rte_pow2ops.h
* new header includes rte_bitops.h
move log2 functions from rte_common.h -> rte_log2ops.h
* new header includes rte_bitops.h, rte_pow2ops.h
include rte_bitops.h, rte_pow2ops.h and rte_log2ops.h back into rte_common.h
* this is done to reduce the impact of compatibility break by continuing to expose the pow2/log2/bitops via rte_common.h
so we end up with 3 standalone headers, where the whole tree builds without having to add a pile of includes for the new headers. we can later deprecate the exposure of the inline functions when including rte_common.h
* one caveat is that there was some contamination coming in via the removed rte_debug.h where rte_bitops.h was used. so technically a break of api too.
objections?
if this is no good i'll just fold my new functions into rte_common.h and leave the mess for the next person, though i am trying not to do that.
thanks for the discussion.
RE: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 117 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 5 January 2023 23.06Quoted 6 lines · Morten Brørup
Quoted 6 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 5 January 2023 21.58Quoted 2 lines · Tyler Retzlaff
Quoted 1 line · Tyler Retzlaff
Quoted 1 line
Quoted 1 line
oh! not a problem. i'm very keen to catch any mistakes,
thought
Quoted 10 lines
Quoted 10 lines
i had
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 1 line
missed something.
I think we should move all bit-related functions together. Please could you add another patch to your series moving "ms1b"/"bsf"/"fls" functions in this file?
okay, so there is already a
rte_bitops.h. i guess everythingshould
Quoted 6 lines
Quoted 6 lines
go
Quoted 1 line
Quoted 1 line
there including the leading/trailing count functions instead of
adding a
Quoted 3 lines
Quoted 3 lines
new header.
i'll introduce a new patch to the series that gathers the
existing
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
functions into
rte_bitops.hand place the new functions theretoo.
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 2 lines
thanks
just as a further follow up, you do understand that this is
technically
Quoted 3 lines
an api break?
moving functions from
rte_common.htorte_bitops.hwill maketranslation
Quoted 1 line
units that included only
rte_common.hbut used these functionswill
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
fail to compile without being updated to include
rte_bitops.h.anyway, i'll submit v3 with this change anyway.
so when attempting to do this it became immediately obvious that
moving
Quoted 1 line
Quoted 1 line
just the bit op functions out is going to create a circular
dependency
Quoted 3 lines
Quoted 3 lines
between
rte_common.h,rte_bitops.honce the bit ops are moved out of common there are still other
inline
Quoted 1 line
Quoted 1 line
functions that remain in comman that require bringing bitops back
in,
Quoted 5 lines
Quoted 5 lines
but bitops depends on common.
my compromise will be to break log2 and pow2 inline functions into their
own files to break the cycle (common no longer depends on bitops).i'll
Quoted 7 lines
Quoted 5 lines
submit patches for this but it ends up touching a lot more of the tree to add back includes for log/pow inline use.
alternatively i can just not move the remaining bit manipulation functions, let me know which is preferred.
It seems that no perfect solution exists, so we will have to live
with a compromise. Here is another proposal for a compromise, for yours and Thomas's consideration:
Quoted 2 lines
I noticed that
rte_bitops.his mainly for setting/getting bits, usedfor accessing hardware.
Quoted 2 lines
Your functions are mathematical functions, and so are the similar
functions in
rte_common.h(which is why it makes sense to keep them together with yours). If we cannot clean uprte_common.hby moving them out, perhaps we should accept the current situation (until we find a way to move them out) and just add your mathematical functions where the existing mathematical functions reside, i.e. inrte_common.h.Quoted 2 lines
This proposal only makes the existing mess slightly larger; it
doesn't create a new kind of mess.
so i fudged around a bit to see if i could get a happy medium. i ended up with this.
remove include of
rte_debug.hfromrte_bitops.h* had to remove the
RTE_ASSERTfrom existingrte_bitops.hfunctions
* this breaks a good piece of the cycle debug -> log -> common ->
bitops -> debug
* deal breaker? i don't think it was right that we were getting all of log, common just for using bitops anyway.move pow2 functions from
rte_common.h->rte_pow2ops.h
* new header includesrte_bitops.hmove log2 functions from
rte_common.h->rte_log2ops.h
* new header includesrte_bitops.h,rte_pow2ops.hinclude
rte_bitops.h,rte_pow2ops.handrte_log2ops.hback intorte_common.h* this is done to reduce the impact of compatibility break by continuing to expose the pow2/log2/bitops via
rte_common.hso we end up with 3 standalone headers, where the whole tree builds without having to add a pile of includes for the new headers. we can later deprecate the exposure of the inline functions when including
rte_common.h* one caveat is that there was some contamination coming in via the removed
rte_debug.hwhererte_bitops.hwas used. so technically a break of api too.
Quoted 7 lines
objections?
if this is no good i'll just fold my new functions into
rte_common.hand
leave the mess for the next person, though i am trying not to do that.thanks for the discussion.
Here's some long term thinking: EAL has grown into a trashcan where too much is thrown in. It should only be a thin shim to abstract the underlying hardware and O/S environment. A step in that direction could be splitting the current EAL into a true EAL and a Utils library. Not now, but perhaps some day in a rosy future.
Your proposal effectively makes rte_common.h even bigger by including rte_bitops.h (which was intended for accessing hardware). I am not sure it is a step in the right direction. On the other hand, introducing yet another header file for bit-mathematical functions is probably worse than adding them to rte_bitops.h.
I can't come up with something good myself, but I lean towards simply adding your functions to rte_common.h and live with the existing mess. If you think your proposal is better, I will not object. I'm only voicing my thoughts.
@Thomas may have another perspective on the matter.
Thanks for all the work you put into this.
-Morten
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 43 lines · Morten Brørup
Quoted 43 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 5 January 2023 23.06doesn't create a new kind of mess.
so i fudged around a bit to see if i could get a happy medium. i ended up with this.
remove include of
rte_debug.hfromrte_bitops.h* had to remove the
RTE_ASSERTfrom existingrte_bitops.hfunctions
* this breaks a good piece of the cycle debug -> log -> common ->
bitops -> debug
* deal breaker? i don't think it was right that we were getting all of log, common just for using bitops anyway.move pow2 functions from
rte_common.h->rte_pow2ops.h
* new header includesrte_bitops.hmove log2 functions from
rte_common.h->rte_log2ops.h
* new header includesrte_bitops.h,rte_pow2ops.hinclude
rte_bitops.h,rte_pow2ops.handrte_log2ops.hback intorte_common.h* this is done to reduce the impact of compatibility break by continuing to expose the pow2/log2/bitops via
rte_common.hso we end up with 3 standalone headers, where the whole tree builds without having to add a pile of includes for the new headers. we can later deprecate the exposure of the inline functions when including
rte_common.h* one caveat is that there was some contamination coming in via the removed
rte_debug.hwhererte_bitops.hwas used. so technically a break of api too.objections?
if this is no good i'll just fold my new functions into
rte_common.hand
leave the mess for the next person, though i am trying not to do that.
Quoted 7 lines
Quoted 1 line
thanks for the discussion.
Here's some long term thinking: EAL has grown into a trashcan where too much is thrown in. It should only be a thin shim to abstract the underlying hardware and O/S environment. A step in that direction could be splitting the current EAL into a true EAL and a Utils library. Not now, but perhaps some day in a rosy future.
Your proposal effectively makes
rte_common.heven bigger by includingrte_bitops.h(which was intended for accessing hardware). I am not sure it is a step in the right direction. On the other hand, introducing yet another header file for bit-mathematical functions is probably worse than adding them torte_bitops.h.I can't come up with something good myself, but I lean towards simply adding your functions to
rte_common.hand live with the existing mess. If you think your proposal is better, I will not object. I'm only voicing my thoughts.
it's hard when we are starting with something monolithic and trying to split it. you always end up with these iterative transitions toward what you want because you have to keep some kind of compat.
Quoted 2 lines
@Thomas may have another perspective on the matter.
Thomas any last word after this back and forth? This change isn't necessarily blocking me but is a distraction i'd like to finish/offload.
Quoted 2 lines
Thanks for all the work you put into this.
np, it is somewhat out of necessity since i need this stuff to be portable. but having it move in the right direction at the same time is a benefit for anyone who comes later.
ty
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
06/01/2023 02:04, Tyler Retzlaff:
Quoted 57 lines · Morten Brørup
Quoted 43 lines
Quoted 43 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 5 January 2023 23.06doesn't create a new kind of mess.
so i fudged around a bit to see if i could get a happy medium. i ended up with this.
remove include of
rte_debug.hfromrte_bitops.h* had to remove the
RTE_ASSERTfrom existingrte_bitops.hfunctions
* this breaks a good piece of the cycle debug -> log -> common ->
bitops -> debug
* deal breaker? i don't think it was right that we were getting all of log, common just for using bitops anyway.move pow2 functions from
rte_common.h->rte_pow2ops.h
* new header includesrte_bitops.hmove log2 functions from
rte_common.h->rte_log2ops.h
* new header includesrte_bitops.h,rte_pow2ops.hinclude
rte_bitops.h,rte_pow2ops.handrte_log2ops.hback intorte_common.h* this is done to reduce the impact of compatibility break by continuing to expose the pow2/log2/bitops via
rte_common.hso we end up with 3 standalone headers, where the whole tree builds without having to add a pile of includes for the new headers. we can later deprecate the exposure of the inline functions when including
rte_common.h* one caveat is that there was some contamination coming in via the removed
rte_debug.hwhererte_bitops.hwas used. so technically a break of api too.objections?
if this is no good i'll just fold my new functions into
rte_common.hand
leave the mess for the next person, though i am trying not to do that.Quoted 7 lines
Quoted 1 line
thanks for the discussion.
Here's some long term thinking: EAL has grown into a trashcan where too much is thrown in. It should only be a thin shim to abstract the underlying hardware and O/S environment. A step in that direction could be splitting the current EAL into a true EAL and a Utils library. Not now, but perhaps some day in a rosy future.
Your proposal effectively makes
rte_common.heven bigger by includingrte_bitops.h(which was intended for accessing hardware). I am not sure it is a step in the right direction. On the other hand, introducing yet another header file for bit-mathematical functions is probably worse than adding them torte_bitops.h.I can't come up with something good myself, but I lean towards simply adding your functions to
rte_common.hand live with the existing mess. If you think your proposal is better, I will not object. I'm only voicing my thoughts.it's hard when we are starting with something monolithic and trying to split it. you always end up with these iterative transitions toward what you want because you have to keep some kind of compat.
Quoted 1 line
Quoted 4 lines
Quoted 1 line
@Thomas may have another perspective on the matter.
Thomas any last word after this back and forth? This change isn't necessarily blocking me but is a distraction i'd like to finish/offload.
I think it is better to move all in rte_bitops.hrte_common must have almost zero dependency.
If log2 and pow2 are based on bitops operations, it is not a bad fit for rte_bitops.h.
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
In reply to Tyler Retzlaff05/01/2023 18:27, Tyler Retzlaff:
Quoted 37 lines · Tyler Retzlaff
Quoted 36 lines · Thomas Monjalon
Quoted 34 lines
28/11/2022 18:27, Tyler Retzlaff:
Quoted 21 lines · Morten Brørup
Quoted 20 lines
Quoted 19 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 28 November 2022 18.14Quoted 7 lines · Morten Brørup
Quoted 7 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>let me unpack what is being asked for here.
Quoted 1 line
Related functions already exist in
lib/eal/include/rte_common.h.i don't understand. are you saying these inline functions duplicate existing bit counting functionality? if so i'll relocate any you identify.
Quoted 6 lines
Quoted 3 lines
Sorry about not being clear about my intentions with the feedback.
I'm not asking for anything; I only wanted to point at the similar family of functions in
rte_common.h, to make sure that you were aware of them.oh! not a problem. i'm very keen to catch any mistakes, thought i had missed something.
I think we should move all bit-related functions together. Please could you add another patch to your series moving "ms1b"/"bsf"/"fls" functions in this file?
Quoted 3 lines
Quoted 3 lines
okay, so there is already a
rte_bitops.h. i guess everything should go there including the leading/trailing count functions instead of adding a new header.
Yes good idea to gather all in rte_bitops.h.
Quoted 7 lines
Quoted 4 lines
i'll introduce a new patch to the series that gathers the existing functions into
rte_bitops.hand place the new functions there too.thanks
just as a further follow up, you do understand that this is technically an api break?
Yes
Quoted 3 lines
moving functions from
rte_common.htorte_bitops.hwill make translation units that included onlyrte_common.hbut used these functions will fail to compile without being updated to includerte_bitops.h.
These functions are not used a lot, it is a "small" API break.
RE: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
In reply to Tyler RetzlaffQuoted 83 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>--- lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 265 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+) create mode 100644 lib/eal/include/rte_bitcount.hlib/eal/include/meson.build +1
-0@@ -5,6 +5,7 @@ includes += include_directories('.') headers += files( 'rte_alarm.h', + 'rte_bitcount.h', 'rte_bitmap.h', 'rte_bitops.h', 'rte_branch_prediction.h',lib/eal/include/rte_bitcount.h new file +18
-0@@ -0,0 +1,265 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022 Microsoft Corporation +*/ + +#ifndef _RTE_BITCOUNT_H_ +#define _RTE_BITCOUNT_H_ + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef RTE_TOOLCHAIN_MSVC + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without priornotice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h new file +14
-0+__rte_experimental +static inline unsigned int +rte_clz (unsigned int v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */
lib/eal/include/rte_bitcount.h line 51
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)
Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
E.g.: rte_clz32(uint32_t v)
Quoted 20 lines
lib/eal/include/rte_bitcount.h new file +11
-0+{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */
lib/eal/include/rte_bitcount.h line 73
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzll (unsigned long long v)
Same comment as above: e.g. rte_clz64(uint64_t v)
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
05/01/2023 08:09, Morten Brørup:
Quoted 19 lines
Quoted 13 lines
From: Tyler Retzlaff [mailto:[email protected]] +/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h line 51
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
Quoted 1 line
E.g.:
rte_clz32(uint32_t v)
I agree on using numbers.
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 20 lines · Thomas Monjalon
05/01/2023 08:09, Morten Brørup:
Quoted 19 lines
Quoted 13 lines
From: Tyler Retzlaff [mailto:[email protected]] +/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h line 51
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
Quoted 4 lines
Quoted 1 line
E.g.:
rte_clz32(uint32_t v)I agree on using numbers.
love the idea, fewer functions too.
though it is a shame we cannot adopt C11 standard because we could just do away with the bit suffixes entirely.
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 23 lines · On Thu, 5 Jan 2023 09:21:18 -0800 Tyler Retzlaff…
Quoted 22 lines · Thomas Monjalon
05/01/2023 08:09, Morten Brørup:
Quoted 20 lines
Quoted 13 lines
From: Tyler Retzlaff [mailto:[email protected]] +/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h line 51
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
E.g.:
rte_clz32(uint32_t v)
Quoted 7 lines
Quoted 2 lines
I agree on using numbers.
love the idea, fewer functions too.
though it is a shame we cannot adopt C11 standard because we could just do away with the bit suffixes entirely.
We could but the project needs to support older RHEL releases which have older tool sets. Though probably this is moot point given how much meson seems to change.
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 29 lines · Stephen Hemminger
Quoted 26 lines · On Thu, 5 Jan 2023 09:21:18 -0800 Tyler Retzlaff…
Quoted 24 lines · Thomas Monjalon
05/01/2023 08:09, Morten Brørup:
Quoted 19 lines
Quoted 13 lines
From: Tyler Retzlaff [mailto:[email protected]] +/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h line 51
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
Quoted 1 line
E.g.:
rte_clz32(uint32_t v)I agree on using numbers.
Quoted 8 lines
Quoted 4 lines
love the idea, fewer functions too.
though it is a shame we cannot adopt C11 standard because we could just do away with the bit suffixes entirely.
We could but the project needs to support older RHEL releases which have older tool sets. Though probably this is moot point given how much meson seems to change.
True, though meson tends to be a bit easier to update than GCC on a system
- no "pip3 install --upgrade gcc", sadly :-)
If we can't go all the way to C11 support, how about at least going to C99 support? As far as I know DPDK has never updated its minimum C-standard version, and it might be a good idea to start the process of doing so, even if it is a baby step.
/Bruce
RE: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 49 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Friday, 6 January 2023 12.48Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Thu, 5 Jan 2023 09:21:18 -0800 Tyler Retzlaff…
Quoted 5 lines · Thomas Monjalon
05/01/2023 08:09, Morten Brørup:
Quoted 4 lines
Quoted 4 lines
From: Tyler Retzlaff [mailto:[email protected]] +/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed,without prior
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/eal/include/rte_bitcount.h line 51
Quoted 6 lines
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)Don't use l (long) and ll (long long) for names (and types),
use explicit bit lengths, 32 and 64.
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
E.g.:
rte_clz32(uint32_t v)I agree on using numbers.
love the idea, fewer functions too.
though it is a shame we cannot adopt C11 standard because we could
just
Quoted 5 lines
Quoted 1 line
do away with the bit suffixes entirely.
We could but the project needs to support older RHEL releases which have older tool sets. Though probably this is moot point given how much meson seems to change.
True, though meson tends to be a bit easier to update than GCC on a system
- no "pip3 install --upgrade gcc", sadly :-)
Quoted 8 lines
If we can't go all the way to C11 support, how about at least going to C99
support? As far as I know DPDK has never updated its minimum C-standard version, and it might be a good idea to start the process of doing so, even
if it is a baby step./Bruce
The DPDK Getting Started Guide [1] says:
"Required Tools and Libraries:
[...]
a supported C compiler such as gcc (version 4.9+)"
GCC version 4.9 supports C11 [2]:
"GCC 4.9 Changes: "ISO C11 support is now at a similar level of completeness to ISO C99 support [...]"
So why are we not going to support C11?
Probably because of RHEL 7, which only provides GCC 4.8 [3].
RHEL 7 was released for GA on June 10, 2014 [4]. If someone has a server with a nine year old distro still used in production, it is probably because it is running some legacy application, which is difficult to get up and running on a newer distro. Partial conclusion: RHEL 7 is probably still widely used in production.
However, I have a hard time understanding why anyone would build and/or deploy a brand new DPDK application (based on DPDK 23.03) on such a server. Can someone please justify this?
Are we really going to postpone C11 support in DPDK until June 30, 2026, when RHEL 7 ends its Extended Life Cycle Support [4]?
If so, then the GCC version mentioned in the DPDK Getting Started Guide should be corrected accordingly.
[1]: https://doc.dpdk.org/guides/linux_gsg/sys_reqs.html#compilation-of-the-dpdk
[2]: https://gcc.gnu.org/wiki/C11Status
[3]: https://access.redhat.com/solutions/19458
[4]: https://access.redhat.com/support/policy/updates/errata#Life_Cycle_Dates
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
06/01/2023 13:41, Morten Brørup:
Quoted 49 lines
Quoted 49 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Friday, 6 January 2023 12.48Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Thu, 5 Jan 2023 09:21:18 -0800 Tyler Retzlaff…
Quoted 5 lines · Thomas Monjalon
05/01/2023 08:09, Morten Brørup:
Quoted 4 lines
Quoted 4 lines
From: Tyler Retzlaff [mailto:[email protected]] +/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed,without prior
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
+ * @return
+ * The count of leading zero bits.
+ */(quoted diff) +3
-0+__rte_experimental +static inline unsigned int +rte_clzl(unsigned long v)Don't use l (long) and ll (long long) for names (and types),
use explicit bit lengths, 32 and 64.
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
E.g.:
rte_clz32(uint32_t v)I agree on using numbers.
love the idea, fewer functions too.
though it is a shame we cannot adopt C11 standard because we could
just
Quoted 5 lines
Quoted 1 line
do away with the bit suffixes entirely.
We could but the project needs to support older RHEL releases which have older tool sets. Though probably this is moot point given how much meson seems to change.
True, though meson tends to be a bit easier to update than GCC on a system
- no "pip3 install --upgrade gcc", sadly :-)
Quoted 6 lines
Quoted 6 lines
If we can't go all the way to C11 support, how about at least going to C99
support? As far as I know DPDK has never updated its minimum C-standard version, and it might be a good idea to start the process of doing so, even
if it is a baby step.
I am in favor of this baby step: define -std=c99 porject-wise and see what are the effects during the year.
Quoted 10 lines
The DPDK Getting Started Guide [1] says:
"Required Tools and Libraries:
[...]
a supported C compiler such as gcc (version 4.9+)"GCC version 4.9 supports C11 [2]:
"GCC 4.9 Changes: "ISO C11 support is now at a similar level of completeness to ISO C99 support [...]"So why are we not going to support C11?
We should make a plan to switch to C11 during next year.
Quoted 7 lines
Probably because of RHEL 7, which only provides GCC 4.8 [3].
RHEL 7 was released for GA on June 10, 2014 [4]. If someone has a server with a nine year old distro still used in production, it is probably because it is running some legacy application, which is difficult to get up and running on a newer distro. Partial conclusion: RHEL 7 is probably still widely used in production.
However, I have a hard time understanding why anyone would build and/or deploy a brand new DPDK application (based on DPDK 23.03) on such a server. Can someone please justify this?
Are we really going to postpone C11 support in DPDK until June 30, 2026, when RHEL 7 ends its Extended Life Cycle Support [4]?
RHEL does its own choices to support old software for long. Upstream development should move forward.
Quoted 1 line
If so, then the GCC version mentioned in the DPDK Getting Started Guide should be corrected accordingly.
No let's keep GCC 4.9 as a minimum for now.
If needed we could upgrade it later.
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 83 lines · Thomas Monjalon
06/01/2023 13:41, Morten Brørup:
Quoted 49 lines
Quoted 49 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Friday, 6 January 2023 12.48Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Thu, 5 Jan 2023 09:21:18 -0800 Tyler Retzlaff…
Quoted 5 lines · Thomas Monjalon
05/01/2023 08:09, Morten Brørup:
Quoted 4 lines
Quoted 4 lines
From: Tyler Retzlaff [mailto:[email protected]] +/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed,without prior
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
+ * @return
+ * The count of leading zero bits.
+ */(quoted diff) +3
-0+__rte_experimental +static inline unsigned int +rte_clzl(unsigned long v)Don't use l (long) and ll (long long) for names (and types),
use explicit bit lengths, 32 and 64.
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
E.g.:
rte_clz32(uint32_t v)I agree on using numbers.
love the idea, fewer functions too.
though it is a shame we cannot adopt C11 standard because we could
just
Quoted 5 lines
Quoted 1 line
do away with the bit suffixes entirely.
We could but the project needs to support older RHEL releases which have older tool sets. Though probably this is moot point given how much meson seems to change.
True, though meson tends to be a bit easier to update than GCC on a system
- no "pip3 install --upgrade gcc", sadly :-)Quoted 6 lines
Quoted 6 lines
If we can't go all the way to C11 support, how about at least going to C99
support? As far as I know DPDK has never updated its minimum C-standard version, and it might be a good idea to start the process of doing so, even
if it is a baby step.I am in favor of this baby step: define -std=c99 porject-wise and see what are the effects during the year.
Quoted 10 lines
The DPDK Getting Started Guide [1] says:
"Required Tools and Libraries:
[...]
a supported C compiler such as gcc (version 4.9+)"GCC version 4.9 supports C11 [2]:
"GCC 4.9 Changes: "ISO C11 support is now at a similar level of completeness to ISO C99 support [...]"So why are we not going to support C11?
We should make a plan to switch to C11 during next year.
Quoted 7 lines
Probably because of RHEL 7, which only provides GCC 4.8 [3].
RHEL 7 was released for GA on June 10, 2014 [4]. If someone has a server with a nine year old distro still used in production, it is probably because it is running some legacy application, which is difficult to get up and running on a newer distro. Partial conclusion: RHEL 7 is probably still widely used in production.
However, I have a hard time understanding why anyone would build and/or deploy a brand new DPDK application (based on DPDK 23.03) on such a server. Can someone please justify this?
Are we really going to postpone C11 support in DPDK until June 30, 2026, when RHEL 7 ends its Extended Life Cycle Support [4]?
Quoted 8 lines
RHEL does its own choices to support old software for long. Upstream development should move forward.
Quoted 1 line
If so, then the GCC version mentioned in the DPDK Getting Started Guide should be corrected accordingly.
No let's keep GCC 4.9 as a minimum for now.
If needed we could upgrade it later.
but i think the point Morten is making is that RHEL 7 gcc is 4.8 and therefore we implicitly no longer support it if we document requiring gcc 4.9.
Quoted 2 lines
so i think the way to do this is through clarification at the next release / ltsc release. starting with dpdk 23.xx will require compiler conforming to standard X and optional features / annexes from standard X. anyone building applications targeting that version of dpdk release will need a conforming implementation.
from there we just need to take care not to backport any code to stable branches that depend on standard features that exceed the requirements documented for that release.
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
06/01/2023 19:58, Tyler Retzlaff:
Quoted 88 lines · Thomas Monjalon
Quoted 87 lines
06/01/2023 13:41, Morten Brørup:
Quoted 49 lines
Quoted 49 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Friday, 6 January 2023 12.48Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Thu, 5 Jan 2023 09:21:18 -0800 Tyler Retzlaff…
Quoted 5 lines · Thomas Monjalon
05/01/2023 08:09, Morten Brørup:
Quoted 4 lines
Quoted 4 lines
From: Tyler Retzlaff [mailto:[email protected]] +/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed,without prior
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
+ * @return
+ * The count of leading zero bits.
+ */(quoted diff) +3
-0+__rte_experimental +static inline unsigned int +rte_clzl(unsigned long v)Don't use l (long) and ll (long long) for names (and types),
use explicit bit lengths, 32 and 64.
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
E.g.:
rte_clz32(uint32_t v)I agree on using numbers.
love the idea, fewer functions too.
though it is a shame we cannot adopt C11 standard because we could
just
Quoted 5 lines
Quoted 1 line
do away with the bit suffixes entirely.
We could but the project needs to support older RHEL releases which have older tool sets. Though probably this is moot point given how much meson seems to change.
True, though meson tends to be a bit easier to update than GCC on a system
- no "pip3 install --upgrade gcc", sadly :-)Quoted 6 lines
Quoted 6 lines
If we can't go all the way to C11 support, how about at least going to C99
support? As far as I know DPDK has never updated its minimum C-standard version, and it might be a good idea to start the process of doing so, even
if it is a baby step.I am in favor of this baby step: define -std=c99 porject-wise and see what are the effects during the year.
Quoted 10 lines
The DPDK Getting Started Guide [1] says:
"Required Tools and Libraries:
[...]
a supported C compiler such as gcc (version 4.9+)"GCC version 4.9 supports C11 [2]:
"GCC 4.9 Changes: "ISO C11 support is now at a similar level of completeness to ISO C99 support [...]"So why are we not going to support C11?
We should make a plan to switch to C11 during next year.
Quoted 7 lines
Probably because of RHEL 7, which only provides GCC 4.8 [3].
RHEL 7 was released for GA on June 10, 2014 [4]. If someone has a server with a nine year old distro still used in production, it is probably because it is running some legacy application, which is difficult to get up and running on a newer distro. Partial conclusion: RHEL 7 is probably still widely used in production.
However, I have a hard time understanding why anyone would build and/or deploy a brand new DPDK application (based on DPDK 23.03) on such a server. Can someone please justify this?
Are we really going to postpone C11 support in DPDK until June 30, 2026, when RHEL 7 ends its Extended Life Cycle Support [4]?
RHEL does its own choices to support old software for long. Upstream development should move forward.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
If so, then the GCC version mentioned in the DPDK Getting Started Guide should be corrected accordingly.
No let's keep GCC 4.9 as a minimum for now.
If needed we could upgrade it later.but i think the point Morten is making is that RHEL 7 gcc is 4.8 and therefore we implicitly no longer support it if we document requiring gcc 4.9.
Yes I got it.
I think everything in DPDK works on RHEL 7 today,
but I believe RHEL 7 is not a strong requirement anymore for the mainline. Asking for confirmation here.
Quoted 9 lines
so i think the way to do this is through clarification at the next release / ltsc release. starting with dpdk 23.xx will require compiler conforming to standard X and optional features / annexes from standard X. anyone building applications targeting that version of dpdk release will need a conforming implementation.
from there we just need to take care not to backport any code to stable branches that depend on standard features that exceed the requirements documented for that release.
We could even start testing C99 requirement in 23.03 I think.
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 109 lines · Thomas Monjalon
06/01/2023 19:58, Tyler Retzlaff:
Quoted 88 lines · Thomas Monjalon
Quoted 87 lines
06/01/2023 13:41, Morten Brørup:
Quoted 49 lines
Quoted 49 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Friday, 6 January 2023 12.48Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Thu, 5 Jan 2023 09:21:18 -0800 Tyler Retzlaff…
Quoted 5 lines · Thomas Monjalon
05/01/2023 08:09, Morten Brørup:
Quoted 4 lines
Quoted 4 lines
From: Tyler Retzlaff [mailto:[email protected]] +/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed,without prior
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
+ * @return
+ * The count of leading zero bits.
+ */(quoted diff) +3
-0+__rte_experimental +static inline unsigned int +rte_clzl(unsigned long v)Don't use l (long) and ll (long long) for names (and types),
use explicit bit lengths, 32 and 64.
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
E.g.:
rte_clz32(uint32_t v)I agree on using numbers.
love the idea, fewer functions too.
though it is a shame we cannot adopt C11 standard because we could
just
Quoted 5 lines
Quoted 1 line
do away with the bit suffixes entirely.
We could but the project needs to support older RHEL releases which have older tool sets. Though probably this is moot point given how much meson seems to change.
True, though meson tends to be a bit easier to update than GCC on a system
- no "pip3 install --upgrade gcc", sadly :-)Quoted 6 lines
Quoted 6 lines
If we can't go all the way to C11 support, how about at least going to C99
support? As far as I know DPDK has never updated its minimum C-standard version, and it might be a good idea to start the process of doing so, even
if it is a baby step.I am in favor of this baby step: define -std=c99 porject-wise and see what are the effects during the year.
Quoted 10 lines
The DPDK Getting Started Guide [1] says:
"Required Tools and Libraries:
[...]
a supported C compiler such as gcc (version 4.9+)"GCC version 4.9 supports C11 [2]:
"GCC 4.9 Changes: "ISO C11 support is now at a similar level of completeness to ISO C99 support [...]"So why are we not going to support C11?
We should make a plan to switch to C11 during next year.
Quoted 7 lines
Probably because of RHEL 7, which only provides GCC 4.8 [3].
RHEL 7 was released for GA on June 10, 2014 [4]. If someone has a server with a nine year old distro still used in production, it is probably because it is running some legacy application, which is difficult to get up and running on a newer distro. Partial conclusion: RHEL 7 is probably still widely used in production.
However, I have a hard time understanding why anyone would build and/or deploy a brand new DPDK application (based on DPDK 23.03) on such a server. Can someone please justify this?
Are we really going to postpone C11 support in DPDK until June 30, 2026, when RHEL 7 ends its Extended Life Cycle Support [4]?
RHEL does its own choices to support old software for long. Upstream development should move forward.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
If so, then the GCC version mentioned in the DPDK Getting Started Guide should be corrected accordingly.
No let's keep GCC 4.9 as a minimum for now.
If needed we could upgrade it later.but i think the point Morten is making is that RHEL 7 gcc is 4.8 and therefore we implicitly no longer support it if we document requiring gcc 4.9.
Yes I got it.
I think everything in DPDK works on RHEL 7 today,
but I believe RHEL 7 is not a strong requirement anymore for the mainline. Asking for confirmation here.Quoted 6 lines
so i think the way to do this is through clarification at the next release / ltsc release. starting with dpdk 23.xx will require compiler conforming to standard X and optional features / annexes from standard X. anyone building applications targeting that version of dpdk release will need a conforming implementation.
Quoted 7 lines
Quoted 3 lines
from there we just need to take care not to backport any code to stable branches that depend on standard features that exceed the requirements documented for that release.
We could even start testing C99 requirement in 23.03 I think.
I missed discussion in this thread, but replied in other thread, replying here too.
+1 to switch C99 support.
There are bunch of C99 features used within DPDK already, and there were some drivers compiled with c89 support, that restriction is removed now, so it should be OK to move to C99 support.
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
In reply to Bruce RichardsonQuoted 35 lines · Bruce Richardson
Quoted 34 lines · Stephen Hemminger
Quoted 30 lines · On Thu, 5 Jan 2023 09:21:18 -0800 Tyler Retzlaff…
Quoted 20 lines · Thomas Monjalon
05/01/2023 08:09, Morten Brørup:
Quoted 19 lines
Quoted 13 lines
From: Tyler Retzlaff [mailto:[email protected]] +/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h line 51
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
Quoted 4 lines
Quoted 1 line
E.g.:
rte_clz32(uint32_t v)I agree on using numbers.
love the idea, fewer functions too.
though it is a shame we cannot adopt C11 standard because we could just do away with the bit suffixes entirely.
Quoted 6 lines
Quoted 3 lines
We could but the project needs to support older RHEL releases which have older tool sets. Though probably this is moot point given how much meson seems to change.
True, though meson tends to be a bit easier to update than GCC on a system
- no "pip3 install --upgrade gcc", sadly :-)
* on linux. :)
Quoted 5 lines
If we can't go all the way to C11 support, how about at least going to C99 support? As far as I know DPDK has never updated its minimum C-standard version, and it might be a good idea to start the process of doing so, even if it is a baby step.
the thing that blurs the line a bit is how the gcc version that is holding us back does actually allow the use of some C99 optional features. for example we use the C99 fixed width integer types so technically some of the code already requires C99.
i also notice at least one driver is explicitly specifying -std=gnu99 so maybe that driver just isn't being built when the old gcc is detected?
anyway, i think we are stuck pre-c99 so long as we have RHEL 7 to contend with. the rationale is if we could use a compiler conforming to the new standard we could just directly use those features, but so long as we have to support non conforming compiler at a particular level we have to introduce an abstraction and that is where all the extra work comes from.
a prominent example is atomics from C11, but for other reasons in our code base that i won't go into even if we required C11 we would still need to abstract atomics. fwiw i'm working on this patch series now and hope to provide a first draft in the next week or two.
finally, i do think it would be good to document a minimum C compiler conformance level rather than specific gcc versions. though i admit we also have a hard dependency on gcc right now. my goal is to improve portability to a level where we could just state "you need a C<N> compliant compiler" (or as close to it as possible).
ty
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 59 lines · Tyler Retzlaff
Quoted 35 lines · Bruce Richardson
Quoted 34 lines · Stephen Hemminger
Quoted 30 lines · On Thu, 5 Jan 2023 09:21:18 -0800 Tyler Retzlaff…
Quoted 20 lines · Thomas Monjalon
05/01/2023 08:09, Morten Brørup:
Quoted 19 lines
Quoted 13 lines
From: Tyler Retzlaff [mailto:[email protected]] +/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */Review
Quoted 3 lines
(quoted diff) +3
-0+__rte_experimental +static inline unsigned int +rte_clzl(unsigned long v)Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
Quoted 4 lines
Quoted 1 line
E.g.:
rte_clz32(uint32_t v)I agree on using numbers.
love the idea, fewer functions too.
though it is a shame we cannot adopt C11 standard because we could just do away with the bit suffixes entirely.
Quoted 6 lines
Quoted 3 lines
We could but the project needs to support older RHEL releases which have older tool sets. Though probably this is moot point given how much meson seems to change.
True, though meson tends to be a bit easier to update than GCC on a system
- no "pip3 install --upgrade gcc", sadly :-)* on linux. :)
Quoted 5 lines
If we can't go all the way to C11 support, how about at least going to C99 support? As far as I know DPDK has never updated its minimum C-standard version, and it might be a good idea to start the process of doing so, even if it is a baby step.
the thing that blurs the line a bit is how the gcc version that is holding us back does actually allow the use of some C99 optional features. for example we use the C99 fixed width integer types so technically some of the code already requires C99.
i also notice at least one driver is explicitly specifying -std=gnu99 so maybe that driver just isn't being built when the old gcc is detected?
Quoted 7 lines
anyway, i think we are stuck pre-c99 so long as we have RHEL 7 to contend with. the rationale is if we could use a compiler conforming to the new standard we could just directly use those features, but so long as we have to support non conforming compiler at a particular level we have to introduce an abstraction and that is where all the extra work comes from.
AFAIK the gcc 4.8 compiler on RHEL 7/Centos 7 does support C99, it's just missing full support for C11 (which comes in 4.9). Therefore I see using C99 as hopefully being unproblematic, and allowing us to try moving forward revision and seeing what issues - if any - we hit. It should also allow us to put in place infrastructure to support such version changes, since, for example, we likely need to ensure that our headers still work with C90 compilation.
/Bruce
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
In reply to Morten BrørupQuoted 89 lines · Morten Brørup
Quoted 83 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>--- lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 265 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+) create mode 100644 lib/eal/include/rte_bitcount.hlib/eal/include/meson.build +1
-0@@ -5,6 +5,7 @@ includes += include_directories('.') headers += files( 'rte_alarm.h', + 'rte_bitcount.h', 'rte_bitmap.h', 'rte_bitops.h', 'rte_branch_prediction.h',lib/eal/include/rte_bitcount.h new file +18
-0@@ -0,0 +1,265 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022 Microsoft Corporation +*/ + +#ifndef _RTE_BITCOUNT_H_ +#define _RTE_BITCOUNT_H_ + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef RTE_TOOLCHAIN_MSVC + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without priornotice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h new file +14
-0+__rte_experimental +static inline unsigned int +rte_clz (unsigned int v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h line 51
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
Quoted 1 line
E.g.:
rte_clz32(uint32_t v)
so i just noticed this, but sometimes these functions receive size_t so naming them specifically 32/64 bit becomes problematic because are going to end up with promotion on sizeof(size_t) == sizeof(long) == 4 platforms.
i.e.size_t s = ...;
x = rte_clz64(s); // assume 64-bit today
this code is now broken because on 32-bit platform s will get promoted and the extra 32 zero-bits will be returned in the result breaking calculations.
any thoughts? should we go back to l, ll?
ty
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 101 lines · Tyler Retzlaff
Quoted 89 lines · Morten Brørup
Quoted 83 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>--- lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 265 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+) create mode 100644 lib/eal/include/rte_bitcount.hlib/eal/include/meson.build +1
-0@@ -5,6 +5,7 @@ includes += include_directories('.') headers += files( 'rte_alarm.h', + 'rte_bitcount.h', 'rte_bitmap.h', 'rte_bitops.h', 'rte_branch_prediction.h',lib/eal/include/rte_bitcount.h new file +18
-0@@ -0,0 +1,265 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022 Microsoft Corporation +*/ + +#ifndef _RTE_BITCOUNT_H_ +#define _RTE_BITCOUNT_H_ + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef RTE_TOOLCHAIN_MSVC + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without priornotice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h new file +14
-0+__rte_experimental +static inline unsigned int +rte_clz (unsigned int v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h line 51
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
Quoted 1 line
E.g.:
rte_clz32(uint32_t v)so i just noticed this, but sometimes these functions receive
size_tso naming them specifically 32/64 bit becomes problematic because are going to end up with promotion onsizeof(size_t)== sizeof(long) == 4 platforms.i.e.
size_ts = ...;
x =rte_clz64(s); // assume 64-bit today
Quoted 6 lines
this code is now broken because on 32-bit platform s will get promoted and the extra 32 zero-bits will be returned in the result breaking calculations.
any thoughts? should we go back to l, ll?
Yes, promotion will happen, but I still think that the 32 and 64 versions are far clearer here in all cases. Anyone looking at the code will recognise that the result will be the leading zero count of a 64-bit number irrespective of the type actually passed in. It's less confusing now IMHO.
/Bruce
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 106 lines · Bruce Richardson
Quoted 105 lines · Tyler Retzlaff
Quoted 89 lines · Morten Brørup
Quoted 83 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>--- lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 265 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+) create mode 100644 lib/eal/include/rte_bitcount.hlib/eal/include/meson.build +1
-0@@ -5,6 +5,7 @@ includes += include_directories('.') headers += files( 'rte_alarm.h', + 'rte_bitcount.h', 'rte_bitmap.h', 'rte_bitops.h', 'rte_branch_prediction.h',lib/eal/include/rte_bitcount.h new file +18
-0@@ -0,0 +1,265 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022 Microsoft Corporation +*/ + +#ifndef _RTE_BITCOUNT_H_ +#define _RTE_BITCOUNT_H_ + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef RTE_TOOLCHAIN_MSVC + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without priornotice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h new file +14
-0+__rte_experimental +static inline unsigned int +rte_clz (unsigned int v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h line 51
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
Quoted 1 line
E.g.:
rte_clz32(uint32_t v)so i just noticed this, but sometimes these functions receive
size_tso naming them specifically 32/64 bit becomes problematic because are going to end up with promotion onsizeof(size_t)== sizeof(long) == 4 platforms.i.e.
size_ts = ...;
x =rte_clz64(s); // assume 64-bit todaythis code is now broken because on 32-bit platform s will get promoted and the extra 32 zero-bits will be returned in the result breaking calculations.
Quoted 7 lines
Quoted 2 lines
any thoughts? should we go back to l, ll?
Yes, promotion will happen, but I still think that the 32 and 64 versions are far clearer here in all cases. Anyone looking at the code will recognise that the result will be the leading zero count of a 64-bit number irrespective of the type actually passed in. It's less confusing now IMHO.
here's an example in the code that would result in a bad calculation or at least i believe so at a glance. switching to rte_clz32() would break on 64-bit since it would truncate.
lib/eal/common/malloc_elem.c
-log2 = sizeof(size) * 8 - __builtin_clzl(size);
+log2 = sizeof(size) * 8 - rte_clz64(size);
if i'm right you'd have to conditionally compile at the site.
#ifdef 64-bitrte_clz64()
#elserte_clz32()
#endif
and that seems very undesirable. another solution is to defer this change until post 23.07 release (where C11 can be used) and we could then just provide a single generic.
with C11 i can provide a single macro that doesn't need 8/16/32/64 suffix.
size_t v;
n = rte_clz(v); // sizeof(v) doesn't matter.
Quoted 2 lines
/Bruce
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 124 lines · Tyler Retzlaff
Quoted 106 lines · Bruce Richardson
Quoted 105 lines · Tyler Retzlaff
Quoted 89 lines · Morten Brørup
Quoted 83 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>--- lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 265 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+) create mode 100644 lib/eal/include/rte_bitcount.hlib/eal/include/meson.build +1
-0@@ -5,6 +5,7 @@ includes += include_directories('.') headers += files( 'rte_alarm.h', + 'rte_bitcount.h', 'rte_bitmap.h', 'rte_bitops.h', 'rte_branch_prediction.h',lib/eal/include/rte_bitcount.h new file +18
-0@@ -0,0 +1,265 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022 Microsoft Corporation +*/ + +#ifndef _RTE_BITCOUNT_H_ +#define _RTE_BITCOUNT_H_ + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef RTE_TOOLCHAIN_MSVC + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without priornotice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h new file +14
-0+__rte_experimental +static inline unsigned int +rte_clz (unsigned int v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h line 51
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
Quoted 1 line
E.g.:
rte_clz32(uint32_t v)so i just noticed this, but sometimes these functions receive
size_tso naming them specifically 32/64 bit becomes problematic because are going to end up with promotion onsizeof(size_t)== sizeof(long) == 4 platforms.i.e.
size_ts = ...;
x =rte_clz64(s); // assume 64-bit todaythis code is now broken because on 32-bit platform s will get promoted and the extra 32 zero-bits will be returned in the result breaking calculations.
Quoted 7 lines
Quoted 2 lines
any thoughts? should we go back to l, ll?
Yes, promotion will happen, but I still think that the 32 and 64 versions are far clearer here in all cases. Anyone looking at the code will recognise that the result will be the leading zero count of a 64-bit number irrespective of the type actually passed in. It's less confusing now IMHO.
here's an example in the code that would result in a bad calculation or at least i believe so at a glance. switching to
rte_clz32()would break on 64-bit since it would truncate.
lib/eal/common/malloc_elem.c(quoted diff) +1
-1-log2 = sizeof(size) * 8 - __builtin_clzl(size); +log2 = sizeof(size) * 8 - rte_clz64(size);
Quoted 8 lines
if i'm right you'd have to conditionally compile at the site.
#ifdef 64-bit
rte_clz64()
#elserte_clz32()
#endif
Why can clz64 not be used in both 32 and 64 bit cases? You know the result will always include zeros in high bits of a 64-bit value, and the result will still fit inside even an 8-bit variable?
/Bruce
Re: [PATCH v2 1/2] eal: provide leading and trailing zero bit count abstraction
Quoted 127 lines · Bruce Richardson
Quoted 126 lines · Tyler Retzlaff
Quoted 106 lines · Bruce Richardson
Quoted 105 lines · Tyler Retzlaff
Quoted 89 lines · Morten Brørup
Quoted 83 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 24 November 2022 00.43Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Signed-off-by Tyler Retzlaff <[email protected]>--- lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 265 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+) create mode 100644 lib/eal/include/rte_bitcount.hlib/eal/include/meson.build +1
-0@@ -5,6 +5,7 @@ includes += include_directories('.') headers += files( 'rte_alarm.h', + 'rte_bitcount.h', 'rte_bitmap.h', 'rte_bitops.h', 'rte_branch_prediction.h',lib/eal/include/rte_bitcount.h new file +18
-0@@ -0,0 +1,265 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022 Microsoft Corporation +*/ + +#ifndef _RTE_BITCOUNT_H_ +#define _RTE_BITCOUNT_H_ + +#include <rte_compat.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef RTE_TOOLCHAIN_MSVC + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without priornotice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h new file +14
-0+__rte_experimental +static inline unsigned int +rte_clz (unsigned int v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the count of leading 0-bits in v.
+ *
+ * @param v
+ * The value.
+ * @return
+ * The count of leading zero bits.
+ */lib/eal/include/rte_bitcount.h line 51
Quoted 3 lines
lib/eal/include/rte_bitcount.h new file +3
-0+__rte_experimental +static inline unsigned int +rte_clzl (unsigned long v)Don't use l (long) and ll (long long) for names (and types), use explicit bit lengths, 32 and 64.
Quoted 1 line
E.g.:
rte_clz32(uint32_t v)so i just noticed this, but sometimes these functions receive
size_tso naming them specifically 32/64 bit becomes problematic because are going to end up with promotion onsizeof(size_t)== sizeof(long) == 4 platforms.i.e.
size_ts = ...;
x =rte_clz64(s); // assume 64-bit todaythis code is now broken because on 32-bit platform s will get promoted and the extra 32 zero-bits will be returned in the result breaking calculations.
Quoted 7 lines
Quoted 2 lines
any thoughts? should we go back to l, ll?
Yes, promotion will happen, but I still think that the 32 and 64 versions are far clearer here in all cases. Anyone looking at the code will recognise that the result will be the leading zero count of a 64-bit number irrespective of the type actually passed in. It's less confusing now IMHO.
here's an example in the code that would result in a bad calculation or at least i believe so at a glance. switching to
rte_clz32()would break on 64-bit since it would truncate.
lib/eal/common/malloc_elem.c(quoted diff) +1
-1-log2 = sizeof(size) * 8 - __builtin_clzl(size); +log2 = sizeof(size) * 8 - rte_clz64(size);if i'm right you'd have to conditionally compile at the site.
Quoted 10 lines
Quoted 6 lines
#ifdef 64-bit
rte_clz64()
#elserte_clz32()
#endifWhy can clz64 not be used in both 32 and 64 bit cases? You know the result will always include zeros in high bits of a 64-bit value, and the result will still fit inside even an 8-bit variable?
of course. doh.
sorry for the noise!
and thank you as always.
Quoted 2 lines
/Bruce
PATCH v2 2/2 test/bitcount: add bitcount tests
In reply to Tyler Retzlaffbasic unit test of following functions
rte_clz
rte_clzl
rte_clzll
rte_ctz
rte_ctzl
rte_ctzll
--- app/test/meson.build | 2 ++ app/test/test_bitcount.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 app/test/test_bitcount.c
app/test/meson.build +2 -0
@@ -13,6 +13,7 @@ test_sources = files( 'test_alarm.c', 'test_atomic.c', 'test_barrier.c', + 'test_bitcount.c', 'test_bitops.c', 'test_bitmap.c', 'test_bpf.c',
@@ -160,6 +161,7 @@ test_deps += ['bus_pci', 'bus_vdev'] fast_tests = [ ['acl_autotest', true, true], ['atomic_autotest', false, true], + ['bitcount_autotest', true, true], ['bitmap_autotest', true, true], ['bpf_autotest', true, true], ['bpf_convert_autotest', true, true],
app/test/test_bitcount.c new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
1.8.3.1
hi just adding a few extra folks to the to line to try and get some reviewer attention since this patch has been sitting here for a while.
the change is fairly straight forward, would just like to get it cleared.
feedback is appreciated!
thanks
Quoted 26 lines · Tyler Retzlaff
Provide leading and trailing zero bit count functions to abstract away compiler specific implementations.
Include basic unit test for new leading/trailing zero bit count functions.
v2:
* use unsigned int instead of unsigned (checkpatches)
* match multiple include guard naming convention torte_common.h
* add explicit extern "C" linkage torte_bitcount.h
note: not really needed but checkpatches required
* add missing space around '-'Tyler Retzlaff (2):
eal: provide leading and trailing zero bit count abstraction test/bitcount: add bitcount testsapp/test/meson.build | 2 + app/test/test_bitcount.c | 92 ++++++++++++++ lib/eal/include/meson.build | 1 + lib/eal/include/rte_bitcount.h | 265 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 360 insertions(+) create mode 100644 app/test/test_bitcount.c create mode 100644 lib/eal/include/rte_bitcount.hSignature · 1 line
1.8.3.1
v4 cover eal: provide leading and trailing zero bit count abstraction
In reply to Tyler RetzlaffMove existing bit manipulation, log and npow functions from rte_common.h to rte_bitops.h
Provide leading and trailing zero bit count functions to abstract away compiler specific implementations.
Include basic unit test for new leading/trailing zero bit count functions.
v4:
* combine unit test commit into function addition commit
v3:
* rename to use 32/64 instead of l/ll suffixes
* add new functions to rte_bitops.h instead of new header
* move other bit functions from rte_common.h to rte_bitops.h
v2:
* use unsigned int instead of unsigned (checkpatches)
* match multiple include guard naming convention to rte_common.h
* add explicit extern "C" linkage to rte_bitcount.h
note: not really needed but checkpatches required
* add missing space around '-'
Tyler Retzlaff (2):
eal: move bit operation functions from common to bitops header
eal: provide leading and trailing zero bit count abstraction
app/test/meson.build | 2 + app/test/test_bitcount.c | 71 +++++++ app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 460 ++++++++++++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ------------------------- 6 files changed, 535 insertions(+), 293 deletions(-) create mode 100644 app/test/test_bitcount.c
Signature · 2 lines
Series-acked-by: Morten Brørup <[email protected]> Series-acked-by: Bruce Richardson <[email protected]>
PATCH v4 1/2 eal: move bit operation functions from common to bitops header
Move the following inline functions from rte_common.h to rte_bitops.h
rte_combine32ms1b
rte_combine64ms1b
rte_bsf32
rte_bsf32_safe
rte_bsf64
rte_bsf64_safe
rte_fls_u32
rte_fls_u64
rte_is_power_of_2
rte_align32pow2
rte_align32prevpow2
rte_align64pow2
rte_align64prevpow2
rte_log2_u32
rte_log2_u64
--- app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 292 +++++++++++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ---------------------------------------- 4 files changed, 294 insertions(+), 293 deletions(-)
app/test/test_common.c +1 -0
@@ -7,6 +7,7 @@#include <string.h> #include <math.h> #include <rte_common.h> +#include <rte_bitops.h> #include <rte_hexdump.h> #include <rte_pause.h>
lib/eal/common/rte_reciprocal.c +1 -0
@@ -8,6 +8,7 @@#include <stdint.h> #include <rte_common.h> +#include <rte_bitops.h> #include "rte_reciprocal.h"
lib/eal/include/rte_bitops.h +292 -0
298 lines not on this page · raw message
lib/eal/include/rte_common.h +0 -293
305 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH v4 1/2] eal: move bit operation functions from common to bitops header
Quoted 18 lines · Tyler Retzlaff
Move the following inline functions from
rte_common.htorte_bitops.h
rte_combine32ms1b
rte_combine64ms1b
rte_bsf32
rte_bsf32_safe
rte_bsf64
rte_bsf64_safe
rte_fls_u32
rte_fls_u64
rte_is_power_of_2
rte_align32pow2
rte_align32prevpow2
rte_align64pow2
rte_align64prevpow2
rte_log2_u32
rte_log2_u64
Quoted 1 line
Signed-off-by Tyler Retzlaff <[email protected]>
PATCH v4 2/2 eal: provide leading and trailing zero bit count abstraction
In reply to Tyler RetzlaffFrom: Tyler Retzlaff <[email protected]>
Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Include basic unit test of following functions added.
rte_clz32
rte_clz64
rte_ctz32
rte_ctz64--- app/test/meson.build | 2 + app/test/test_bitcount.c | 71 ++++++++++++++++++ lib/eal/include/rte_bitops.h | 168 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 241 insertions(+) create mode 100644 app/test/test_bitcount.c
app/test/meson.build +2 -0
@@ -13,6 +13,7 @@ test_sources = files( 'test_alarm.c', 'test_atomic.c', 'test_barrier.c', + 'test_bitcount.c', 'test_bitops.c', 'test_bitmap.c', 'test_bpf.c',
@@ -160,6 +161,7 @@ test_deps += ['bus_pci', 'bus_vdev'] fast_tests = [ ['acl_autotest', true, true], ['atomic_autotest', false, true], + ['bitcount_autotest', true, true], ['bitmap_autotest', true, true], ['bpf_autotest', true, true], ['bpf_convert_autotest', true, true],
app/test/test_bitcount.c new file +71 -0
71 lines not on this page · raw message
lib/eal/include/rte_bitops.h +168 -0
179 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH v4 2/2] eal: provide leading and trailing zero bit count abstraction
Quoted 146 lines · Tyler Retzlaff
From: Tyler Retzlaff <[email protected]>
Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Include basic unit test of following functions added.
rte_clz32 rte_clz64 rte_ctz32 rte_ctz64Signed-off-by Tyler Retzlaff <[email protected]>--- app/test/meson.build | 2 + app/test/test_bitcount.c | 71 ++++++++++++++++++ lib/eal/include/rte_bitops.h | 168 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 241 insertions(+) create mode 100644 app/test/test_bitcount.capp/test/meson.build +2
-0@@ -13,6 +13,7 @@ test_sources = files( 'test_alarm.c', 'test_atomic.c', 'test_barrier.c', + 'test_bitcount.c', 'test_bitops.c', 'test_bitmap.c', 'test_bpf.c',@@ -160,6 +161,7 @@ test_deps += ['bus_pci', 'bus_vdev'] fast_tests = [ ['acl_autotest', true, true], ['atomic_autotest', false, true], + ['bitcount_autotest', true, true], ['bitmap_autotest', true, true], ['bpf_autotest', true, true], ['bpf_convert_autotest', true, true],app/test/test_bitcount.c new file +71
-0@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022 Microsoft Corporation +*/ + +#include <string.h> + +#include <rte_bitops.h> +#include <rte_debug.h> + +#include "test.h" + +RTE_LOG_REGISTER (bitcount_logtype_test, test.bitcount,INFO ); + +static int +test_clz32 (void ) +{ +uint32_t v =1 ; +RTE_TEST_ASSERT (rte_clz32 (v) ==sizeof (v) *CHAR_BIT -1 , +"Unexpected count." ); + +return 0 ; +} + +static int +test_clz64 (void ) +{ +uint64_t v =1 ; +RTE_TEST_ASSERT (rte_clz64 (v) ==sizeof (v) *CHAR_BIT -1 , +"Unexpected count." ); + +return 0 ; +} + +static int +test_ctz32 (void ) +{ +uint32_t v =2 ; +RTE_TEST_ASSERT (rte_ctz32 (v) ==1 ,"Unexpected count." ); + +return 0 ; +} + +static int +test_ctz64 (void ) +{ +uint64_t v =2 ; +RTE_TEST_ASSERT (rte_ctz64 (v) ==1 ,"Unexpected count." ); + +return 0 ; +} + +static struct unit_test_suite bitcount_test_suite = { + .suite_name ="bitcount autotest" , + .setup =NULL , + .teardown =NULL , + .unit_test_cases = { +TEST_CASE (test_clz32), +TEST_CASE (test_clz64), +TEST_CASE (test_ctz32), +TEST_CASE (test_ctz64), +TEST_CASES_END () + } +}; + +static int +test_bitcount (void ) +{ +return unit_test_suite_runner (&bitcount_test_suite); +} + +REGISTER_TEST_COMMAND (bitcount_autotest, test_bitcount);lib/eal/include/rte_bitops.h +15
-0@@ -1,5 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2020 Arm Limited +* Copyright(c) 2010-2019 Intel Corporation +* Copyright(c) 2023 Microsoft Corporation */ #ifndef _RTE_BITOPS_H_@@ -275,6 +277,172 @@return val & mask; } +#ifdef RTE_TOOLCHAIN_MSVC + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/
lib/eal/include/rte_bitops.h line 302
Quoted 10 lines
lib/eal/include/rte_bitops.h +10
-0+__rte_experimental +static inline unsigned int +rte_clz32 (uint32_t v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned int )rv; +}
OK, this looks wrong to me,
'_BitScanReverse' is [1]:
"Search the mask data from most significant bit (MSB) to least significant bit (LSB) for a set bit (1)."
As far as I can see index starts from zero and from lsb to msb.
So _BitScanReverse() returns following index values:0x2 => 10xffffffff => 31
If above is correct, above function doesn't return number of leading zeros, but it should return "31 - (unsigned int)rv".
Please check godbolt experiment for above:
https://godbolt.org/z/znYn54f57
As far as I can see unit test is correct, so above should fail with windows compiler, and I assume you run unit test with windows compiler, so probably I am missing something but please help me understand.
[1]
https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanreverse-bitscanreverse64?view=msvc-170
Quoted 130 lines
lib/eal/include/rte_bitops.h +130
-0+ +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_clz64 (uint64_t v) +{ +unsigned long rv; + + (void )_BitScanReverse64 (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz32 (uint32_t v) +{ +unsigned long rv; + + (void )_BitScanForward (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz64 (uint64_t v) +{ +unsigned long rv; + + (void )_BitScanForward64 (&rv, v); + +return (unsigned int )rv; +} + +#else + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_clz32 (uint32_t v) +{ +return (unsigned int )__builtin_clz (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_clz64 (uint64_t v) +{ +return (unsigned int )__builtin_clzll (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz32 (uint32_t v) +{ +return (unsigned int )__builtin_ctz (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v
lib/eal/include/rte_bitops.h line 442
Quoted 10 lines
lib/eal/include/rte_bitops.h +10
-0+* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz64 (uint64_t v) +{ +return (unsigned int )__builtin_ctzll (v); +}
'rte_ctz32()' & 'rte_ctz64()' are practically exact same with 'rte_bsf32()' & 'rte_bsf64()',
Although I can see description is different, do we need same functionality with new function name,
why not add 'rte_bsf32()' & 'rte_bsf64()' versions for the Windows?
btw, do you guys know what 'bsf' & 'fls' (rte_fls_u32) stands for?
Quoted 6 lines
lib/eal/include/rte_bitops.h +3
-0+ +#endif +/** * Combines 32b inputs most significant set bits into the least * significant bits to construct a value with the same MSBs as x
Re: [PATCH v4 2/2] eal: provide leading and trailing zero bit count abstraction
Quoted 332 lines · Ferruh Yigit
Quoted 146 lines · Tyler Retzlaff
From: Tyler Retzlaff <[email protected]>
Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Include basic unit test of following functions added.
rte_clz32 rte_clz64 rte_ctz32 rte_ctz64Signed-off-by Tyler Retzlaff <[email protected]>--- app/test/meson.build | 2 + app/test/test_bitcount.c | 71 ++++++++++++++++++ lib/eal/include/rte_bitops.h | 168 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 241 insertions(+) create mode 100644 app/test/test_bitcount.capp/test/meson.build +2
-0@@ -13,6 +13,7 @@ test_sources = files( 'test_alarm.c', 'test_atomic.c', 'test_barrier.c', + 'test_bitcount.c', 'test_bitops.c', 'test_bitmap.c', 'test_bpf.c',@@ -160,6 +161,7 @@ test_deps += ['bus_pci', 'bus_vdev'] fast_tests = [ ['acl_autotest', true, true], ['atomic_autotest', false, true], + ['bitcount_autotest', true, true], ['bitmap_autotest', true, true], ['bpf_autotest', true, true], ['bpf_convert_autotest', true, true],app/test/test_bitcount.c new file +71
-0@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022 Microsoft Corporation +*/ + +#include <string.h> + +#include <rte_bitops.h> +#include <rte_debug.h> + +#include "test.h" + +RTE_LOG_REGISTER (bitcount_logtype_test, test.bitcount,INFO ); + +static int +test_clz32 (void ) +{ +uint32_t v =1 ; +RTE_TEST_ASSERT (rte_clz32 (v) ==sizeof (v) *CHAR_BIT -1 , +"Unexpected count." ); + +return 0 ; +} + +static int +test_clz64 (void ) +{ +uint64_t v =1 ; +RTE_TEST_ASSERT (rte_clz64 (v) ==sizeof (v) *CHAR_BIT -1 , +"Unexpected count." ); + +return 0 ; +} + +static int +test_ctz32 (void ) +{ +uint32_t v =2 ; +RTE_TEST_ASSERT (rte_ctz32 (v) ==1 ,"Unexpected count." ); + +return 0 ; +} + +static int +test_ctz64 (void ) +{ +uint64_t v =2 ; +RTE_TEST_ASSERT (rte_ctz64 (v) ==1 ,"Unexpected count." ); + +return 0 ; +} + +static struct unit_test_suite bitcount_test_suite = { + .suite_name ="bitcount autotest" , + .setup =NULL , + .teardown =NULL , + .unit_test_cases = { +TEST_CASE (test_clz32), +TEST_CASE (test_clz64), +TEST_CASE (test_ctz32), +TEST_CASE (test_ctz64), +TEST_CASES_END () + } +}; + +static int +test_bitcount (void ) +{ +return unit_test_suite_runner (&bitcount_test_suite); +} + +REGISTER_TEST_COMMAND (bitcount_autotest, test_bitcount);lib/eal/include/rte_bitops.h +15
-0@@ -1,5 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2020 Arm Limited +* Copyright(c) 2010-2019 Intel Corporation +* Copyright(c) 2023 Microsoft Corporation */ #ifndef _RTE_BITOPS_H_@@ -275,6 +277,172 @@return val & mask; } +#ifdef RTE_TOOLCHAIN_MSVC + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ lib/eal/include/rte_bitops.h line 302
Quoted 10 lines
lib/eal/include/rte_bitops.h +10
-0+__rte_experimental +static inline unsigned int +rte_clz32 (uint32_t v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned int )rv; +}OK, this looks wrong to me,
'
_BitScanReverse' is [1]:
"Search the mask data from most significant bit (MSB) to least significant bit (LSB) for a set bit (1)."As far as I can see index starts from zero and from lsb to msb.
So
_BitScanReverse()returns following index values:0x2=> 10xffffffff=> 31If above is correct, above function doesn't return number of leading zeros, but it should return "31 - (unsigned int)rv".
Please check godbolt experiment for above:
https://godbolt.org/z/znYn54f57As far as I can see unit test is correct, so above should fail with windows compiler, and I assume you run unit test with windows compiler, so probably I am missing something but please help me understand.
[1]
https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanreverse-bitscanreverse64?view=msvc-170Quoted 130 lines
lib/eal/include/rte_bitops.h +130
-0+ +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_clz64 (uint64_t v) +{ +unsigned long rv; + + (void )_BitScanReverse64 (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz32 (uint32_t v) +{ +unsigned long rv; + + (void )_BitScanForward (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz64 (uint64_t v) +{ +unsigned long rv; + + (void )_BitScanForward64 (&rv, v); + +return (unsigned int )rv; +} + +#else + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_clz32 (uint32_t v) +{ +return (unsigned int )__builtin_clz (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_clz64 (uint64_t v) +{ +return (unsigned int )__builtin_clzll (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz32 (uint32_t v) +{ +return (unsigned int )__builtin_ctz (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v lib/eal/include/rte_bitops.h line 442
Quoted 10 lines
lib/eal/include/rte_bitops.h +10
-0+* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz64 (uint64_t v) +{ +return (unsigned int )__builtin_ctzll (v); +}'
rte_ctz32()' & 'rte_ctz64()' are practically exact same with 'rte_bsf32()' & 'rte_bsf64()',
Quoted 3 lines
Although I can see description is different, do we need same functionality with new function name,
why not add 'rte_bsf32()' & 'rte_bsf64()' versions for the Windows?
i agree. i need a consensus from reviewers if they think this series should be changed.
if we do take bsf{32,64} instead then does that mean we ban the use of __ctz{32,64} in dpdk? keeping in mind the end goal is portability.
Quoted 4 lines
btw, do you guys know what 'bsf' & 'fls' (
rte_fls_u32) stands for?
no idea. before my time.
Quoted 7 lines
Quoted 7 lines
lib/eal/include/rte_bitops.h +3
-0+ +#endif +/** * Combines 32b inputs most significant set bits into the least * significant bits to construct a value with the same MSBs as x
Re: [PATCH v4 2/2] eal: provide leading and trailing zero bit count abstraction
In reply to Ferruh YigitQuoted 175 lines · Ferruh Yigit
Quoted 146 lines · Tyler Retzlaff
From: Tyler Retzlaff <[email protected]>
Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Include basic unit test of following functions added.
rte_clz32 rte_clz64 rte_ctz32 rte_ctz64Signed-off-by Tyler Retzlaff <[email protected]>--- app/test/meson.build | 2 + app/test/test_bitcount.c | 71 ++++++++++++++++++ lib/eal/include/rte_bitops.h | 168 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 241 insertions(+) create mode 100644 app/test/test_bitcount.capp/test/meson.build +2
-0@@ -13,6 +13,7 @@ test_sources = files( 'test_alarm.c', 'test_atomic.c', 'test_barrier.c', + 'test_bitcount.c', 'test_bitops.c', 'test_bitmap.c', 'test_bpf.c',@@ -160,6 +161,7 @@ test_deps += ['bus_pci', 'bus_vdev'] fast_tests = [ ['acl_autotest', true, true], ['atomic_autotest', false, true], + ['bitcount_autotest', true, true], ['bitmap_autotest', true, true], ['bpf_autotest', true, true], ['bpf_convert_autotest', true, true],app/test/test_bitcount.c new file +71
-0@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022 Microsoft Corporation +*/ + +#include <string.h> + +#include <rte_bitops.h> +#include <rte_debug.h> + +#include "test.h" + +RTE_LOG_REGISTER (bitcount_logtype_test, test.bitcount,INFO ); + +static int +test_clz32 (void ) +{ +uint32_t v =1 ; +RTE_TEST_ASSERT (rte_clz32 (v) ==sizeof (v) *CHAR_BIT -1 , +"Unexpected count." ); + +return 0 ; +} + +static int +test_clz64 (void ) +{ +uint64_t v =1 ; +RTE_TEST_ASSERT (rte_clz64 (v) ==sizeof (v) *CHAR_BIT -1 , +"Unexpected count." ); + +return 0 ; +} + +static int +test_ctz32 (void ) +{ +uint32_t v =2 ; +RTE_TEST_ASSERT (rte_ctz32 (v) ==1 ,"Unexpected count." ); + +return 0 ; +} + +static int +test_ctz64 (void ) +{ +uint64_t v =2 ; +RTE_TEST_ASSERT (rte_ctz64 (v) ==1 ,"Unexpected count." ); + +return 0 ; +} + +static struct unit_test_suite bitcount_test_suite = { + .suite_name ="bitcount autotest" , + .setup =NULL , + .teardown =NULL , + .unit_test_cases = { +TEST_CASE (test_clz32), +TEST_CASE (test_clz64), +TEST_CASE (test_ctz32), +TEST_CASE (test_ctz64), +TEST_CASES_END () + } +}; + +static int +test_bitcount (void ) +{ +return unit_test_suite_runner (&bitcount_test_suite); +} + +REGISTER_TEST_COMMAND (bitcount_autotest, test_bitcount);lib/eal/include/rte_bitops.h +15
-0@@ -1,5 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2020 Arm Limited +* Copyright(c) 2010-2019 Intel Corporation +* Copyright(c) 2023 Microsoft Corporation */ #ifndef _RTE_BITOPS_H_@@ -275,6 +277,172 @@return val & mask; } +#ifdef RTE_TOOLCHAIN_MSVC + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ lib/eal/include/rte_bitops.h line 302
Quoted 10 lines
lib/eal/include/rte_bitops.h +10
-0+__rte_experimental +static inline unsigned int +rte_clz32 (uint32_t v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned int )rv; +}OK, this looks wrong to me,
'
_BitScanReverse' is [1]:
"Search the mask data from most significant bit (MSB) to least significant bit (LSB) for a set bit (1)."As far as I can see index starts from zero and from lsb to msb.
So
_BitScanReverse()returns following index values:0x2=> 10xffffffff=> 31If above is correct, above function doesn't return number of leading zeros, but it should return "31 - (unsigned int)rv".
Quoted 7 lines
Please check godbolt experiment for above:
https://godbolt.org/z/znYn54f57As far as I can see unit test is correct, so above should fail with windows compiler, and I assume you run unit test with windows compiler, so probably I am missing something but please help me understand.
the test is wrong, i will fix both the test and the implementation.
thank you for the careful review.
Re: [PATCH v4 0/2] eal: provide leading and trailing zero bit count abstraction
In reply to Tyler RetzlaffQuoted 23 lines · Tyler Retzlaff
Move existing bit manipulation, log and npow functions from
rte_common.htorte_bitops.hProvide leading and trailing zero bit count functions to abstract away compiler specific implementations.
Include basic unit test for new leading/trailing zero bit count functions.
v4:
* combine unit test commit into function addition commitv3:
* rename to use 32/64 instead of l/ll suffixes
* add new functions torte_bitops.hinstead of new header
* move other bit functions fromrte_common.htorte_bitops.hv2:
* use unsigned int instead of unsigned (checkpatches)
* match multiple include guard naming convention torte_common.h
* add explicit extern "C" linkage torte_bitcount.h
note: not really needed but checkpatches required
* add missing space around '-'
Quoted 4 lines
Tyler Retzlaff (2):
eal: move bit operation functions from common to bitops header
eal: provide leading and trailing zero bit count abstraction
There are checkpatch / checkgitlog errors, can you please check them:
- checkpatches:
### [PATCH] eal: provide leading and trailing zero bit count abstraction
WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address
mismatch: 'From: Tyler Retzlaff <[email protected]>' != 'Signed-off-by: Tyler Retzlaff <[email protected]>'
total: 0 errors, 1 warnings, 264 lines checked
1/2 valid patch
- check-git-log:
Headline too long:
eal: move bit operation functions from common to bitops header
v3 cover eal: provide leading and trailing zero bit count
In reply to Tyler RetzlaffMove existing bit manipulation, log and npow functions from rte_common.h to rte_bitops.h
Provide leading and trailing zero bit count functions to abstract away compiler specific implementations.
Include basic unit test for new leading/trailing zero bit count functions.
v3:
* rename to use 32/64 instead of l/ll suffixes
* add new functions to rte_bitops.h instead of new header
* move other bit functions from rte_common.h to rte_bitops.h
v2:
* use unsigned int instead of unsigned (checkpatches)
* match multiple include guard naming convention to rte_common.h
* add explicit extern "C" linkage to rte_bitcount.h
note: not really needed but checkpatches required
* add missing space around '-'
Tyler Retzlaff (3):
eal: move bit functions from common to bitops header
eal: provide leading and trailing zero bit count abstraction test/bitcount: add bitcount tests
app/test/meson.build | 2 + app/test/test_bitcount.c | 71 +++++++ app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 460 ++++++++++++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ------------------------- 6 files changed, 535 insertions(+), 293 deletions(-) create mode 100644 app/test/test_bitcount.c
Signature · 1 line
1.8.3.1
PATCH v3 1/3 eal: move bit functions from common to bitops header
Move the following inline functions from rte_common.h to rte_bitops.h
rte_combine32ms1b
rte_combine64ms1b
rte_bsf32
rte_bsf32_safe
rte_bsf64
rte_bsf64_safe
rte_fls_u32
rte_fls_u64
rte_is_power_of_2
rte_align32pow2
rte_align32prevpow2
rte_align64pow2
rte_align64prevpow2
rte_log2_u32
rte_log2_u64
--- app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 292 +++++++++++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ---------------------------------------- 4 files changed, 294 insertions(+), 293 deletions(-)
app/test/test_common.c +1 -0
@@ -7,6 +7,7 @@#include <string.h> #include <math.h> #include <rte_common.h> +#include <rte_bitops.h> #include <rte_hexdump.h> #include <rte_pause.h>
lib/eal/common/rte_reciprocal.c +1 -0
@@ -8,6 +8,7 @@#include <stdint.h> #include <rte_common.h> +#include <rte_bitops.h> #include "rte_reciprocal.h"
lib/eal/include/rte_bitops.h +292 -0
298 lines not on this page · raw message
lib/eal/include/rte_common.h +0 -293
305 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 2/3 eal: provide leading and trailing zero bit count abstraction
In reply to Tyler RetzlaffFrom: Tyler Retzlaff <[email protected]>
Provide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
--- lib/eal/include/rte_bitops.h | 168 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+)
lib/eal/include/rte_bitops.h +168 -0
@@ -1,5 +1,7 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2020 Arm Limited +* Copyright(c) 2010-2019 Intel Corporation +* Copyright(c) 2023 Microsoft Corporation */ #ifndef _RTE_BITOPS_H_
@@ -275,6 +277,172 @@return val & mask; } +#ifdef RTE_TOOLCHAIN_MSVC + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_clz32 (uint32_t v) +{ +unsigned long rv; + + (void )_BitScanReverse (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_clz64 (uint64_t v) +{ +unsigned long rv; + + (void )_BitScanReverse64 (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz32 (uint32_t v) +{ +unsigned long rv; + + (void )_BitScanForward (&rv, v); + +return (unsigned int )rv; +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz64 (uint64_t v) +{ +unsigned long rv; + + (void )_BitScanForward64 (&rv, v); + +return (unsigned int )rv; +} + +#else + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_clz32 (uint32_t v) +{ +return (unsigned int )__builtin_clz (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of leading 0-bits in v. +* +* @param v +* The value. +* @return +* The count of leading zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_clz64 (uint64_t v) +{ +return (unsigned int )__builtin_clzll (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz32 (uint32_t v) +{ +return (unsigned int )__builtin_ctz (v); +} + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Get the count of trailing 0-bits in v. +* +* @param v +* The value. +* @return +* The count of trailing zero bits. +*/ +__rte_experimental +static inline unsigned int +rte_ctz64 (uint64_t v) +{ +return (unsigned int )__builtin_ctzll (v); +} + +#endif +/** * Combines 32b inputs most significant set bits into the least * significant bits to construct a value with the same MSBs as x
Signature · 1 line
1.8.3.1
PATCH v3 3/3 test/bitcount: add bitcount tests
In reply to Tyler Retzlaffbasic unit test of following functions
rte_clz32
rte_clz64
rte_ctz32
rte_ctz64--- app/test/meson.build | 2 ++ app/test/test_bitcount.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 app/test/test_bitcount.c
app/test/meson.build +2 -0
@@ -13,6 +13,7 @@ test_sources = files( 'test_alarm.c', 'test_atomic.c', 'test_barrier.c', + 'test_bitcount.c', 'test_bitops.c', 'test_bitmap.c', 'test_bpf.c',
@@ -160,6 +161,7 @@ test_deps += ['bus_pci', 'bus_vdev'] fast_tests = [ ['acl_autotest', true, true], ['atomic_autotest', false, true], + ['bitcount_autotest', true, true], ['bitmap_autotest', true, true], ['bpf_autotest', true, true], ['bpf_convert_autotest', true, true],
app/test/test_bitcount.c new file +71 -0
71 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH v3 3/3] test/bitcount: add bitcount tests
06/01/2023 23:01, Tyler Retzlaff:
Quoted 6 lines
basic unit test of following functions
rte_clz32 rte_clz64 rte_ctz32 rte_ctz64
This can be squashed with implementation in previous patch.
Re: [PATCH v3 3/3] test/bitcount: add bitcount tests
Quoted 11 lines · Thomas Monjalon
06/01/2023 23:01, Tyler Retzlaff:
Quoted 6 lines
basic unit test of following functions
rte_clz32 rte_clz64 rte_ctz32 rte_ctz64This can be squashed with implementation in previous patch.
if you mean squashed into the patch that moves the existing functions sure it can be, but really the addtions are a self contained change separate from the move of the existing functions.
ordinarily i'd rather see history order be as follows.
- here is a change that just moves code (no addtions no deletions).
- here is a change that adds new apis (no moves).
you sure you want the move and additions all combined into one change?
either way confirm what you want and if needed i'll combine and push a v4.
thanks
Re: [PATCH v3 3/3] test/bitcount: add bitcount tests
Quoted 19 lines · Tyler Retzlaff
Quoted 11 lines · Thomas Monjalon
06/01/2023 23:01, Tyler Retzlaff:
Quoted 6 lines
basic unit test of following functions
rte_clz32 rte_clz64 rte_ctz32 rte_ctz64This can be squashed with implementation in previous patch.
if you mean squashed into the patch that moves the existing functions sure it can be, but really the addtions are a self contained change separate from the move of the existing functions.
ordinarily i'd rather see history order be as follows.
Quoted 8 lines
- here is a change that just moves code (no addtions no deletions).
- here is a change that adds new apis (no moves).you sure you want the move and additions all combined into one change?
either way confirm what you want and if needed i'll combine and push a v4.
ignore the above, i misread what you were asking for. i will submit a new version with the unit tests squished in to the new function additions.
Quoted 1 line
thanks
RE: [PATCH v3 3/3] test/bitcount: add bitcount tests
In reply to Tyler RetzlaffQuoted 5 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Friday, 6 January 2023 23.02basic unit test of following functions
Quoted 7 lines
rte_clz32 rte_clz64 rte_ctz32 rte_ctz64Signed-off-by Tyler Retzlaff <[email protected]>---
Quoted 6 lines · Tyler Retzlaff
Move existing bit manipulation, log and npow functions from
rte_common.htorte_bitops.hProvide leading and trailing zero bit count functions to abstract away compiler specific implementations.
Quoted 7 lines
Include basic unit test for new leading/trailing zero bit count functions.
v3:
* rename to use 32/64 instead of l/ll suffixes
* add new functions torte_bitops.hinstead of new header
* move other bit functions fromrte_common.htorte_bitops.h
v5 cover eal: provide leading and trailing zero bit count abstraction
In reply to Tyler RetzlaffMove existing bit manipulation, log and npow functions from rte_common.h to rte_bitops.h
Provide leading and trailing zero bit count functions to abstract away compiler specific implementations.
Include basic unit test for new leading/trailing zero bit count functions.
v5:
* fix implementation of msvc versions of rte_clz{32,64} incorrect use of _BitscanReverse{,64} index.
* fix and expand unit test to exercise full range of counting over uint{32,64}_t input values. (which would have caught above mistake).
* reduce commit title length
* correct commit author
v4:
* combine unit test commit into function addition commit
v3:
* rename to use 32/64 instead of l/ll suffixes
* add new functions to rte_bitops.h instead of new header
* move other bit functions from rte_common.h to rte_bitops.h
v2:
* use unsigned int instead of unsigned (checkpatches)
* match multiple include guard naming convention to rte_common.h
* add explicit extern "C" linkage to rte_bitcount.h
note: not really needed but checkpatches required
* add missing space around '-'
Tyler Retzlaff (2):
eal: move bit operation common to bitops header
eal: provide leading and trailing zero bit count abstraction
app/test/meson.build | 2 + app/test/test_bitcount.c | 86 ++++++++ app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 460 ++++++++++++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ------------------------- 6 files changed, 550 insertions(+), 293 deletions(-) create mode 100644 app/test/test_bitcount.c
Signature · 2 lines
Series-acked-by: Morten Brørup <[email protected]> Series-acked-by: Bruce Richardson <[email protected]>
PATCH v5 1/2 eal: move bit operation common to bitops header
Move the following inline functions from rte_common.h to rte_bitops.h
rte_combine32ms1b
rte_combine64ms1b
rte_bsf32
rte_bsf32_safe
rte_bsf64
rte_bsf64_safe
rte_fls_u32
rte_fls_u64
rte_is_power_of_2
rte_align32pow2
rte_align32prevpow2
rte_align64pow2
rte_align64prevpow2
rte_log2_u32
rte_log2_u64
---
app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 292 +++++++++++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ---------------------------------------- 4 files changed, 294 insertions(+), 293 deletions(-)
app/test/test_common.c +1 -0
@@ -7,6 +7,7 @@#include <string.h> #include <math.h> #include <rte_common.h> +#include <rte_bitops.h> #include <rte_hexdump.h> #include <rte_pause.h>
lib/eal/common/rte_reciprocal.c +1 -0
@@ -8,6 +8,7 @@#include <stdint.h> #include <rte_common.h> +#include <rte_bitops.h> #include "rte_reciprocal.h"
lib/eal/include/rte_bitops.h +292 -0
298 lines not on this page · raw message
lib/eal/include/rte_common.h +0 -293
305 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v5 2/2 eal: provide leading and trailing zero bit count abstraction
In reply to Tyler RetzlaffProvide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Include basic unit test of following functions added.
rte_clz32
rte_clz64
rte_ctz32
rte_ctz64--- app/test/meson.build | 2 + app/test/test_bitcount.c | 94 ++++++++++++++++++++++++ lib/eal/include/rte_bitops.h | 168 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 264 insertions(+) create mode 100644 app/test/test_bitcount.c
app/test/meson.build +2 -0
@@ -13,6 +13,7 @@ test_sources = files( 'test_alarm.c', 'test_atomic.c', 'test_barrier.c', + 'test_bitcount.c', 'test_bitops.c', 'test_bitmap.c', 'test_bpf.c',
@@ -160,6 +161,7 @@ test_deps += ['bus_pci', 'bus_vdev'] fast_tests = [ ['acl_autotest', true, true], ['atomic_autotest', false, true], + ['bitcount_autotest', true, true], ['bitmap_autotest', true, true], ['bpf_autotest', true, true], ['bpf_convert_autotest', true, true],
app/test/test_bitcount.c new file +94 -0
94 lines not on this page · raw message
lib/eal/include/rte_bitops.h +168 -0
179 lines not on this page · raw message
Signature · 1 line
1.8.3.1
v6 cover eal: provide leading and trailing zero bit count abstraction
In reply to Tyler Retzlaffv6:
* remove stray #include <stdio.h>
v5:
* fix implementation of msvc versions of rte_clz{32,64} incorrect use of _BitscanReverse{,64} index.
* fix and expand unit test to exercise full range of counting over uint{32,64}_t input values. (which would have caught above mistake).
* reduce commit title length
* correct commit author
v4:
* combine unit test commit into function addition commit
v3:
* rename to use 32/64 instead of l/ll suffixes
* add new functions to rte_bitops.h instead of new header
* move other bit functions from rte_common.h to rte_bitops.h
v2:
* use unsigned int instead of unsigned (checkpatches)
* match multiple include guard naming convention to rte_common.h
* add explicit extern "C" linkage to rte_bitcount.h
note: not really needed but checkpatches required
* add missing space around '-'
Tyler Retzlaff (2):
eal: move bit operation common to bitops header
eal: provide leading and trailing zero bit count abstraction
app/test/meson.build | 2 + app/test/test_bitcount.c | 93 ++++++++ app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 460 ++++++++++++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ------------------------- 6 files changed, 557 insertions(+), 293 deletions(-) create mode 100644 app/test/test_bitcount.c
Signature · 2 lines
Series-acked-by: Morten Brørup <[email protected]> Series-acked-by: Bruce Richardson <[email protected]>
PATCH v6 1/2 eal: move bit operation common to bitops header
Move the following inline functions from rte_common.h to rte_bitops.h
rte_combine32ms1b
rte_combine64ms1b
rte_bsf32
rte_bsf32_safe
rte_bsf64
rte_bsf64_safe
rte_fls_u32
rte_fls_u64
rte_is_power_of_2
rte_align32pow2
rte_align32prevpow2
rte_align64pow2
rte_align64prevpow2
rte_log2_u32
rte_log2_u64
---
app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 292 +++++++++++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ---------------------------------------- 4 files changed, 294 insertions(+), 293 deletions(-)
app/test/test_common.c +1 -0
@@ -7,6 +7,7 @@#include <string.h> #include <math.h> #include <rte_common.h> +#include <rte_bitops.h> #include <rte_hexdump.h> #include <rte_pause.h>
lib/eal/common/rte_reciprocal.c +1 -0
@@ -8,6 +8,7 @@#include <stdint.h> #include <rte_common.h> +#include <rte_bitops.h> #include "rte_reciprocal.h"
lib/eal/include/rte_bitops.h +292 -0
298 lines not on this page · raw message
lib/eal/include/rte_common.h +0 -293
305 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v6 2/2 eal: provide leading and trailing zero bit count abstraction
In reply to Tyler RetzlaffProvide an abstraction for leading and trailing zero bit counting functions to hide compiler specific intrinsics and builtins.
Include basic unit test of following functions added.
rte_clz32
rte_clz64
rte_ctz32
rte_ctz64--- app/test/meson.build | 2 + app/test/test_bitcount.c | 93 ++++++++++++++++++++++++ lib/eal/include/rte_bitops.h | 168 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 263 insertions(+) create mode 100644 app/test/test_bitcount.c
app/test/meson.build +2 -0
@@ -13,6 +13,7 @@ test_sources = files( 'test_alarm.c', 'test_atomic.c', 'test_barrier.c', + 'test_bitcount.c', 'test_bitops.c', 'test_bitmap.c', 'test_bpf.c',
@@ -160,6 +161,7 @@ test_deps += ['bus_pci', 'bus_vdev'] fast_tests = [ ['acl_autotest', true, true], ['atomic_autotest', false, true], + ['bitcount_autotest', true, true], ['bitmap_autotest', true, true], ['bpf_autotest', true, true], ['bpf_convert_autotest', true, true],
app/test/test_bitcount.c new file +93 -0
93 lines not on this page · raw message
lib/eal/include/rte_bitops.h +168 -0
179 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH v6 0/2] eal: provide leading and trailing zero bit count abstraction
In reply to Tyler Retzlaffhi folks,
i think this one can probably be merged?
patch 1/2 Acked-by: Ferruh Yigit <[email protected]>
thanks!
Quoted 44 lines · Tyler Retzlaff
v6:
* remove stray #include <stdio.h>v5:
* fix implementation of msvc versions of rte_clz{32,64} incorrect use of _BitscanReverse{,64} index.
* fix and expand unit test to exercise full range of counting over uint{32,64}_t input values. (which would have caught above mistake).
* reduce commit title length
* correct commit authorv4:
* combine unit test commit into function addition commitv3:
* rename to use 32/64 instead of l/ll suffixes
* add new functions torte_bitops.hinstead of new header
* move other bit functions fromrte_common.htorte_bitops.hv2:
* use unsigned int instead of unsigned (checkpatches)
* match multiple include guard naming convention torte_common.h
* add explicit extern "C" linkage torte_bitcount.h
note: not really needed but checkpatches required
* add missing space around '-'Tyler Retzlaff (2):
eal: move bit operation common to bitops header
eal: provide leading and trailing zero bit count abstractionapp/test/meson.build | 2 + app/test/test_bitcount.c | 93 ++++++++ app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 460 ++++++++++++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ------------------------- 6 files changed, 557 insertions(+), 293 deletions(-) create mode 100644 app/test/test_bitcount.cSignature · 2 lines
Series-acked-by: Morten Brørup <[email protected]> Series-acked-by: Bruce Richardson <[email protected]>
Re: [PATCH v6 0/2] eal: provide leading and trailing zero bit count abstraction
Hello Tyler,
Quoted 8 lines · Tyler Retzlaff
hi folks,
i think this one can probably be merged?
Series-acked-by Morten Brørup <[email protected]>Series-acked-by Bruce Richardson <[email protected]>patch 1/2 Acked-by: Ferruh Yigit <[email protected]>
I like the cleanup of rte_common.h and additional unit tests, but the MSVC bits don't belong here.
Please move them in your MSVC enablement series
https://patchwork.dpdk.org/project/dpdk/list/?series=26662&state=%2A&archive=both.
Thanks.
Signature · 1 line
David Marchand
Re: [PATCH v6 0/2] eal: provide leading and trailing zero bit count abstraction
Quoted 10 lines · David Marchand
Hello Tyler,
Quoted 5 lines · Tyler Retzlaff
hi folks,
i think this one can probably be merged?
Quoted 8 lines
Quoted 3 lines
Series-acked-by Morten Brørup <[email protected]>Series-acked-by Bruce Richardson <[email protected]>patch 1/2 Acked-by: Ferruh Yigit <[email protected]>
I like the cleanup of
rte_common.hand additional unit tests, but the MSVC bits don't belong here.
Please move them in your MSVC enablement series
https://patchwork.dpdk.org/project/dpdk/list/?series=26662&state=%2A&archive=both.
Addendum, running the series through my checks, I can see that test_bitcount.c is left unattended wrt the MAINTAINERS file. app/test/test_bitcount.c must be put under the "EAL API and common code" section.
Thanks.
Signature · 1 line
David Marchand
Re: [PATCH v6 0/2] eal: provide leading and trailing zero bit count abstraction
Quoted 21 lines · David Marchand
Quoted 10 lines · David Marchand
Hello Tyler,
Quoted 5 lines · Tyler Retzlaff
hi folks,
i think this one can probably be merged?
Quoted 8 lines
Quoted 3 lines
Series-acked-by Morten Brørup <[email protected]>Series-acked-by Bruce Richardson <[email protected]>patch 1/2 Acked-by: Ferruh Yigit <[email protected]>
I like the cleanup of
rte_common.hand additional unit tests, but the MSVC bits don't belong here.
Please move them in your MSVC enablement series
https://patchwork.dpdk.org/project/dpdk/list/?series=26662&state=%2A&archive=both.
Quoted 4 lines
Addendum, running the series through my checks, I can see that
test_bitcount.cis left unattended wrt theMAINTAINERSfile.app/test/test_bitcount.cmust be put under the "EAL API and common code" section.
is this an automated check i should have run prior to submission?
either way i'll fix that up, sorry for the mistake.
Quoted 4 lines
Thanks.
Signature · 1 line
David Marchand
Re: [PATCH v6 0/2] eal: provide leading and trailing zero bit count abstraction
Quoted 11 lines · Tyler Retzlaff
Quoted 9 lines
Quoted 4 lines
I like the cleanup of
rte_common.hand additional unit tests, but the MSVC bits don't belong here.
Please move them in your MSVC enablement series
https://patchwork.dpdk.org/project/dpdk/list/?series=26662&state=%2A&archive=both.Addendum, running the series through my checks, I can see that
test_bitcount.cis left unattended wrt theMAINTAINERSfile.app/test/test_bitcount.cmust be put under the "EAL API and common code" section.is this an automated check i should have run prior to submission?
The script is devtools/check-maintainers.sh.
But unfortunately it is not run in the CI as its author never made it reliable enough: it has false positives / known issues / accepted issues.
Users (I guess Thomas and I, maybe some subtree maintainers) keep a local reference of this script output, and compare against it.
This is something that is rarely needed: in general additions are done as a single component in MAINTAINERS, so people naturally add themselves with the top level directory, and that's it.
So I guess our current check is good enough.
Quoted 2 lines
either way i'll fix that up, sorry for the mistake.
No worries, this is not something you could easily find unless grepping and looking how things were done for other unit tests.
Signature · 1 line
David Marchand
Re: [PATCH v6 0/2] eal: provide leading and trailing zero bit count abstraction
In reply to David MarchandQuoted 9 lines · David Marchand
Hello Tyler,
Quoted 5 lines · Tyler Retzlaff
hi folks,
i think this one can probably be merged?
Quoted 7 lines
Quoted 3 lines
Series-acked-by Morten Brørup <[email protected]>Series-acked-by Bruce Richardson <[email protected]>patch 1/2 Acked-by: Ferruh Yigit <[email protected]>
I like the cleanup of
rte_common.hand additional unit tests, but the MSVC bits don't belong here.
Please move them in your MSVC enablement series
hm, the way i'm approaching this is to keep specific features together similar to if i added new platform functionality for threads i add windows or linux in the same series. similarly, in this case i'm adding msvc and gcc in the same series.
the msvc enablement series introduces the changes for the build system so it's about enabling a compiler not adding functionality to dpdk so this change/API really aren't related to the other, but i agree the other series is part of converging on the platform, toolchain combination being enabled overall.
reconsider? if not i guess i'll just withdraw the actual API for now and have to resubmit and review later since i don't think it belongs mixed in with the compiler enablement.
if the msvc series were just merged, i think the above discussion would be moot no?
anyway, i'll abide by whatever decision you go with.
thanks!
Re: [PATCH v6 0/2] eal: provide leading and trailing zero bit count abstraction
Quoted 30 lines · Tyler Retzlaff
Quoted 9 lines · David Marchand
Hello Tyler,
Quoted 5 lines · Tyler Retzlaff
hi folks,
i think this one can probably be merged?
Quoted 7 lines
Quoted 3 lines
Series-acked-by Morten Brørup <[email protected]>Series-acked-by Bruce Richardson <[email protected]>patch 1/2 Acked-by: Ferruh Yigit <[email protected]>
I like the cleanup of
rte_common.hand additional unit tests, but the MSVC bits don't belong here.
Please move them in your MSVC enablement serieshm, the way i'm approaching this is to keep specific features together similar to if i added new platform functionality for threads i add windows or linux in the same series. similarly, in this case i'm adding msvc and gcc in the same series.
the msvc enablement series introduces the changes for the build system so it's about enabling a compiler not adding functionality to dpdk so this change/API really aren't related to the other, but i agree the other series is part of converging on the platform, toolchain combination being enabled overall.
Quoted 8 lines
reconsider? if not i guess i'll just withdraw the actual API for now and have to resubmit and review later since i don't think it belongs mixed in with the compiler enablement.
if the msvc series were just merged, i think the above discussion would be moot no?
Indeed, but until we have support for MSVC, this part of the patch is putting dead (untested) code in the tree.
It is also confusing to see references to MSVC in the tree while we have nothing setting this config item, and no documentation explaining how/when this will be actually usable.
Signature · 1 line
David Marchand
v7 cover eal: provide abstracted bit counting functions
In reply to Tyler RetzlaffAs discussed technical board meeting 2023-02-22
http://mails.dpdk.org/archives/dev/2023-February/263516.html
We will bring support in pieces for the MSVC compiler, there will be some abstractions and functions introduced before the compiler is capable of compiling DPDK in order to make parallel progress while waiting for standard atomics in 23.07.
A higher level plan / order of work is available in the Microsoft roadmap for 23.07 and 23.11.
note:
Morten Brørup and Bruce Richardson previous acks have been preserved but be aware of the two additional functions introduced in v7. If you wish to withdraw your ack, please let me know but I believe the 2 additions are consistent with previous.
v7:
* add 2 additional counting functions rte_popcount{32,64} including basic unit tests
* fix patch 1 title link (CI complained too long)
* add test_bitcount.c entry to MAINTAINERS file
v6:
* remove stray #include <stdio.h>
v5:
* fix implementation of msvc versions of rte_clz{32,64} incorrect use of _BitscanReverse{,64} index.
* fix and expand unit test to exercise full range of counting over uint{32,64}_t input values. (which would have caught above mistake).
* reduce commit title length
* correct commit author
v4:
* combine unit test commit into function addition commit
v3:
* rename to use 32/64 instead of l/ll suffixes
* add new functions to rte_bitops.h instead of new header
* move other bit functions from rte_common.h to rte_bitops.h
v2:
* use unsigned int instead of unsigned (checkpatches)
* match multiple include guard naming convention to rte_common.h
* add explicit extern "C" linkage to rte_bitcount.h
note: not really needed but checkpatches required
* add missing space around '-'
Tyler Retzlaff (4):
eal: move bit count functions to bitops header
eal: provide abstracted bit count functions
pipeline: add include of bitops
maintainers: add bitcount test under EAL API and common code
MAINTAINERS | 1 + app/test/meson.build | 2 + app/test/test_bitcount.c | 136 ++++++++ app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 532 +++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ----------------- lib/pipeline/rte_swx_pipeline_internal.h | 1 + 8 files changed, 674 insertions(+), 293 deletions(-) create mode 100644 app/test/test_bitcount.c
Signature · 1 line
1.8.3.1
PATCH v7 1/4 eal: move bit count functions to bitops header
Move the following inline functions from rte_common.h to rte_bitops.h
rte_combine32ms1b
rte_combine64ms1b
rte_bsf32
rte_bsf32_safe
rte_bsf64
rte_bsf64_safe
rte_fls_u32
rte_fls_u64
rte_is_power_of_2
rte_align32pow2
rte_align32prevpow2
rte_align64pow2
rte_align64prevpow2
rte_log2_u32
rte_log2_u64
--- app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 292 +++++++++++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ---------------------------------------- 4 files changed, 294 insertions(+), 293 deletions(-)
app/test/test_common.c +1 -0
@@ -7,6 +7,7 @@#include <string.h> #include <math.h> #include <rte_common.h> +#include <rte_bitops.h> #include <rte_hexdump.h> #include <rte_pause.h>
lib/eal/common/rte_reciprocal.c +1 -0
@@ -8,6 +8,7 @@#include <stdint.h> #include <rte_common.h> +#include <rte_bitops.h> #include "rte_reciprocal.h"
lib/eal/include/rte_bitops.h +292 -0
298 lines not on this page · raw message
lib/eal/include/rte_common.h +0 -293
305 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v7 2/4 eal: provide abstracted bit count functions
In reply to Tyler RetzlaffProvide abstracted bit counting functions for count, leading and trailing bits in v to hide compiler specific intrinsics and builtins.
Include basic unit test of following functions added.
rte_clz32
rte_clz64
rte_ctz32
rte_ctz64
rte_popcount32
rte_popcount64--- app/test/meson.build | 2 + app/test/test_bitcount.c | 136 ++++++++++++++++++++++++ lib/eal/include/rte_bitops.h | 240 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 378 insertions(+) create mode 100644 app/test/test_bitcount.c
app/test/meson.build +2 -0
@@ -13,6 +13,7 @@ test_sources = files( 'test_alarm.c', 'test_atomic.c', 'test_barrier.c', + 'test_bitcount.c', 'test_bitops.c', 'test_bitmap.c', 'test_bpf.c',
@@ -161,6 +162,7 @@ test_deps += ['bus_pci', 'bus_vdev'] fast_tests = [ ['acl_autotest', true, true], ['atomic_autotest', false, true], + ['bitcount_autotest', true, true], ['bitmap_autotest', true, true], ['bpf_autotest', true, true], ['bpf_convert_autotest', true, true],
app/test/test_bitcount.c new file +136 -0
136 lines not on this page · raw message
lib/eal/include/rte_bitops.h +240 -0
251 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v7 3/4 pipeline: add include of bitops
In reply to Tyler RetzlaffInclude rte_bitops.h with the inline functions moving this include is now needed.
--- lib/pipeline/rte_swx_pipeline_internal.h | 1 + 1 file changed, 1 insertion(+)
lib/pipeline/rte_swx_pipeline_internal.h +1 -0
@@ -8,6 +8,7 @@#include <string.h> #include <sys/queue.h> +#include <rte_bitops.h> #include <rte_byteorder.h> #include <rte_common.h> #include <rte_cycles.h>
Signature · 1 line
1.8.3.1
PATCH v7 4/4 maintainers: add bitcount test under EAL API and common code
In reply to Tyler RetzlaffList app/test/test_bitcount.c under EAL API and common code.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -155,6 +155,7 @@ F: doc/guides/prog_guide/env_abstraction_layer.rst F: app/test/test_alarm.c F: app/test/test_atomic.c F: app/test/test_barrier.c +F: app/test/test_bitcount.c F: app/test/test_byteorder.c F: app/test/test_common.c F: app/test/test_cpuflags.c
Signature · 1 line
1.8.3.1
RE: [PATCH v7 0/4] eal: provide abstracted bit counting functions
In reply to Tyler RetzlaffQuoted 2 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Saturday, 1 April 2023 02.45
[...]
Quoted 6 lines
note:
Morten Brørup and Bruce Richardson previous acks have been preserved but be aware of the two additional functions introduced in v7. If you wish to withdraw your ack, please let me know but I believe the 2 additions are consistent with previous.
The additions check out OK. My Ack remains. :-)
v8 cover eal: provide abstracted bit counting functions
In reply to Tyler RetzlaffAs discussed technical board meeting 2023-02-22
http://mails.dpdk.org/archives/dev/2023-February/263516.html
We will bring support in pieces for the MSVC compiler, there will be some abstractions and functions introduced before the compiler is capable of compiling DPDK in order to make parallel progress while waiting for standard atomics in 23.07.
A higher level plan / order of work is available in the Microsoft roadmap for 23.07 and 23.11.
note:
Bruce Richardson previous acks have been preserved but be aware of the two additional functions introduced in v7. If you wish to withdraw your ack, please let me know but I believe the 2 additions are consistent with previous.
v8:
* squish patch including rte_bitops.h in lib/pipeline into first patch.
v7:
* add 2 additional counting functions rte_popcount{32,64} including basic unit tests
* fix patch 1 title link (CI complained too long)
* add test_bitcount.c entry to MAINTAINERS file
v6:
* remove stray #include <stdio.h>
v5:
* fix implementation of msvc versions of rte_clz{32,64} incorrect use of _BitscanReverse{,64} index.
* fix and expand unit test to exercise full range of counting over uint{32,64}_t input values. (which would have caught above mistake).
* reduce commit title length
* correct commit author
v4:
* combine unit test commit into function addition commit
v3:
* rename to use 32/64 instead of l/ll suffixes
* add new functions to rte_bitops.h instead of new header
* move other bit functions from rte_common.h to rte_bitops.h
v2:
* use unsigned int instead of unsigned (checkpatches)
* match multiple include guard naming convention to rte_common.h
* add explicit extern "C" linkage to rte_bitcount.h
note: not really needed but checkpatches required
* add missing space around '-'
Tyler Retzlaff (3):
eal: move bit count functions to bitops header
eal: provide abstracted bit count functions
maintainers: add bitcount test under EAL API and common code
MAINTAINERS | 1 + app/test/meson.build | 2 + app/test/test_bitcount.c | 136 ++++++++ app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 532 +++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ----------------- lib/pipeline/rte_swx_pipeline_internal.h | 1 + 8 files changed, 674 insertions(+), 293 deletions(-) create mode 100644 app/test/test_bitcount.c
Signature · 1 line
1.8.3.1
PATCH v8 1/3 eal: move bit count functions to bitops header
Move the following inline functions from rte_common.h to rte_bitops.h
rte_combine32ms1b
rte_combine64ms1b
rte_bsf32
rte_bsf32_safe
rte_bsf64
rte_bsf64_safe
rte_fls_u32
rte_fls_u64
rte_is_power_of_2
rte_align32pow2
rte_align32prevpow2
rte_align64pow2
rte_align64prevpow2
rte_log2_u32
rte_log2_u64
--- app/test/test_common.c | 1 + lib/eal/common/rte_reciprocal.c | 1 + lib/eal/include/rte_bitops.h | 292 ++++++++++++++++++++++++++++++ lib/eal/include/rte_common.h | 293 ------------------------------- lib/pipeline/rte_swx_pipeline_internal.h | 1 + 5 files changed, 295 insertions(+), 293 deletions(-)
app/test/test_common.c +1 -0
@@ -7,6 +7,7 @@#include <string.h> #include <math.h> #include <rte_common.h> +#include <rte_bitops.h> #include <rte_hexdump.h> #include <rte_pause.h>
lib/eal/common/rte_reciprocal.c +1 -0
@@ -8,6 +8,7 @@#include <stdint.h> #include <rte_common.h> +#include <rte_bitops.h> #include "rte_reciprocal.h"
lib/eal/include/rte_bitops.h +292 -0
298 lines not on this page · raw message
lib/eal/include/rte_common.h +0 -293
305 lines not on this page · raw message
lib/pipeline/rte_swx_pipeline_internal.h +1 -0
@@ -8,6 +8,7 @@#include <string.h> #include <sys/queue.h> +#include <rte_bitops.h> #include <rte_byteorder.h> #include <rte_common.h> #include <rte_cycles.h>
Signature · 1 line
1.8.3.1
PATCH v8 2/3 eal: provide abstracted bit count functions
In reply to Tyler RetzlaffProvide abstracted bit counting functions for count, leading and trailing bits in v to hide compiler specific intrinsics and builtins.
Include basic unit test of following functions added.
rte_clz32
rte_clz64
rte_ctz32
rte_ctz64
rte_popcount32
rte_popcount64--- app/test/meson.build | 2 + app/test/test_bitcount.c | 136 ++++++++++++++++++++++++ lib/eal/include/rte_bitops.h | 240 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 378 insertions(+) create mode 100644 app/test/test_bitcount.c
app/test/meson.build +2 -0
@@ -13,6 +13,7 @@ test_sources = files( 'test_alarm.c', 'test_atomic.c', 'test_barrier.c', + 'test_bitcount.c', 'test_bitops.c', 'test_bitmap.c', 'test_bpf.c',
@@ -161,6 +162,7 @@ test_deps += ['bus_pci', 'bus_vdev'] fast_tests = [ ['acl_autotest', true, true], ['atomic_autotest', false, true], + ['bitcount_autotest', true, true], ['bitmap_autotest', true, true], ['bpf_autotest', true, true], ['bpf_convert_autotest', true, true],
app/test/test_bitcount.c new file +136 -0
136 lines not on this page · raw message
lib/eal/include/rte_bitops.h +240 -0
251 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v8 3/3 maintainers: add bitcount test under EAL API and common code
In reply to Tyler RetzlaffList app/test/test_bitcount.c under EAL API and common code.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -155,6 +155,7 @@ F: doc/guides/prog_guide/env_abstraction_layer.rst F: app/test/test_alarm.c F: app/test/test_atomic.c F: app/test/test_barrier.c +F: app/test/test_bitcount.c F: app/test/test_byteorder.c F: app/test/test_common.c F: app/test/test_cpuflags.c
Signature · 1 line
1.8.3.1
Re: [PATCH v8 0/3] eal: provide abstracted bit counting functions
In reply to Tyler RetzlaffQuoted 8 lines · Tyler Retzlaff
As discussed technical board meeting 2023-02-22
http://mails.dpdk.org/archives/dev/2023-February/263516.htmlWe will bring support in pieces for the MSVC compiler, there will be some abstractions and functions introduced before the compiler is capable of compiling DPDK in order to make parallel progress while waiting for standard atomics in 23.07.
Quoted 9 lines
A higher level plan / order of work is available in the Microsoft roadmap for 23.07 and 23.11.
note:
Bruce Richardson previous acks have been preserved but be aware of the two additional functions introduced in v7. If you wish to withdraw your ack, please let me know but I believe the 2 additions are consistent with previous.
All good, keeping them is fine.
Thanks,
/Bruce
Re: [PATCH v8 0/3] eal: provide abstracted bit counting functions
In reply to Tyler RetzlaffQuoted 11 lines · Tyler Retzlaff
As discussed technical board meeting 2023-02-22
http://mails.dpdk.org/archives/dev/2023-February/263516.htmlWe will bring support in pieces for the MSVC compiler, there will be some abstractions and functions introduced before the compiler is capable of compiling DPDK in order to make parallel progress while waiting for standard atomics in 23.07.
A higher level plan / order of work is available in the Microsoft roadmap for 23.07 and 23.11.
I rebased this series following Bruce rework on app/test/ and applied it. Thanks.
Signature · 1 line
David Marchand