From: Xueming Li <xuemingl@nvidia.com>
To: <dev@dpdk.org>
Cc: Thomas Monjalon <thomas@monjalon.net>, <xuemingl@nvidia.com>,
"Cristian Dumitrescu" <cristian.dumitrescu@intel.com>,
Jasvinder Singh <jasvinder.singh@intel.com>
Subject: [dpdk-dev] [PATCH v1] sched: adds function to get 64 bits greatest common divisor
Date: Wed, 15 Sep 2021 18:26:10 +0800 [thread overview]
Message-ID: <20210915102610.83105-1-xuemingl@nvidia.com> (raw)
In-Reply-To: <20210823081539.1410259-1-xuemingl@nvidia.com>
This patch adds new function that compute the greatest common
divisor of 64 bits, also changes the original 32 bits function to call
this new 64 bits version.
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
v1: add 64 bits version and make 32 bits api call it
lib/sched/rte_sched_common.h | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/lib/sched/rte_sched_common.h b/lib/sched/rte_sched_common.h
index 96706df7bd..1056543a84 100644
--- a/lib/sched/rte_sched_common.h
+++ b/lib/sched/rte_sched_common.h
@@ -51,10 +51,10 @@ rte_min_pos_4_u16(uint16_t *x)
* gcd(a, b) = gcd(b, a mod b)
*
*/
-static inline uint32_t
-rte_get_gcd(uint32_t a, uint32_t b)
+static inline uint64_t
+rte_get_gcd64(uint64_t a, uint64_t b)
{
- uint32_t c;
+ uint64_t c;
if (a == 0)
return b;
@@ -76,6 +76,19 @@ rte_get_gcd(uint32_t a, uint32_t b)
return a;
}
+/*
+ * Compute the Greatest Common Divisor (GCD) of two u32 numbers.
+ * This implementation uses Euclid's algorithm:
+ * gcd(a, 0) = a
+ * gcd(a, b) = gcd(b, a mod b)
+ *
+ */
+static inline uint32_t
+rte_get_gcd(uint32_t a, uint32_t b)
+{
+ return rte_get_gcd64(a, b);
+}
+
/*
* Compute the Lowest Common Denominator (LCD) of two numbers.
* This implementation computes GCD first:
--
2.33.0
next prev parent reply other threads:[~2021-09-15 10:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-23 8:15 [dpdk-dev] [PATCH] sched: support " Xueming Li
2021-09-15 10:26 ` Xueming Li [this message]
2021-09-22 17:09 ` [dpdk-dev] [PATCH v1] sched: adds function to get " Kevin Traynor
2021-09-23 5:34 ` Xueming(Steven) Li
2021-09-23 8:11 ` [dpdk-dev] [PATCH v2 0/2] " Xueming Li
2021-09-23 8:11 ` [dpdk-dev] [PATCH v2 1/2] " Xueming Li
2021-09-23 9:53 ` Kevin Traynor
2021-09-23 8:11 ` [dpdk-dev] [PATCH v2 2/2] vdpa/mlx5: fix large VM memory region registration Xueming Li
2021-09-27 15:26 ` [dpdk-dev] [PATCH v2 0/2] sched: adds function to get 64 bits greatest common divisor Thomas Monjalon
2021-09-28 5:47 ` Xueming(Steven) Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210915102610.83105-1-xuemingl@nvidia.com \
--to=xuemingl@nvidia.com \
--cc=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
--cc=jasvinder.singh@intel.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).