From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0071.outbound.protection.outlook.com [104.47.42.71]) by dpdk.org (Postfix) with ESMTP id B26217CAB for ; Sun, 3 Sep 2017 14:37:06 +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=RHV5pZ5iak36Sg3uzTaw61g6A4IBpXEZBgBQQIH5XSg=; b=mhviw20xbpOF1jP4FrCpFkeOkJQmwMMaE7tXDMoyD2ahIQIbyj/ejHBoAqgPustBb5cVTpi8yVA6XkhZyPEICLKpv/KkClzvjimlGZKcIl0uceNXNdrXXD1gP+6/65uo/03+VCHcaPOXepQA0NDSQmN7623jAGHHlT9KOeYToJI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (103.16.71.101) by BN6PR07MB3457.namprd07.prod.outlook.com (10.161.153.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Sun, 3 Sep 2017 12:37:02 +0000 From: Pavan Nikhilesh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, stephen@networkplumber.org, Pavan Nikhilesh Date: Sun, 3 Sep 2017 18:06:27 +0530 Message-Id: <1504442189-4384-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: [103.16.71.101] X-ClientProxiedBy: SG2PR0601CA0005.apcprd06.prod.outlook.com (10.170.128.15) To BN6PR07MB3457.namprd07.prod.outlook.com (10.161.153.20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d7e0c547-9779-4dd6-7ff7-08d4f2c87b77 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:BN6PR07MB3457; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3457; 3:C3EtqvOtvV42nBnPAbyhPoVJCmq7/hnW3PoeZdgE3jqT+Ykr/q61v6SO9Fjef9ZCkAMc6u+ma1vhC5CHhJqBOSWMCvNdLhj5FuWiBWtD4mGI3TxY9ykUomdFNsjVXMlmeUwN2BCKltqNkJq5SzRwf4pWqhrnSNIbMZhnxGCDJdSHkxeeS7UUHzqDCiMvpRRRhY1kJFLSa5AcDtZ8TTJDYPhbJKJyUzUKdgQl7zez8i3cOuNJNgVhbnnTTfZwLD5Q; 25:SGZzGaEXP1VBnf9ICI2Vdgc9ut0hgwcYYgthpFIYthbJdIOy6lPFq1SY1MjGDZExp2myv5pOlmmxC07nHscK+pMvG01Bw3QqcIdR2zW193IgmIlETxqxISTSZioRr+rS5E+ALZWcOre/fLj20wGP1iOV7gtdyxZpESueEroKX6qh/5W6g7glioDHkNloQYlflZfg3k0P7EZ1GLi3LH8OfJ+T+NyMR5pm8lNBfCMooiOdk4EdN8cojNY2rgg+VFGEjDCNO6vOpvk8mHFO68vJAcVfmY8ToswOfeLoGY0W8tjcTx6LE+7mUb4iUZyIamJJows5/ks1YvMLuGRtfYQxaQ==; 31:wgFyhir+y/sWkIQYWlKjnEV5pxWaOKgL4k24o3NteXhQayijjPnZKqP7SeS3nr5yenyk8kfi6+ANVKcVi9vkJm00MY/kNCsk6sTNA2BOL9PwkqRosaWzv6qBwUAi8tSvZHCDy4YFLVkQ6MZwD28NE/CVxxgUaP6CkuF19QElaopXmL3b6F6Gr3deeN9oKty8O0Kh67Fmr9lFmlCkDT5EMvT/8NWhynmzqGkySWoRhzY= X-MS-TrafficTypeDiagnostic: BN6PR07MB3457: X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3457; 20:jJV+EfzFwaPgCHy8j/ILGyFve5z0WRcx8OC5Jfey602sAO7fKfZRBlLBmuvj6/U96Ib/X2r6nGOTSuutRWQnbskBmQqfb14o3qQjL5GOpxKXDRUFQRM21WorJAcmICBKrQkzHVVbDPPi+FWK+jeJnqM57+bnx4ce374zoeppoVoQnD/QHKgFXLnJOBqKml4wRQgHKesWJOjPAqZbld49ep0RGZ7GVS3tw2fab2kmqmO014Hfh1SmszWkI+yv9dzD0onJOAkTiq9MzcpFlyuG+yFbDV2mCX4nT0pKgbJZqz+7wl/50lgZYk7FsrS7t0FvrVfb5gJzgA4Cd8gsvK0HQRYhx8hHbwb4QIXecDd4b+5Xj+ws5Bgpyh1eswC0WtqeX7sQiASSg7mxykTPmZWB/h/tpncjRrFU8UREeurthMZY8sD5VicdLOhqwC8TYM2YCpqIDbBcknBYdibDyzu+/+exhI1ApD7I8hAMrzczE7KNYMLYUDDlncq3Sae1aNX0hwczOxGogmuUyXmjtgoQBsJJy/ArFocl2oMtIIJ39PAoBcohyQ1wRlITYWZtuCrzqnkD8dt/RZIR+O8xNinVLeEnnDD+VtUjSvwkblnjcvs=; 4:FeKtRnzOJpuB9Cn43tDWLTfwfXhNFU93DcQ9ThNdecSPE2tVF4/cvA+/T4fpRs7sWv9AnG2qRv9YpXIsiQlf7ETHosVOzCUOQyS1UJyU7QSWvHy/ywg1VYDT+XKIOLtuo/tUq5RZQzcEURGsxc14pXru4i7SqwRHxYDEUvPAie/cjaAA7j6ItcvyMdBENizufmVE51fRdGb88NBoixNi/pzQBcfnGMlGH2MIgjeWpXTebtWV5UgL/FHd759cWzA7pv8EDaO9V0m5kvuFipmuDyGh0G6O0FjQvO/iXjKamLA= X-Exchange-Antispam-Report-Test: UriScan:(278428928389397); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(6041248)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR07MB3457; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR07MB3457; X-Forefront-PRVS: 041963B986 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(189002)(199003)(107886003)(5003940100001)(6116002)(3846002)(2906002)(189998001)(5660300001)(575784001)(110136004)(48376002)(53936002)(6512007)(97736004)(50466002)(33646002)(66066001)(2351001)(106356001)(2361001)(105586002)(36756003)(6506006)(50986999)(42186005)(47776003)(101416001)(478600001)(6486002)(25786009)(81156014)(50226002)(68736007)(8936002)(305945005)(72206003)(8676002)(81166006)(7736002)(6666003)(42882006)(6916009)(4326008)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3457; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; BN6PR07MB3457; 23:ydTgU7EyttZo9eLHX8GUZggJzunAS8oTfIY3Y2dor?= =?us-ascii?Q?I3+5b/7zkRVxjMXX76NTqiTdb5AKKhNUW0zxpj3l8ly/x1jg/oaWePqftIJr?= =?us-ascii?Q?3GQsUlKsNUb6zsb2KvSyNcI5m0c5FUIOnoNeGaDiJ4xjULm8F4nKsZDxge4t?= =?us-ascii?Q?jDkmwypfxyYivypBLGebeSb0W25PaDSsVbYCAIayhW987wIn+HDESAMw6qLM?= =?us-ascii?Q?ZeiISPVYB6HuAhmE3FHogb8+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vL3ELiE5?= =?us-ascii?Q?ccySDQkIhU=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3457; 6:/twsIGV5H6uvWdmFE9FMvtLsoXqG3Ux9XkHarXfLczg5s0fVcPDeA/v9QsRdnqu0VIx8DBvKKMnXo0hMUTTs3OCW0CL8fIRBVdvM/8RRemiRIwoP7fqmnmSerFN6mpVmKH2zXvGVMp4vegZwM2Qi4n4tXwoFwLa4c0hVt458+x7fb6b2f1ykUQcf9vHoxVYV1HGFgW+YjdYwF9NJG0wlK9368wqOLQsnySyjMvfHy+Xg2H57y1YQP10WFsE3PetHAIea+MPLz9/nIVmNIyulnCy4TQARRcqoWIW3+A63jNGg/Uzm/TboNuKRH3Sfbk2qKtS7Hka6QKcguljaVAPhLg==; 5:nZhMHRAICrNjyN555HxQ7+cxvy36ghWbvfGq9HiKLmkbwQMNIW4bzbWWTiLCLlZG5e58vaxpD5EcsPMGOPVETb1EDLbvrjYRFII+mturjMwrb/nsT+87nMVVKvumGXykK0QXZg0t2ZQ2cTRWL8qIwA==; 24:EnuEBGisprIPGHySVUsraOlX4kGJsaB4xSYkmA3arnvFbvh0LWqhbfXdA4F+KAaONgGpkVr5GlJtifCUB9J0a6LPuCWmXmj4meXjnyVDSzo=; 7:vdhXETi69BTNa3T5Vk3k2TG31Kt6Vcya81Zv9VFmsUfIiKH/P2VzZZ5RtmWllCMv1txG1S55XSQqS+JsfzIGr5T+iPryl9Ib/rRAegWhiJ0rGlVKBxkCxjkFpR6kPIB/+qMDDdC49sSHXqbkofOMlsPlo2SQwR5K04w6cVLJaZmONFHB/Nx0vtBMNVCse3TE4KKol7v7iXhw/XDrOE+BxNHpSvQ5JRuvVkhm/LPzVAA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2017 12:37:02.9579 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3457 Subject: [dpdk-dev] [PATCH v3 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: Sun, 03 Sep 2017 12:37:07 -0000 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 --- 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 79e7d31..d0bda66 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -238,3 +238,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 468c706..65117cb 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -243,3 +243,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