From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0063.outbound.protection.outlook.com [104.47.34.63]) by dpdk.org (Postfix) with ESMTP id E7BD43254 for ; Tue, 5 Sep 2017 12:49:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=GiS/an4YlByfAcPYz9uuRYHL7WbFJj7OMS+G0Wq04cU=; b=B7tXguKSkNmMaVZAGX60qumhOIyNKADcH92KDYsfdQUi2bodV/weANW7dXuNUzwMtDjTMPAYNiitRpR/LI4i9l5ozaUIfC8UEmDNLJFVoiWk+F2FWhgPf5CPznk/e98sObVERiJnRGHO79jQrtS0+HBbmdgkF/YbhueDmDA4gc8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from PBHAGAVATULA-LT.caveonetworks.com (111.93.218.67) by CY4PR07MB3461.namprd07.prod.outlook.com (10.171.252.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Tue, 5 Sep 2017 10:49:10 +0000 From: Pavan Nikhilesh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, stephen@networkplumber.org, Pavan Bhagavatula Date: Tue, 5 Sep 2017 16:18:50 +0530 Message-Id: <1504608532-18598-1-git-send-email-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MWHPR15CA0070.namprd15.prod.outlook.com (10.174.254.32) To CY4PR07MB3461.namprd07.prod.outlook.com (10.171.252.142) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f5fb0cb5-92ed-4dbd-3488-08d4f44bbea1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CY4PR07MB3461; X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3461; 3:CDCXisZknfCUQg0wp807BsgxJ+Ue4kZulMp1eCxE7lj/DdyWVCQJsPNd0ry9Zmj825lCRfDux7HfpeLVE+K7qunxhK0IVFCYTJIURde5s4ZLwlKA5L6qupv0aobrCacA+d7xdvuQARARpOv6A3vs+SrDCETFkc+8vq43Iz1H4GHJFeqMtCa6RQoIMbD2SOXJ9XL50f+yFGxSZpfD0x4N0CoMvdpG8LydY5OoxSgaf7DBBaESNsV3ZIzv+nd50hrG; 25:55JSwG6KDm/DDpy6hob1k8xsVm4gfQ19Uw80yAxHC4Qe/BQvwBW5GNqzbWdoC6PaKMdR6C3Q7xQICVhgPhDzc0MhweeUIKNEjWngHmpPLFHl8oFtkCscCBFRelUpU//L0KkaoR1IEAuu6O2wpqTsp3l6p9HOZWq07fxviyLTDqlLe/wJdIFeqNKMkFO2S+yaPlTHj0pHLH2oXAqinqmApnSiNC0/MAnMEdkJePjXy4R1gtSUQuDl/Gzgw3KGnKqm8D6tlxqGugXSnajuRsv29XQy4s4139ISh1V/X6ESGqr2f1UWC66v8H5Kg/r6WAWDkjWwOB+0y8bxv0ibj4mOtw==; 31:EAVLhB+l9cjaJV9Ut3xV6z1dDSGC0HxNxj/0T5jC+4fsyfH7izkFjw5JP7qjJoDrh+WuoRODX8X2sOu4SsntnHVSLBtjyayz8pro+zawEpYwjXN2ahOKaKx1Q88i/0ASvl8eUtuC7PvkilEXb6xuEtHYtttJ4smrIpj/b2qM3Q8Y6nvTo7Zuh5tzf1koJfR+4J346LM7U3obhJedekxz67R7Q5lkjhOiV4WXo7D/yB0= X-MS-TrafficTypeDiagnostic: CY4PR07MB3461: X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3461; 20:i4iI6k7ZL22TWDsHbLgc7CRTjv/+Io7wn4MHpRloD4rzdPLH9Xi3I+GNR6V31brCCQwCR78qZqV/yk++E1BN/k5JBViP0m1jzMhilzS+qflgm3Z7n7zGOvguOuFlLu91pVkojiCro0A7HVu8ZX/Gght/MS0tX4oxTrf/VKrNhTPAJc/qq7PZEsGquO/IzzjFi4SdZYAs5ieyHtphTc8tJk3NgU9t3UHZ/R70/UC7F8HbCVqZh67jGYKiodMCfqGuspQNIyi6IDXxipBvcJcBr+dgBWts/w7rhsrFYQEsz/cVLES6rwlUJEXypThNv5VfonEpRISAwBm3rLYNIEF/ikvHRBLtjL5B2U38+7xlwys5JILRSbuyyNcakxozgtLOCt8v+/DQBF9Fwjha0lagVVi7Q+mY6qxM7ON7IBE3TtVzskVUMPH9lmWlRDrTSRmkcQAZYmLdFjTwZP7DwjZafJCv6sWV3s64A/8cPFJMoJ8Ls6KFdJEGXgSg4Yem6PraSIxn3tdXFHlVKUQ8ouTDezBjIdD6SYo+EBTnIRl6SnubuJVp+FUfEDs4M2FXbedyfrjiWNeaqW2NshfFdcyBOluC7N6gBktGsiZieRxc5W4= X-Exchange-Antispam-Report-Test: UriScan:(278428928389397)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(10201501046)(93006095)(100000703101)(100105400095)(3002001)(6041248)(20161123555025)(20161123560025)(20161123558100)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR07MB3461; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR07MB3461; X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3461; 4:0KCzCAur5+/CBddkfr3nHZi3tJz4DNu8F3MQCLi9JcgxJcweOw1luHsAOP88q1SkimTxKXXw+m1N52WIztNy9Osh6KPBUy4/fdjP5IB99g6yCaKEmSeZ1KJNmcjogXVG4Iq8h5vB5hTez/mVRrpJF21MaYtt7CuxFTq4KfSV0I6baTgdUWlbBqJKBFjK0v6UEeKuUnvluS7obEyQ6VAQB9EU/WeRe6IHgF1jepU0E99HBkGAZFvIpJMtfWmsEsAAmSxz4heKXRdMS+hmvpi/fvyUgYXD4fynDu+5bjCLR19p6szylQwHqSg+p6GsFf9Ehq6prGnKh2YMeGHB9ehz6w== X-Forefront-PRVS: 0421BF7135 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(50466002)(72206003)(69596002)(48376002)(305945005)(66066001)(97736004)(478600001)(107886003)(4326008)(110136004)(8936002)(53936002)(6512007)(81156014)(5660300001)(8676002)(68736007)(7736002)(25786009)(81166006)(36756003)(50226002)(42186005)(5003940100001)(105586002)(2361001)(33646002)(101416001)(53416004)(6116002)(189998001)(3846002)(6916009)(42882006)(2906002)(5009440100003)(50986999)(47776003)(6486002)(6666003)(6506006)(106356001)(2351001)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR07MB3461; H:PBHAGAVATULA-LT.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR07MB3461; 23:7gURgrdO48/ufvvIosxSFrhqMulxj9jgDaVkp/7Vu?= =?us-ascii?Q?7KPhKY0E3PnKEazNF0GDWQqhu1GkKhqGf8xEccMDwO3KteJEn16+jf3a17/+?= =?us-ascii?Q?DHC6HNSH7tXLjnGM7J+NjhZx97HsC4+zF505Gw1kX+f7W8OUzAY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fkH5qAFgmQgdtgfulM35UUBzgnDwsJyDB3TJx4?= =?us-ascii?Q?xv403t7mIhfbL5/eQPazGauXe3LP+go1KxmbySpKZIPhS2xcDV3lo3ZVtGeC?= =?us-ascii?Q?Al7FMIlCKoT7mKCVl+x53xbLh+koPTr?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3461; 6:OROc7mSI10+Op4mMxPoRhgAR8v8kACvsyvKG2Y2MjbdqRa5v81++Thx8QHwPG1yLeNDuk6HA8auLtvXq/2hazh3RiZVPUm4M+hdopB2kBHReJQOgdHOw/X3ehM29WKiUIQtXfwVkyb0OYo/hxxCbtccRBFBe1E8byekI06Z58jnvMr0ihskKrpv9BfUoGDVGAm4w0bQtU+m1Z5psY1jKxJxwiRNLDk39tMKdXEpGhmiGasp2lytIyZO7NcSLGMQSd5qR17OYJ5n6pZ7nu7dxnY6IsRPms91gtIapRCAnRULJcQArmZRe1xSrhRhnF9n8e8VsrcvlcKFSJFfL6W5K4g==; 5:1y8vlA17g3ZLp9rNmamblJ7wHk9N80Ktw+IgTZVn1KHsXc9pGof2WB0z51NkfmCGKG87+t5BqfrTTAt/tgIJf7/aS7r6X5pkJ4D99TS+FyE46Yd2bGAPP2SePDl8+nAnI2RqXaX557znaHzG754JxQ==; 24:j/+UR5PxPY3nA7QLdUmtWbHPPmPmXbU9gfEPh7X17v8oORHuAmwE55eM++DD5NO7ZHQqdMgbLMLwy0zuTeucHCkGoLgxFFCJFK5IuI79JrU=; 7:bS1woG6zaVLQhoRUdN71TAyPw1CtXt2gA4tFHwmlCEQhnYsuMAi29X/XHHA2IHe9P0w/afBBqh3fsMFVjJBQIQzbfLRehzOYH8YI+/kXT9DG+zkslxl/o7vpcL5Y7m05iXaZu92g0fLA3pqdo3GXGfwH7jIwVKvLJUkXSSJOjIYpH9tLOgXsimQbVFRnW+NH39MsnFf+scSFWYm/LQoHoBBDzARSDDoWCp2DKWfljOo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2017 10:49:10.8417 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB3461 Subject: [dpdk-dev] [PATCH v4 1/3] eal: introduce integer divide through reciprocal X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2017 10:49:14 -0000 From: Pavan Bhagavatula In some use cases of integer division, denominator remains constant and numerator varies. It is possible to optimize division for such specific scenarios. The librte_sched uses rte_reciprocal to optimize division so, moving it to eal/common would allow other libraries and applications to use it. Signed-off-by: Pavan Nikhilesh Reviewed-by: Anatoly Burakov --- v4 changes: - minor fix for test cases - fix u32 divisor generation v3 changes: - fix x86_32 compilation issue - fix improper licence in test v2 changes: - fix compilation issues with .map files - add test cases for correctness and performance - remove extra licence inclusion - fix coding style issues lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/rte_eal_version.map | 7 +++++++ lib/librte_eal/common/Makefile | 1 + lib/{librte_sched => librte_eal/common/include}/rte_reciprocal.h | 6 ++++-- lib/{librte_sched => librte_eal/common}/rte_reciprocal.c | 6 ++++-- lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/rte_eal_version.map | 7 +++++++ lib/librte_sched/Makefile | 2 -- lib/librte_sched/rte_sched.c | 2 +- 9 files changed, 26 insertions(+), 7 deletions(-) rename lib/{librte_sched => librte_eal/common/include}/rte_reciprocal.h (87%) rename lib/{librte_sched => librte_eal/common}/rte_reciprocal.c (96%) diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index 005019e..56f9804 100644 --- a/lib/librte_eal/bsdapp/eal/Makefile +++ b/lib/librte_eal/bsdapp/eal/Makefile @@ -88,6 +88,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += malloc_elem.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += malloc_heap.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_keepalive.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_service.c +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_reciprocal.c # from arch dir SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += rte_cpuflags.c diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index aac6fd7..90d7258 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -237,3 +237,10 @@ EXPERIMENTAL { rte_service_unregister; } DPDK_17.08; + +DPDK_17.11 { + global: + + rte_reciprocal_value; + +} DPDK_17.08; diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index e8fd67a..a680b2d 100644 --- a/lib/librte_eal/common/Makefile +++ b/lib/librte_eal/common/Makefile @@ -42,6 +42,7 @@ INC += rte_hexdump.h rte_devargs.h rte_bus.h rte_dev.h rte_vdev.h INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h +INC += rte_reciprocal.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_spinlock.h rte_memcpy.h rte_cpuflags.h rte_rwlock.h diff --git a/lib/librte_sched/rte_reciprocal.h b/lib/librte_eal/common/include/rte_reciprocal.h similarity index 87% rename from lib/librte_sched/rte_reciprocal.h rename to lib/librte_eal/common/include/rte_reciprocal.h index 5e21f09..b6d752f 100644 --- a/lib/librte_sched/rte_reciprocal.h +++ b/lib/librte_eal/common/include/rte_reciprocal.h @@ -29,13 +29,15 @@ struct rte_reciprocal { uint8_t sh1, sh2; }; -static inline uint32_t rte_reciprocal_divide(uint32_t a, struct rte_reciprocal R) +static inline uint32_t +rte_reciprocal_divide(uint32_t a, struct rte_reciprocal R) { uint32_t t = (uint32_t)(((uint64_t)a * R.m) >> 32); return (t + ((a - t) >> R.sh1)) >> R.sh2; } -struct rte_reciprocal rte_reciprocal_value(uint32_t d); +struct rte_reciprocal +rte_reciprocal_value(uint32_t d); #endif /* _RTE_RECIPROCAL_H_ */ diff --git a/lib/librte_sched/rte_reciprocal.c b/lib/librte_eal/common/rte_reciprocal.c similarity index 96% rename from lib/librte_sched/rte_reciprocal.c rename to lib/librte_eal/common/rte_reciprocal.c index 652f023..7ab99b4 100644 --- a/lib/librte_sched/rte_reciprocal.c +++ b/lib/librte_eal/common/rte_reciprocal.c @@ -41,7 +41,8 @@ /* find largest set bit. * portable and slow but does not matter for this usage. */ -static inline int fls(uint32_t x) +static inline int +fls(uint32_t x) { int b; @@ -53,7 +54,8 @@ static inline int fls(uint32_t x) return 0; } -struct rte_reciprocal rte_reciprocal_value(uint32_t d) +struct rte_reciprocal +rte_reciprocal_value(uint32_t d) { struct rte_reciprocal R; uint64_t m; diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile index 90bca4d..98f3b8e 100644 --- a/lib/librte_eal/linuxapp/eal/Makefile +++ b/lib/librte_eal/linuxapp/eal/Makefile @@ -100,6 +100,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += malloc_elem.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += malloc_heap.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_keepalive.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_service.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_reciprocal.c # from arch dir SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += rte_cpuflags.c diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 3a8f154..2070cba 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -242,3 +242,10 @@ EXPERIMENTAL { rte_service_unregister; } DPDK_17.08; + +DPDK_17.11 { + global: + + rte_reciprocal_value; + +} DPDK_17.08; diff --git a/lib/librte_sched/Makefile b/lib/librte_sched/Makefile index 18274e7..569656b 100644 --- a/lib/librte_sched/Makefile +++ b/lib/librte_sched/Makefile @@ -52,10 +52,8 @@ LIBABIVER := 1 # all source are stored in SRCS-y # SRCS-$(CONFIG_RTE_LIBRTE_SCHED) += rte_sched.c rte_red.c rte_approx.c -SRCS-$(CONFIG_RTE_LIBRTE_SCHED) += rte_reciprocal.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_SCHED)-include := rte_sched.h rte_bitmap.h rte_sched_common.h rte_red.h rte_approx.h -SYMLINK-$(CONFIG_RTE_LIBRTE_SCHED)-include += rte_reciprocal.h include $(RTE_SDK)/mk/rte.lib.mk diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index b7cba11..3b8ccaa 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -42,12 +42,12 @@ #include #include #include +#include #include "rte_sched.h" #include "rte_bitmap.h" #include "rte_sched_common.h" #include "rte_approx.h" -#include "rte_reciprocal.h" #ifdef __INTEL_COMPILER #pragma warning(disable:2259) /* conversion may lose significant bits */ -- 2.7.4