From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0068.outbound.protection.outlook.com [104.47.38.68]) by dpdk.org (Postfix) with ESMTP id C2AF65A6E for ; Mon, 4 Sep 2017 11:51:35 +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=zwI9B9NA8DzhNH54ovnk5GQbXl+/UmA2jXjR2JCZhLs=; b=X9EMttQ5U6kyGaxs6IM9Ee50CG9L0LfmXl1XGiye2CIwrNi79zcydPL9u7M5Gs6xPKxhdAw/G9Jm3xzmu7cAhrcJt/SCQ1obuHti+zMIQPqvZrkhGSF3XScfW/HlTvaPont4smHiBZH91qhVZtVOP74IPIcXXZAopjaN1a+wpbM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from PBHAGAVATULA-LT (111.93.218.67) by DM5PR07MB3468.namprd07.prod.outlook.com (10.164.153.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Mon, 4 Sep 2017 09:51:32 +0000 Date: Mon, 4 Sep 2017 15:19:25 +0530 From: Pavan Nikhilesh Bhagavatula To: "Burakov, Anatoly" Cc: dev@dpdk.org Message-ID: <20170904094923.GA24204@PBHAGAVATULA-LT> References: <1504442189-4384-1-git-send-email-pbhagavatula@caviumnetworks.com> <1504442189-4384-3-git-send-email-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BMXPR01CA0006.INDPRD01.PROD.OUTLOOK.COM (10.174.214.144) To DM5PR07MB3468.namprd07.prod.outlook.com (10.164.153.23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d3fed5e8-53f0-4c15-ece9-08d4f37a86b0 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:DM5PR07MB3468; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3468; 3:RQ66MTli9bSNUsKPdOhJL2S08U2LHLROFULivRWPlTXfKtAg683ZiUEcYLujwdtTuFZw6NBKRBjOcR7ryxsbnLOV+iUL3GRRlAaBoH9CTB/pAGTELhF4MiVPu++4a/cN5Uz7oJ/MDlNbnze54JTommsBf3ZVOQlETmmJD1U/Ir4aSYU58UFmGRKPWQPjqOMtdzsWVPXCiluOhixRxBE7Jc9me5Oki5VkdHw4maIEcmwkRaZKUiJ4gydDoN22ce+1; 25:2aH04dXQHlQlsVIrNrr2hidBe2EvIhx7CoqnO6EX3ZWRPNvRuYthMNuSZz3JilNltr0HWIRdauU6DurjegYj0nJcwfNziawoB7XSxkrJh5Rwh0hUAtJWJfP7QyCK78P6WKY0GJ5rvoq1FzB95rq1dkNpH2PpPq2ZpW9RHKNpJWoaQJmKJGKDj5H4cG+ptOWCsLp/NyWFwlEdR6bE4S3zafBM/g0p1P88919SmPOLTrfBBAImhDORLBXteckA5K8HdFa6JU/k42dZOQ8+WZaGXDY1JhwLNAKDjPppCR3FSG7Psfvld/rEXrHyGSOAoBVUz+8OWMrbyp4bUdmg/yt6aw==; 31:83ySRkJQSZAh9hhg0+USeS5IdQRXbuQ/ww2RHYydWNZzZ0effhp5aNHQ75O7PO6LkepcfP/J9A2/YqZpcXoSQV8vxIHeYSfem0f+Px2GANHIXzsi4y2A0S5Ng3NaSgxSVwAHQu7AzRTJDb2hfxI997j0teZ4mRrJNWRDHPgURm6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-Test: UriScan:(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(93006095)(100000703101)(100105400095)(3002001)(10201501046)(6041248)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR07MB3468; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR07MB3468; X-Forefront-PRVS: 0420213CCD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(24454002)(377454003)(199003)(51914003)(33716001)(6116002)(3846002)(101416001)(55016002)(9686003)(68736007)(83506001)(72206003)(5009440100003)(1076002)(23726003)(4001350100001)(478600001)(97736004)(53546010)(50986999)(76176999)(54356999)(8936002)(8676002)(66066001)(42186005)(229853002)(47776003)(106356001)(81156014)(81166006)(7736002)(105586002)(110136004)(6246003)(2906002)(6496005)(25786009)(6916009)(53936002)(42882006)(2950100002)(189998001)(6666003)(33656002)(4326008)(50466002)(5660300001)(305945005)(18370500001)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3468; H:PBHAGAVATULA-LT; 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; DM5PR07MB3468; 23:rFgcHKl5IsOObbxJP3M9HcTxB2X1wC9FCpF6UZ1pk?= =?us-ascii?Q?AF0Q/uMAnbdrzeykSWTPHz2tIyPGhYNqY2yYQU96RWwPFzS1Whex1HYGYZkO?= =?us-ascii?Q?KsqDh9H/BX+oL+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otIrO?= =?us-ascii?Q?oe6vMk0f8yEhkklghrmkzKAebJNWqVyCvcwY7q7sULvw6dQHabuK3zP49V+S?= =?us-ascii?Q?YNSt4b628TdNqXj9lXVTkdDs2QG1eU4VfvwFnc5ChTeHA7FodARV/B/1ehz5?= =?us-ascii?Q?BjkK2VqWtMemdW5xlcdlgi2vyhCq7trXp4IsQKREQ/TNQkzfZZ+tofQksW1T?= =?us-ascii?Q?7oxnB5njgkgq3kx22KJZ7G1iZEVughio2LwZany8s772Cq7n9WemT+y4QJzZ?= =?us-ascii?Q?90KG4UltPlAYGlis8wjUXzTF+rKPS/eM+HQAHV1Vbx9911LLIo4SryF7a2Uz?= =?us-ascii?B?UT09?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3468; 6:4tDaiKg2kADVFMK5KcdsyILz42vPfirsmdgyOmb9I3+7r4RAD5Nvn8AUHWk60ICdNgl3pr2AMVnZm1pUywksYMyJRKPy1pbp80N+w7fGlBtatqpi7P780/e8W9RIMPiierh9TNWvZpgHRBeuBAzSrY6OMUPjT5o0cWHkMCFF3bP+9khNA43ps+/TfxgIoTg88eprL7wz7rJopSwog3cjeT6Bhhmk9itbdem+Cg+R7mf0+I2vl37aFZnP4PuMvb+mycDAzof/sFTFuyKF4mJd9t/M2ViiMACkEXsao0QvFcjAZt4hDkxjhlkenGfltO5fXmxFVKrZyjFpeA2DLxcHow==; 5:BGBxUS6P7zUmE7ToS7tXX59yi34zsNXuOQ48g0FoAcCUp5oRzCyMoQ4ulfLkUEin1ga5EeKgRYzXQEIKgTG3yAbb3XwmX66pQPlWsG9KSSqTYjXHBm1nt8I787TrwsuTXROlZRe2p4IKyQmC32/HMA==; 24:/EHJXnJSTIpmb/JIMv6gTAcksXAo02RrqQI76MhPX4AmSUyE+EnTZfuWvzfvcygMRCCdKStI6sheMh+9g7GYGiXRu5uunx+Q2oWPvuqmbb4=; 7:jflks9sK/5DXAwmeNFG/j/U4R5vqOiUJIKsa+XTeUViLO8Ztm7vK8aB0LO8lViGBgD+7wYmg/LSD4tlr0pmhZmuFS/54JI9oEHRcgNTQvM1S2Gjro1liHROBUF90rvrQRZJujt24YIHNlS4SHn5qqpi6t1LVU4O9zpAh6qaHuBZGmCHkBYL2fsy7T1YVS3WnZXP0zOm5Dmczx8fdqvQ2oPxI8ICt5vPxWqnspwKkILU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2017 09:51:32.5977 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3468 Subject: Re: [dpdk-dev] [PATCH v3 3/3] test: add tests for reciprocal based division 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: Mon, 04 Sep 2017 09:51:36 -0000 On Mon, Sep 04, 2017 at 09:18:37AM +0000, Burakov, Anatoly wrote: Hi Burakov, > Hi Pavan, > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pavan Nikhilesh > > Sent: Sunday, September 3, 2017 1:36 PM > > To: dev@dpdk.org > > Cc: Dumitrescu, Cristian ; > > stephen@networkplumber.org; Pavan Nikhilesh > > > > Subject: [dpdk-dev] [PATCH v3 3/3] test: add tests for reciprocal based > > division > > > > This commit provides a set of tests for verifying the correctness and > > performance of both unsigned 32 and 64bit reciprocal based division. > > > > Signed-off-by: Pavan Nikhilesh > > --- > > test/test/Makefile | 2 + > > test/test/test_reciprocal_division.c | 109 ++++++++++++++++++ > > test/test/test_reciprocal_division_perf.c | 181 > > ++++++++++++++++++++++++++++++ > > 3 files changed, 292 insertions(+) > > create mode 100644 test/test/test_reciprocal_division.c > > create mode 100644 test/test/test_reciprocal_division_perf.c > > > > diff --git a/test/test/Makefile b/test/test/Makefile index 42d9a49..6017862 > > 100644 > > --- a/test/test/Makefile > > +++ b/test/test/Makefile > > @@ -94,6 +94,8 @@ SRCS-y += test_cycles.c SRCS-y += test_spinlock.c > > SRCS-y += test_memory.c SRCS-y += test_memzone.c > > +SRCS-y += test_reciprocal_division.c > > +SRCS-y += test_reciprocal_division_perf.c > > > > SRCS-y += test_ring.c > > SRCS-y += test_ring_perf.c > > diff --git a/test/test/test_reciprocal_division.c > > b/test/test/test_reciprocal_division.c > > new file mode 100644 > > index 0000000..771ea64 > > --- /dev/null > > +++ b/test/test/test_reciprocal_division.c > > @@ -0,0 +1,109 @@ > > +/* > > + * BSD LICENSE > > + * > > + * Copyright (C) Cavium, Inc. 2017. > > + * > > + * Redistribution and use in source and binary forms, with or without > > + * modification, are permitted provided that the following conditions > > + * are met: > > + * > > + * * Redistributions of source code must retain the above copyright > > + * notice, this list of conditions and the following disclaimer. > > + * * Redistributions in binary form must reproduce the above copyright > > + * notice, this list of conditions and the following disclaimer in > > + * the documentation and/or other materials provided with the > > + * distribution. > > + * * Neither the name of Cavium, Inc nor the names of its > > + * contributors may be used to endorse or promote products derived > > + * from this software without specific prior written permission. > > + * > > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > > CONTRIBUTORS > > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT > > NOT > > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND > > FITNESS FOR > > + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > > COPYRIGHT > > + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > > INCIDENTAL, > > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > > NOT > > + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS > > OF USE, > > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED > > AND ON ANY > > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR > > TORT > > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF > > THE USE > > + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > > DAMAGE. > > + */ > > + > > +#include "test.h" > > + > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#define MAX_ITERATIONS 1000000 > > +#define DIVIDE_ITER 100 > > + > > +static int > > +test_reciprocal_division(void) > > +{ > > + int i; > > + int result = 0; > > + uint32_t divisor_u32 = 0; > > + uint32_t dividend_u32; > > + uint32_t nresult_u32; > > + uint32_t rresult_u32; > > + uint64_t divisor_u64 = 0; > > + uint64_t dividend_u64; > > + uint64_t nresult_u64; > > + uint64_t rresult_u64; > > + struct rte_reciprocal_u32 reci_u32; > > + struct rte_reciprocal_u64 reci_u64; > > + > > + rte_srand(rte_rdtsc()); > > + printf("Validating unsigned 32bit division.\n"); > > + for (i = 0; i < MAX_ITERATIONS; i++) { > > + /* Change divisor every DIVIDE_ITER iterations. */ > > + if (i % DIVIDE_ITER == 0) { > > + divisor_u32 = rte_rand(); > > + reci_u32 = rte_reciprocal_value_u32(divisor_u32); > > + } > > + > > + dividend_u32 = rte_rand(); > > + nresult_u32 = dividend_u32 / divisor_u32; > > + rresult_u32 = rte_reciprocal_divide_u32(dividend_u32, > > + &reci_u32); > > + if (nresult_u32 != rresult_u32) { > > + printf("Division failed, expected %"PRIu32" " > > + "result %"PRIu32"", > > + nresult_u32, rresult_u32); > > + result = 1; > > + break; > > + } > > + } > > + > > + printf("Validating unsigned 64bit division.\n"); > > + for (i = 0; i < MAX_ITERATIONS; i++) { > > + /* Change divisor every DIVIDE_ITER iterations. */ > > + if (i % DIVIDE_ITER == 0) { > > + divisor_u64 = rte_rand(); > > + reci_u64 = rte_reciprocal_value_u64(divisor_u64); > > + } > > + > > + dividend_u64 = rte_rand(); > > + nresult_u64 = dividend_u64 / divisor_u64; > > + rresult_u64 = rte_reciprocal_divide_u64(dividend_u64, > > + &reci_u64); > > + if (nresult_u64 != rresult_u64) { > > + printf("Division failed, expected %"PRIu64" " > > + "result %"PRIu64"", > > + nresult_u64, rresult_u64); > > + result = 1; > > + break; > > + } > > + } > > + > > + return result; > > +} > > + > > +REGISTER_TEST_COMMAND(reciprocal_division, test_reciprocal_division); > > diff --git a/test/test/test_reciprocal_division_perf.c > > b/test/test/test_reciprocal_division_perf.c > > new file mode 100644 > > index 0000000..31f069d > > --- /dev/null > > +++ b/test/test/test_reciprocal_division_perf.c > > @@ -0,0 +1,181 @@ > > +/* > > + * BSD LICENSE > > + * > > + * Copyright (C) Cavium, Inc. 2017. > > + * > > + * Redistribution and use in source and binary forms, with or without > > + * modification, are permitted provided that the following conditions > > + * are met: > > + * > > + * * Redistributions of source code must retain the above copyright > > + * notice, this list of conditions and the following disclaimer. > > + * * Redistributions in binary form must reproduce the above copyright > > + * notice, this list of conditions and the following disclaimer in > > + * the documentation and/or other materials provided with the > > + * distribution. > > + * * Neither the name of Cavium, Inc nor the names of its > > + * contributors may be used to endorse or promote products derived > > + * from this software without specific prior written permission. > > + * > > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > > CONTRIBUTORS > > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT > > NOT > > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND > > FITNESS FOR > > + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > > COPYRIGHT > > + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > > INCIDENTAL, > > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > > NOT > > + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS > > OF USE, > > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED > > AND ON ANY > > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR > > TORT > > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF > > THE USE > > + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > > DAMAGE. > > + */ > > + > > +#include "test.h" > > + > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#define MAX_ITERATIONS 1000000 > > +#define DIVIDE_ITER 100 > > + > > +static int > > +test_reciprocal_division_perf(void) > > +{ > > + int result = 0; > > + uint32_t divisor_u32 = 0; > > + uint32_t dividend_u32; > > + uint32_t nresult_u32; > > + uint32_t rresult_u32; > > + uint64_t divisor_u64 = 0; > > + uint64_t dividend_u64; > > + uint64_t nresult_u64; > > + uint64_t rresult_u64; > > + uint64_t cur_cyc; > > + uint64_t tot_cyc_n = 0; > > + uint64_t tot_cyc_r = 0; > > + uint64_t i; > > + struct rte_reciprocal_u32 reci_u32 = {0}; > > + struct rte_reciprocal_u64 reci_u64 = {0}; > > + > > + rte_srand(rte_rdtsc()); > > + printf("Validating unsigned 32bit division.\n"); > > + for (i = 0; i < MAX_ITERATIONS; i++) { > > + /* Change divisor every DIVIDE_ITER iterations. */ > > + if (i % DIVIDE_ITER == 0) { > > + divisor_u32 = rte_rand(); > > + reci_u32 = rte_reciprocal_value_u32(divisor_u32); > > + } > > + > > + dividend_u32 = rte_rand(); > > + cur_cyc = rte_rdtsc(); > > + nresult_u32 = dividend_u32 / divisor_u32; > > + tot_cyc_n += rte_rdtsc() - cur_cyc; > > + > > + cur_cyc = rte_rdtsc(); > > Is there any particular reason for calling rte_rdtsc() twice in a row? Instead of, say, doing something like this: > > start = rdtsc(); > // do something > split = rdtsc(); > // do something else > end = rdtsc(); > // figure out which cycle value goes where > No particular reason for doing so. I will do the changes in v4. tot_cyc_n += split - start; tot_cyc_r += end - split; Thanks for the inputs. -Pavan. > > + rresult_u32 = rte_reciprocal_divide_u32(dividend_u32, > > + &reci_u32); > > + tot_cyc_r += rte_rdtsc() - cur_cyc; > > + if (nresult_u32 != rresult_u32) { > > + printf("Division failed, expected %"PRIu32" " > > + "result %"PRIu32"", > > + nresult_u32, rresult_u32); > > + result = 1; > > + break; > > + } > > + } > > + printf("32bit Division results:\n"); > > + printf("Total number of cycles normal division : %"PRIu64"\n", > > + tot_cyc_n); > > + printf("Total number of cycles reciprocal division : %"PRIu64"\n", > > + tot_cyc_r); > > + printf("Cycles per division(normal) : %3.2f\n", > > + ((double)tot_cyc_n)/i); > > + printf("Cycles per division(normal) : %3.2f\n\n", > > + ((double)tot_cyc_r)/i); > > + > > + tot_cyc_n = 0; > > + tot_cyc_r = 0; > > + printf("Validating unsigned 64bit division.\n"); > > + > > + for (i = 0; i < MAX_ITERATIONS; i++) { > > + /* Change divisor every DIVIDE_ITER iterations. */ > > + if (i % DIVIDE_ITER == 0) { > > + divisor_u64 = rte_rand(); > > + reci_u64 = rte_reciprocal_value_u64(divisor_u64); > > + } > > + > > + dividend_u64 = rte_rand(); > > + cur_cyc = rte_rdtsc(); > > + nresult_u64 = dividend_u64 / divisor_u64; > > + tot_cyc_n += rte_rdtsc() - cur_cyc; > > + > > + cur_cyc = rte_rdtsc(); > > Same as above > > > + rresult_u64 = rte_reciprocal_divide_u64(dividend_u64, > > + &reci_u64); > > + tot_cyc_r += rte_rdtsc() - cur_cyc; > > + if (nresult_u64 != rresult_u64) { > > + printf("Division failed, expected %"PRIu64" " > > + "result %"PRIu64"", > > + nresult_u64, rresult_u64); > > + result = 1; > > + break; > > + } > > + } > > + printf("64bit Division results:\n"); > > + printf("Total number of cycles normal division : %"PRIu64"\n", > > + tot_cyc_n); > > + printf("Total number of cycles reciprocal division : %"PRIu64"\n", > > + tot_cyc_r); > > + printf("Cycles per division(normal) : %3.2f\n", > > + ((double)tot_cyc_n)/i); > > + printf("Cycles per division(normal) : %3.2f\n\n", > > + ((double)tot_cyc_r)/i); > > + > > + printf("Validating unsigned 64bit division with 32bit divisor.\n"); > > + for (i = 0; i < MAX_ITERATIONS; i++) { > > + /* Change divisor every DIVIDE_ITER iterations. */ > > + if (i % DIVIDE_ITER == 0) { > > + divisor_u64 = rte_rand() >> 32; > > + reci_u64 = rte_reciprocal_value_u64(divisor_u64); > > + } > > + > > + dividend_u64 = rte_rand(); > > + cur_cyc = rte_rdtsc(); > > + nresult_u64 = dividend_u64 / divisor_u64; > > + tot_cyc_n += rte_rdtsc() - cur_cyc; > > + > > + cur_cyc = rte_rdtsc(); > > + rresult_u64 = rte_reciprocal_divide_u64(dividend_u64, > > + &reci_u64); > > + tot_cyc_r += rte_rdtsc() - cur_cyc; > > + if (nresult_u64 != rresult_u64) { > > + printf("Division failed, expected %"PRIu64" " > > + "result %"PRIu64"", > > + nresult_u64, rresult_u64); > > + result = 1; > > + break; > > + } > > + } > > + printf("64bit Division results:\n"); > > + printf("Total number of cycles normal division : %"PRIu64"\n", > > + tot_cyc_n); > > + printf("Total number of cycles reciprocal division : %"PRIu64"\n", > > + tot_cyc_r); > > + printf("Cycles per division(normal) : %3.2f\n", > > + ((double)tot_cyc_n)/i); > > + printf("Cycles per division(normal) : %3.2f\n", > > + ((double)tot_cyc_r)/i); > > + > > + tot_cyc_n = 0; > > + tot_cyc_r = 0; > > + > > + return result; > > +} > > + > > +REGISTER_TEST_COMMAND(reciprocal_division_perf, > > +test_reciprocal_division_perf); > > -- > > 2.7.4 >