From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0047.outbound.protection.outlook.com [104.47.36.47]) by dpdk.org (Postfix) with ESMTP id D329AFFA for ; Tue, 29 Aug 2017 20:47:04 +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=U3/PIT6sLQYClFncDQU2khDTXm2Y5Ab7JOBeBA2tl/o=; b=gJyfVDH4TyCBe8IZLJ6wJN2NVsoCq/SH90uxSno3f8035AeeC35MPYZNPX8Scg2dGcOJxG8zW7GptbTIyqbvqKJn/Z+/CGZ1kXJa3yys4kQ5+QbBxa2+CiTL4hZWg8fqPRcegRk7+eOQTrpHHXCVboHVAKAiWFzQ4H+Wz8KwSUY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (103.16.71.100) by DM5PR07MB3467.namprd07.prod.outlook.com (10.164.153.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Tue, 29 Aug 2017 18:47:01 +0000 From: Pavan Nikhilesh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, stephen@networkplumber.org, Pavan Nikhilesh Date: Wed, 30 Aug 2017 00:16:17 +0530 Message-Id: <1504032378-5483-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.100] X-ClientProxiedBy: SG2PR06CA0166.apcprd06.prod.outlook.com (10.175.208.20) To DM5PR07MB3467.namprd07.prod.outlook.com (10.164.153.22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: afcc1d1f-4807-4061-b4ce-08d4ef0e570a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM5PR07MB3467; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3467; 3:NmwnmdzUXRRTlXgZ+F3LqpShKiusVnKqsqOWGLmjgKsd1s2mvAD4LO9T7EivQDJdobGwgLosv8PB5q4pV7MiKfvLDUC/1Ruw0nHNfjudJhCkeWkEiw9c8ZqThD7R8NVQTniehaxCEg6CndNFKw93LQnC7itBWAzZ4R2GhwJcSzpBXK9W32yMTPKjznFvw/yj7ZEpMMeW0NzzFRiVLRXc9sbJw4xsgUXZgvgSVdk4hfgbWwc7cxpz8mZI8Fun8l9J; 25:oeUMow2qPJN4flbUgBpT/22DVf9RWbb4NWrbC+nTpDyLz8/YUE8nn4cFlRtPWlw1IuU/OKDFtbzHwikut5WLUrXZ3/vqjBK9Bkbh7Opqpf9K1tiMCBw2mN7wPYjOPDCz9dRamiS7L2o8JCk42nz9RqaA8try0NZbRKrHjvNEhao5/3lGVxuFjn5v1m2FogStO/98YGt7QMxa/Bz6V4LusqsjOPwbtxywGa5CW2mHLOCoAOBirG6p/SB3WOqk/fPjDodwEYr8i1dRe0Ju5bsUA2+3+/fGRu3ZQgCw5izIRwgVdUm5tyKSZM8yMnkEZJBb8UpVGEOkQasmt5bJNsLxeQ==; 31:IemPasT2exCDi7b2J+78qVNYNDxbe30adqVLosJW/J2JR/6x3Af2Jne5sjtI/QxENmgvShOdBMTq4NPmfK/Ou1hBzcOLTMbwJcBe6Kj+jIwCcdNHhy6NayrTosZApAq6OcM5P76m+WvKkqvvbPfd9mvgyvKUinH8iT364b3RzC53RAT9+ZlU+C09GS8yKhoQW13kdbgSireTHYyXnN2D5F2FYJZXQawTnVhp2WxhSnQ= X-MS-TrafficTypeDiagnostic: DM5PR07MB3467: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3467; 20:ZHnJiGTE/flx3qKaHcD2yi+rQCdCOmt+gLJgEMsuktO0Jad3Ed0tl2dlKZIAeIGVe0f4GVCfb0gurK+emhHmE7jvqx/52b1GQSuKOSlbKYGz5/VK7FMCU7UVu46Bd9tPQ0KhQNxsGY1VVbHeI/e5PgftHAhoo22e7NlzllaF4qqpqxaOPTadz+fPaYXB1CmexW3RT5OKX31v6MWTWg1xu34YyPLN8biBROweAuWVa0rHa4fzjkIXeF/S/8+MXfUI328mURo4jNu6AkdLB9S+ZQzPTdciEa7HL/sC8+XJP9UKyF7+9TUgsZaqflHNSkerwvyybupbU6zvxW78z5OmkfkccVx+6WjP9Wvx7OaT8zFeEyhCqjihQWZFC/ne6Qfmnv8uZS71ymc1wnxLqpTX1eGcfTKef/l+h45pi0lkhhFmeMA7XMnAwZAnLM1ePGCUTtXM+yPC5ihfvxTVWudkR7eUGnMlwsEBW8Fj53OejYhBcG36FUl2JWRHNFMH44Mt36pxPn/XrzIZ8xzNqwA/tiM+T8at7LgizFA0xEzev2jUWPlJMzniiTJeRJCwpnsy8eH3dBPOm0QNEDolHE/TRF+K7gWzjOdEwg0lIYFe0UI=; 4:hQwoSQ3xKJJJMA6kH+j+d2n/aBJCQL/4DxTKGTltirxZ/wBhiLOWU+dJPecxHruLZM3+9ROX79SN5sWJOxgDxkOT5TsAMClFVYDcLBW1TzkK9YrhHfWVzxzRPhyiuCeVKzytgbVrS/w6/a4X5FW+EuJh5z1WCejNePtmHNXRYXYVgpaGhGitlkWRHZWL47tRu9xhrGf92wt9FzOl2CmZ1OVRAMQoKAXlAO70HCrYF+ZcLsOVBLx/Nwt38bJPQP3PRhwA7zjM4m78quvAoK9bS9YXUrHT5WTS/6DG44TMBsY= 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)(5005006)(8121501046)(93006095)(3002001)(100000703101)(100105400095)(10201501046)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123562025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR07MB3467; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR07MB3467; X-Forefront-PRVS: 0414DF926F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6069001)(6009001)(189002)(199003)(6506006)(6486002)(6512007)(305945005)(7736002)(6116002)(101416001)(7350300001)(3846002)(2906002)(6916009)(42882006)(6666003)(42186005)(50986999)(5660300001)(25786009)(110136004)(2361001)(2351001)(33646002)(68736007)(478600001)(72206003)(107886003)(36756003)(106356001)(105586002)(47776003)(189998001)(53936002)(97736004)(8676002)(48376002)(4326008)(81156014)(81166006)(50226002)(50466002)(5003940100001)(66066001)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3467; 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; DM5PR07MB3467; 23:vNEps71JDvf6qhwzVcZQ5BbP5qx7e3jfWyPAMs070?= =?us-ascii?Q?CX0bKHosIeg8kQd2nOcBe3nAJhLWsB4B36qhzQXkdtVyzAqNspomche047em?= =?us-ascii?Q?DnYZhyfOBsozLVOIOVAGBc/tcANxGKsldx2xlZqsAAQuaq7An44Ai7pKxC/h?= =?us-ascii?Q?rl5qbuU+u+E0vowP2l5+AGJIZV799MPYLncYXznx0u3L40OrvV+WHjJYNyW7?= =?us-ascii?Q?5zPys+GSX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2aE?= =?us-ascii?Q?yZQvucxFaush+OvIacrpahBM5Z5r3KwTpJIt/tyBYxs1wG8CkYVRg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3467; 6:8cI4gUTfH6VrzFDA+yEXtPP3DTZa5ReIRiwAwLvSJF1Sqtq3gIdiGOI4oSyEjpAQ0vb3qgAjViwOCk8DSzXGuIYKDfNMGtcWsC/1GVl1Xy+o0eLmOVZeTJCTpmaOBIrhoO0o0/WqznXSPolxFl++1v+sjDPPTktP9j81Pc88jbIkgkAyJOZmZ8W+tSexlcAisDaP+apfcw1myLbgPM6MBOnGVLRVWS/3VXJeMxZZgBNULYkiDBB6m9/+bJphAwzg212ASEZ6yIG9E8PTUOtElvCmedp/cTGbd8nrGMlBE10MuBHtjCTAPPWiZVMeCqDvJp2bDFEyftKrHndhUsQKdA==; 5:5MHOLeDc+wybA52vb39JwZdM9eyh6X+1jhFZEDs61ncjbJoAP06fbv0ndABpoYIvdm4DPIDBDfidVvo59Ntp8WQGfyE9l1sH8V6aK0Mon3/7zCjxr4SUxHnmscJMHIN/HY4YGKrdyErunMvyJ/Qd8A==; 24:/P3q+tuZXbhnLLfGh0P0s6cvlHS7S3Y1wed6byAe3Qn0cyWzGp3Lh8aoaM4OOT+l00hI2AvCPgcM6X5k1hufSzRN4B036zzbwRvHUcBPC9Q=; 7:9stBWuBHmbYSdqtqoIhcvFiIT2wrYQniZfpopKTUwqVlTdvNAMigO1o32sA8jd5xGVVMQwdQ8kpaeOoxH2tNlQpJj6GDAkOxKdgdcAzmtDP0KywT545qOebo8YAhy+h+N00qQV+uz8jah+ci2uWvolI2LuYM6Z6cbV29aYCzL0kCGvOKx7vE5ORxuD68d4QexMscwFm7hj5Ls6ULIi3Sj9HnItV+fam/FeJrO7+4cs0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2017 18:47:01.7326 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3467 Subject: [dpdk-dev] [PATCH 1/2] 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, 29 Aug 2017 18:47:05 -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 --- 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..00d5f60 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.11; 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..ac68fb3 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.11; 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