From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0062.outbound.protection.outlook.com [104.47.34.62]) by dpdk.org (Postfix) with ESMTP id AF48FFE5 for ; Wed, 6 Sep 2017 12:22:40 +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=LtxeG0DQycFL7Ym9zaE7KJjFdXw4JEvA/CMk9X6wEMQ=; b=CZ9xGCXY9QYjScwr3LMqDBum0k/lNyuo+qlIavJ0zJwx0cU/Y+YqChdW0gCpCvDWsg+i5OzgIWdCvsUE+zIBZd9N3qjy7MnRvSp9sDl7RFVx1N1Oj81kuVmK3d0BUOoCmYQIFqJaf+9m3VDzEBjghpxeJnfG3usg1qwWsqNWIps= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from PBHAGAVATULA-LT.caveonetworks.com (111.93.218.67) by DM5PR07MB3465.namprd07.prod.outlook.com (10.164.153.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Wed, 6 Sep 2017 10:22:35 +0000 From: Pavan Nikhilesh To: cristian.dumitrescu@intel.com, stephen@networkplumber.org Cc: dev@dpdk.org, Pavan Bhagavatula Date: Wed, 6 Sep 2017 15:51:32 +0530 Message-Id: <1504693294-2100-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: MA1PR01CA0105.INDPRD01.PROD.OUTLOOK.COM (10.174.56.149) To DM5PR07MB3465.namprd07.prod.outlook.com (10.164.153.20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e409a488-6be6-43c6-b9e0-08d4f511329c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM5PR07MB3465; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3465; 3:1dQ0K1gXwcCU0vW76MBkvcrS8iIHjqc6JDcOKWcz1Z8BmNQo76pYkeBm8pArveey/lJdd5/k7xr443V2D27CfulocVM8emeZ1YIAXmedp/P1l+xYaXTEVxfWkTVv89Dk8fbdFnI2uPDmF3ZvxFwN+J3yd8tnTua5uRHk0lUysuU0q9H0ixGy3L/pO5PL+OjmXDPchF1nVJKnhV4Gddtlc0f+skIGvOLhZlpzmSWmfp4HrJj8jVMB0S1La+c1YClr; 25:wYvvFOWZudItABujkx/vMV79h4vGPPrHydQGE/JnKQdHTIght2/vMllnkMXLafMaw12+WB3LJLqIA4/amuUA/cMb8zJ3yugJyewMduRYUA9lCeCNOmta6ee1g8Rzu0mgV8C4jzb0Y6dmonw3OX9DCjwWPkLEnbeYpUJm0qbSJFLVOxpidQobmFnL+gxdGw/QtCCi6o75/+7wrUncVmjXjboGypaL6h8gAsMSyv830C4bQ+RURH29KtoT4ECshMOAuvAFl7hzldScHb1zHWbXt4zg13Q6JwnrfPJYBxVNEtxB+kuwilZpT9V+y9uEFKFGJLajAFlqLp8cgjDBPzrPgg==; 31:kSMdNDznD1FHZuMDEECybLnrgqBy52p04PD5iOtKcoxJkCJPqd8awLC7LJmsV7LOrtLS3zAnBcnGc/prtQZkbuc6e/XthQSK1HiQcH+fpQTNNCgfZS9qZOev4Vv+E51cRrIaHbdEPJrZjEGsbKtW3w2eJ0A4pylyFhQa04w2dVuKKxr2/Ypp//INCqtIH9yM6Nk6+TlulQtfZCAN3iA4UQOqUe2Nl+6KNH82EPo4qOk= X-MS-TrafficTypeDiagnostic: DM5PR07MB3465: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3465; 20:b2NqJRVaojnc+S92+oj3POZO41/wjseKhn4v3i4bn0QZKbEItijaseITfrfqKmMF1f1hYyXf/lH5bUt4IpXhrvHD3atHq1+2/rE3vbB4gnvgs2O3j1K+JnOBFO8fy/H/Z+ivXIYxchPUL3SoUkvKKZ5vyX1lUfOikbPFHqKZDEka/t15kgxBzqb5/R1YXhIZGNRzseJD0FYdKzoFEoQrmMnHiBvawfQ56OWJENk5dlGIFHEfjM3u9tdLiQlVfr/I97pPF1f2wuzSls0phL4bfCD8tTUloSYUCsA89aOzI939NySY4Duvz12W6Znz6p3YFtZYskAL9MyBuk9PZ8yugd91878qJ7AHfyPnIKN8do/iR/fi/dp1iZtyOswAs/ALtwB6PlIHWsm970bJkDvEa923Mqz/zZ3zM/B/W2G+8u9GR8cwf2FJWmRMpbCnsZbWyFJZtcXXS4i7FhVdWKdnPxYjtPISUNramWx1Wc4oA2VsIPmFrpyOtLlGnULE141FkBZjovMgpFWQVpd1nQDVrw+UUAQnWVkXpNjDRGxXjcNABdcp5UI3Ou+yNkwMsnrG1M7HpSpT3S7q4pcANij8MoLH2cpJ7AoSEGx3ovFVOIo= 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)(100000703101)(100105400095)(93006095)(3002001)(10201501046)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(20161123562025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR07MB3465; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR07MB3465; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3465; 4:fH/x08yYHwP/uhSf9Y5AO40R0EhPElW3gXj2Nx1ehMo3WUhYRdk9uBp2DcO7zEKefM1P8yNd2+VSybFbZ27T7icu4EqHQfbb3IcjDpQTtt/2bXqYIQw4Mhfofz9KeilfyWZtc0Uljk6592tW/0OPfKxbgNR9EMGDoh79UMvpQKahLDODYHwum341PnUPphE9QldaP8tVQpbBpkEqh3vwaJXP0oGhrqJ9j3gvvWhaftj5AQzQW4Q9NP25H0i9QcyZ74TT04vkIUziKETI/qFnsEsTQMPZrVocxrpXXlni2g9YQNn7YjRhkNVeJOPx3qYxcDbVoa2nIOOXZ26Oy8Cm4w== X-Forefront-PRVS: 0422860ED4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(101416001)(5003940100001)(2906002)(25786009)(50986999)(189998001)(4326008)(5660300001)(33646002)(106356001)(8936002)(42186005)(3846002)(81156014)(6116002)(72206003)(53416004)(81166006)(8676002)(105586002)(42882006)(50226002)(6666003)(36756003)(48376002)(68736007)(5009440100003)(66066001)(7736002)(69596002)(50466002)(6512007)(478600001)(107886003)(110136004)(6486002)(6506006)(47776003)(97736004)(53936002)(305945005)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3465; 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; DM5PR07MB3465; 23:1y5tYrDPu8udnMAy4/slVe8BCkI+f5ppCHIrKUovV?= =?us-ascii?Q?K5z1PQLqKllzn0UkZk2aNSNEmFenQo7lHI+4N7dwDxIYIhFcspgX1UDl/HSM?= =?us-ascii?Q?IAvdriMEd8zwMR/TPDniQ+ZhpDv09U86R4dFDCBjuQ2BZwUeZPQ1tuqBUxLZ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: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2017 10:22:35.5651 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3465 Subject: [dpdk-dev] [PATCH v6 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: Wed, 06 Sep 2017 10:22:41 -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 --- v6 changes: - remove cache alignment from rte_reciprocal_u{32/64}structures as they would be embedded in other structures. v5 changes: - fix test print strings 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