From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C12BDA0C41; Wed, 15 Sep 2021 12:26:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A487B4003F; Wed, 15 Sep 2021 12:26:43 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2082.outbound.protection.outlook.com [40.107.237.82]) by mails.dpdk.org (Postfix) with ESMTP id D2F364003C for ; Wed, 15 Sep 2021 12:26:41 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VzAashJb0Zu2yoopc++8r7zXEw1PLjGW2UC9HWHpeBvhn1JKuXFWjnhRVeta0fXUAnMgeGUX6MBW5R+6B1X3HeOsfdOqfpUyktAhBGvClLkuVALDGPgSqaZPz1v8vHe6mWe+4ss0ihFowy/5YrSBuOoE1y79yDULA4AiSmaOKLmtmMnCWxcrDW+ILm1NiYILLn72iuicIxRzb+DyIXy8rf8PrzDXQZf5NgN0daO23VZ3XB9Yq821ZqnhqJ2M2BqbiYYoykdH471kCalV4BGxy56GuSqkcLW9pUpNgevL01kUwbodwttpZMNbsrIauVGDjrkXpoH510HcIhbmgA01bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=9FkgIUgXFkhb6yNHvrOTK2YcuKEuOkpws0h9SjNRUIw=; b=MRucvt3RcNzJL+WmSsJTQQSgCo6Uu86UDosVeze3F8EswLaYRJr1K0FPm1Xj39r0klqykqSDBphN7XgSn0AydnDs5KKOznzb/gONDo/wIeCdhGOdlBidXbs48rdaP0QZ/EVZSCwTviySL9D8ejrbTIJWYPYcUuMSns7dYTgl9SncQPVU4ZDLN/1SZI9koB+d/uHbx2+V3Gf4AW7ljYSC3EBPmvFrAwy2pO4Joy95R0LPeKldP1T/dOUyfL0amFSD4pgOuMUENsIPd/RtMUfr69u/Nqenuvtn4SkvGf0RSxKK/YR6OHGayO+jCdsaZNlN2UJXdRrkciWDopqdl3ZW9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.35) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9FkgIUgXFkhb6yNHvrOTK2YcuKEuOkpws0h9SjNRUIw=; b=X5pHC0l/WmvI4sUNpiSWne5tHjlNICRldKmgVXlqow1MS+lveVXaoIZ8zixxfIs7Y0VFSCBHSWwuava+2IM5Bg2PTy+McpqZNCWc+H2VWP9mYWXvZPmgqJhqFbKzYzEtWm3FC8bBBLOBV0pNSxxpFfTW61m4SZAa2ySUlX+uI8Xcyeun8EgfFOIfQljq//cSWtnexckq1kcHYxQD/yMiSIHQS102eN7+SQVkO+IwVXl99DSB42ruBYfR+7U3+n/cg6Pb0TCZ2PnaeDtGNUa/j5i+Oyp0r9qQmXUM2Dil7d1K2z6R2OBb1cHEdtufHNWU+c79vPGIkH3vJY5DT+YefQ== Received: from MWHPR02CA0011.namprd02.prod.outlook.com (2603:10b6:300:4b::21) by DM6PR12MB4636.namprd12.prod.outlook.com (2603:10b6:5:161::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 15 Sep 2021 10:26:38 +0000 Received: from CO1NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:300:4b:cafe::25) by MWHPR02CA0011.outlook.office365.com (2603:10b6:300:4b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Wed, 15 Sep 2021 10:26:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.35) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.35 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.35; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.35) by CO1NAM11FT053.mail.protection.outlook.com (10.13.175.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4523.14 via Frontend Transport; Wed, 15 Sep 2021 10:26:38 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 15 Sep 2021 10:26:38 +0000 Received: from nvidia.com (172.20.187.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 15 Sep 2021 10:26:36 +0000 From: Xueming Li To: CC: Thomas Monjalon , , "Cristian Dumitrescu" , Jasvinder Singh Date: Wed, 15 Sep 2021 18:26:10 +0800 Message-ID: <20210915102610.83105-1-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210823081539.1410259-1-xuemingl@nvidia.com> References: <20210823081539.1410259-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac77eb79-ccef-4d1a-4447-08d978334d66 X-MS-TrafficTypeDiagnostic: DM6PR12MB4636: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1227; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hSsuPsFu1Au7YWGz9z05eTMWhUFKnUKQIvihA9QF9xOqEnO97DiASNYBVpvmnM8b12CRSAyapfB53jOPdJHTEV/enNUerGk1BACI4YGAllsyooCEv+ltfV2Qvy9ORIcddU3EYk11VkEl6EuEqcw3Sr0WuxR5Aw3a1UEUVzGbirEtx0+xLtaM0r7iYO8zCeBwLXugrCoj9G3wybQ57qa+BweyoQWHHXzRfzinKI62D1Qps49EV6IquBmIyNulwoOT/RabB/qqInzca4NTKNvV9syaXOAwx+y0XPEvjpm/FDiHULzuErGYc04xlH3uoIgveuqPitkmgX+96CHqusKYKLVtbzas6rF4F10grtAyMDHgRY7x8Pa629IFa+mLSkvDy151Nkv+q+Rn0UYkgJmEHYiT9knZ8rjPz8XFy4cQVRpDgqkipqci9uysxhmnO/kcrocgA2N/mG3xzJi8XKgaVh86XPSD/f3+h5EKfUUUiEgYAld4zWKmMRcsI6itDE3YG8vIyWCUnC2by0JnhGPMcuWtutcVvaoueEZOFI3sNyzW3JrdgvO62yGmqi0vOhl2qyXwxilhFgK/jF0xzZNcDufU3F9i+zYXCujNnwqaoJJeTE5wAUtNC53JcagCvtxxP6W2xbSHGbaeJp/F/wTBAoqRUNxtRr/SS4N0Jrxi4uIHq/TIXwirvhwMP3UXWdzKPS6hG2n4GUcRN04dGRNgwg== X-Forefront-Antispam-Report: CIP:216.228.112.35; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid02.nvidia.com; CAT:NONE; SFS:(4636009)(136003)(376002)(396003)(39860400002)(346002)(46966006)(36840700001)(82740400003)(70206006)(54906003)(7696005)(1076003)(26005)(86362001)(36906005)(36756003)(70586007)(316002)(8936002)(16526019)(5660300002)(6916009)(186003)(8676002)(2616005)(6286002)(336012)(426003)(83380400001)(47076005)(4326008)(6666004)(356005)(478600001)(36860700001)(7636003)(82310400003)(55016002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 10:26:38.5669 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac77eb79-ccef-4d1a-4447-08d978334d66 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.35]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4636 Subject: [dpdk-dev] [PATCH v1] sched: adds function to get 64 bits greatest common divisor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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