Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/28307/?format=api
https://patches.dpdk.org/api/patches/28307/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1504442189-4384-3-git-send-email-pbhagavatula@caviumnetworks.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1504442189-4384-3-git-send-email-pbhagavatula@caviumnetworks.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1504442189-4384-3-git-send-email-pbhagavatula@caviumnetworks.com", "date": "2017-09-03T12:36:29", "name": "[dpdk-dev,v3,3/3] test: add tests for reciprocal based division", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "056ef64bf7a909e500f177f23e5de78273f23572", "submitter": { "id": 768, "url": "https://patches.dpdk.org/api/people/768/?format=api", "name": "Pavan Nikhilesh", "email": "pbhagavatula@caviumnetworks.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1504442189-4384-3-git-send-email-pbhagavatula@caviumnetworks.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/28307/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/28307/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 470637CCA;\n\tSun, 3 Sep 2017 14:37:12 +0200 (CEST)", "from NAM03-BY2-obe.outbound.protection.outlook.com\n\t(mail-by2nam03on0068.outbound.protection.outlook.com [104.47.42.68])\n\tby dpdk.org (Postfix) with ESMTP id 5FE207CCA\n\tfor <dev@dpdk.org>; Sun, 3 Sep 2017 14:37:10 +0200 (CEST)", "from localhost.localdomain (103.16.71.101) by\n\tBN6PR07MB3457.namprd07.prod.outlook.com (10.161.153.20) with\n\tMicrosoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id\n\t15.20.13.10; Sun, 3 Sep 2017 12:37:07 +0000" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version;\n\tbh=BYdEUNn9VND745guVeHAo2ZywOdm+RDl3/hO81aXg8c=;\n\tb=hq9QvHDC27A7Yy9dOIk/89VXX/f/0SVlAre0DM09NvjkVMuhZVj+eOc9Q1GjayQy0TojGXR7mleExWV48vjJCNBiyHBb5v5AU4HDIc5jSXt58eSLDSQYaz8xSjc3BK9+aYPshpiucSHHldp+T/UoWQntPgwTu2fHIfEenRcrwus=", "Authentication-Results": "spf=none (sender IP is )\n\tsmtp.mailfrom=Pavan.Bhagavatula@cavium.com; ", "From": "Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>", "To": "dev@dpdk.org", "Cc": "cristian.dumitrescu@intel.com, stephen@networkplumber.org,\n\tPavan Nikhilesh <pbhagavatula@caviumnetworks.com>", "Date": "Sun, 3 Sep 2017 18:06:29 +0530", "Message-Id": "<1504442189-4384-3-git-send-email-pbhagavatula@caviumnetworks.com>", "X-Mailer": "git-send-email 2.7.4", "In-Reply-To": "<1504442189-4384-1-git-send-email-pbhagavatula@caviumnetworks.com>", "References": "<1504442189-4384-1-git-send-email-pbhagavatula@caviumnetworks.com>", "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)\n\tTo BN6PR07MB3457.namprd07.prod.outlook.com (10.161.153.20)", "X-MS-PublicTrafficType": "Email", "X-MS-Office365-Filtering-Correlation-Id": "80fc1591-dfce-439f-ed92-08d4f2c87e0b", "X-Microsoft-Antispam": "UriScan:; BCL:0; PCL:0;\n\tRULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);\n\tSRVR:BN6PR07MB3457; ", "X-Microsoft-Exchange-Diagnostics": [ "1; BN6PR07MB3457;\n\t3:W4a/E+joJWi68NTvTWKgPnAt69kZ+xRkBniw7JHOT9NKpLlrzwsTI4a3K/PnKhWHr++vu57QGT5W1U5Df73dE15xpuVqzHUqA+Es32dacngUBiaIR4pD4MNtYr05xMnhQeJi9bvh0Guy9puTFZJd9nl6VJ0qpZDQd65VLyD4kE9z7hwmvnOyD3JrFkugh91MlRN2EUeh1bsagJrtFEIztmrCodWFq6HHE5bN31/UdXp/B1O7hlYWKDBP6RewiIL/;\n\t25:nUEtw2j5B9XFMIWOAUHZNbVu2SovccVvZfFzfoaHGEkPTQzKV8T5+DLps+PQwuNQk0nCqgqVYpFi/55xOz7q9GP9iUyHOhmci0ze1o91LOOwekpvMLVi6FQFaV4Tk2CBkz77zV2zTyraWUkJLIdawh3Zmzc8O4gIIqSTv0VC/9138A1SYX1YgA8IgBfQ19w8C21c3BtjKu8ETMZv2JS0y/Va0wEEeTXQQynb/9tyN05CD2nBiaQxw7BftNk0eSwCbf+OcTCl1taK3Wqr+QtRG/QwFmHLq9zDXRkhHxSiLNINmm/nlzc2Hfie7xEO4tTFpZH/knhvLeQavzyPS2YwJg==;\n\t31:KMbH5pRWsgv9tju/czBYtMKk9E7Kc1MIgxtWa5drUk1vQMJHokMoPc7WkcLU9V5lkQS81OKtR4Ud+/rIlHy/vRuQ+X8kQSF8O3XyE8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AUj1gj3MBnRMf9uDA9NjJITzv1LoWTRJVm8X1xbvpBpFlcu+woihfNqbBtSjGSsYpKgw9kR+3bjqzMa+9L5yDFD6rWj", "1; BN6PR07MB3457;\n\t6:6U6cQxkYpZg03V0O0njfeerOe9mQwo1l1UsnATYpDJEDa7aSRRPNfnSpfIvz6TPjSMM5zoHpAl8cs4TNqtfeEuP0UG+evqPVNMKWUVrEbxtwvBBfA9T1CcjYTwqDBpUNQ5+dbspNNjTX80i6ohze/BFMWs/pW2drAJVJPfujetg5gmIbLz49VZD41ktgHWjBY8ov2Q4UGp2Yiz7vY3HNu83ZIqI2/3NqBypU42OUEz1hnlZJokUB0Fq8dus4ebdfYhaowatSHwZDMlsIkqrWnj+vUE3jsg3zvjAll43cS/kxJbngmLdOX6KwJQxrPNFj7cvIH2uvKKTjYi5+KgZcFg==;\n\t5:KbwRP7sTWU2USnL6bWgWiHSsgqTC8/y0DKnFABJc5oNSL4svVvdOFksFXrgOCbsJ4GHm9xdgsm5vkJvIenzCt9RTgfUbB0KzNKmSS+q+HFwmCL7tmx0ibklJ9Vtq8zGqXVGHJrD80sXm7JZ2PvKDmg==;\n\t24:h7+JmKLVrh/hFuZXwEelrstORd1aSD4Z2tPHCP4mAK8wa7hWwqb8rTEBkVe9ywqRAx/zCrwfj4XcCpBAk43RAqakXW/yin0LfxsOy1gjlT4=;\n\t7:g1Ij17e6samz1PX5KgMu8oTZmdq+ZSSsPIU6/ymXv3YQhaOeFzBkRydGjOog3W7HZu5upLhXsISenbIL+haysR+vvMZ4XO6a/CD3KZMfnRssRAb2OKSg9e6AK0GbKiOv/iM90s8qglVT34jfnl13E1CBsU2Xv4Y848ZGj/G9mO0iWSj09zY/3hgSfUWNDqwP+1eJWa4W5QIY4Zu1KdadANdBbyXKeL2tm5d52reDkMA=" ], "X-MS-TrafficTypeDiagnostic": "BN6PR07MB3457:", "X-Exchange-Antispam-Report-Test": "UriScan:;", "X-Microsoft-Antispam-PRVS": "<BN6PR07MB345760AFACF39DC71C00416C80900@BN6PR07MB3457.namprd07.prod.outlook.com>", "X-Exchange-Antispam-Report-CFA-Test": "BCL:0; PCL:0;\n\tRULEID:(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);\n\tSRVR:BN6PR07MB3457; BCL:0; PCL:0;\n\tRULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);\n\tSRVR:BN6PR07MB3457; ", "X-Forefront-PRVS": "041963B986", "X-Forefront-Antispam-Report": "SFV:NSPM;\n\tSFS:(10009020)(6009001)(6069001)(189002)(199003)(107886003)(5003940100001)(6116002)(3846002)(2906002)(189998001)(5660300001)(110136004)(48376002)(53936002)(6512007)(97736004)(50466002)(33646002)(66066001)(2351001)(106356001)(2361001)(105586002)(36756003)(76176999)(6506006)(50986999)(42186005)(47776003)(101416001)(478600001)(6486002)(25786009)(81156014)(50226002)(68736007)(8936002)(305945005)(72206003)(8676002)(81166006)(7736002)(6666003)(42882006)(2950100002)(6916009)(4326008)(42262002);\n\tDIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3457; H:localhost.localdomain;\n\tFPR:; \n\tSPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; ", "Received-SPF": "None (protection.outlook.com: cavium.com does not designate\n\tpermitted sender hosts)", "SpamDiagnosticOutput": "1:99", "SpamDiagnosticMetadata": "NSPM", "X-OriginatorOrg": "caviumnetworks.com", "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "03 Sep 2017 12:37:07.2705\n\t(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 3/3] test: add tests for reciprocal based\n\tdivision", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "This commit provides a set of tests for verifying the correctness and\nperformance of both unsigned 32 and 64bit reciprocal based division.\n\nSigned-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>\n---\n test/test/Makefile | 2 +\n test/test/test_reciprocal_division.c | 109 ++++++++++++++++++\n test/test/test_reciprocal_division_perf.c | 181 ++++++++++++++++++++++++++++++\n 3 files changed, 292 insertions(+)\n create mode 100644 test/test/test_reciprocal_division.c\n create mode 100644 test/test/test_reciprocal_division_perf.c", "diff": "diff --git a/test/test/Makefile b/test/test/Makefile\nindex 42d9a49..6017862 100644\n--- a/test/test/Makefile\n+++ b/test/test/Makefile\n@@ -94,6 +94,8 @@ SRCS-y += test_cycles.c\n SRCS-y += test_spinlock.c\n SRCS-y += test_memory.c\n SRCS-y += test_memzone.c\n+SRCS-y += test_reciprocal_division.c\n+SRCS-y += test_reciprocal_division_perf.c\n \n SRCS-y += test_ring.c\n SRCS-y += test_ring_perf.c\ndiff --git a/test/test/test_reciprocal_division.c b/test/test/test_reciprocal_division.c\nnew file mode 100644\nindex 0000000..771ea64\n--- /dev/null\n+++ b/test/test/test_reciprocal_division.c\n@@ -0,0 +1,109 @@\n+/*\n+ * BSD LICENSE\n+ *\n+ * Copyright (C) Cavium, Inc. 2017.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Cavium, Inc nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include \"test.h\"\n+\n+#include <stdio.h>\n+#include <unistd.h>\n+#include <inttypes.h>\n+\n+#include <rte_common.h>\n+#include <rte_cycles.h>\n+#include <rte_random.h>\n+#include <rte_reciprocal.h>\n+\n+#define MAX_ITERATIONS\t1000000\n+#define DIVIDE_ITER\t\t100\n+\n+static int\n+test_reciprocal_division(void)\n+{\n+\tint i;\n+\tint result = 0;\n+\tuint32_t divisor_u32 = 0;\n+\tuint32_t dividend_u32;\n+\tuint32_t nresult_u32;\n+\tuint32_t rresult_u32;\n+\tuint64_t divisor_u64 = 0;\n+\tuint64_t dividend_u64;\n+\tuint64_t nresult_u64;\n+\tuint64_t rresult_u64;\n+\tstruct rte_reciprocal_u32 reci_u32;\n+\tstruct rte_reciprocal_u64 reci_u64;\n+\n+\trte_srand(rte_rdtsc());\n+\tprintf(\"Validating unsigned 32bit division.\\n\");\n+\tfor (i = 0; i < MAX_ITERATIONS; i++) {\n+\t\t/* Change divisor every DIVIDE_ITER iterations. */\n+\t\tif (i % DIVIDE_ITER == 0) {\n+\t\t\tdivisor_u32 = rte_rand();\n+\t\t\treci_u32 = rte_reciprocal_value_u32(divisor_u32);\n+\t\t}\n+\n+\t\tdividend_u32 = rte_rand();\n+\t\tnresult_u32 = dividend_u32 / divisor_u32;\n+\t\trresult_u32 = rte_reciprocal_divide_u32(dividend_u32,\n+\t\t\t\t&reci_u32);\n+\t\tif (nresult_u32 != rresult_u32) {\n+\t\t\tprintf(\"Division failed, expected %\"PRIu32\" \"\n+\t\t\t\t \"result %\"PRIu32\"\",\n+\t\t\t\t\tnresult_u32, rresult_u32);\n+\t\t\tresult = 1;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tprintf(\"Validating unsigned 64bit division.\\n\");\n+\tfor (i = 0; i < MAX_ITERATIONS; i++) {\n+\t\t/* Change divisor every DIVIDE_ITER iterations. */\n+\t\tif (i % DIVIDE_ITER == 0) {\n+\t\t\tdivisor_u64 = rte_rand();\n+\t\t\treci_u64 = rte_reciprocal_value_u64(divisor_u64);\n+\t\t}\n+\n+\t\tdividend_u64 = rte_rand();\n+\t\tnresult_u64 = dividend_u64 / divisor_u64;\n+\t\trresult_u64 = rte_reciprocal_divide_u64(dividend_u64,\n+\t\t\t\t&reci_u64);\n+\t\tif (nresult_u64 != rresult_u64) {\n+\t\t\tprintf(\"Division failed, expected %\"PRIu64\" \"\n+\t\t\t\t \"result %\"PRIu64\"\",\n+\t\t\t\t\tnresult_u64, rresult_u64);\n+\t\t\tresult = 1;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\treturn result;\n+}\n+\n+REGISTER_TEST_COMMAND(reciprocal_division, test_reciprocal_division);\ndiff --git a/test/test/test_reciprocal_division_perf.c b/test/test/test_reciprocal_division_perf.c\nnew file mode 100644\nindex 0000000..31f069d\n--- /dev/null\n+++ b/test/test/test_reciprocal_division_perf.c\n@@ -0,0 +1,181 @@\n+/*\n+ * BSD LICENSE\n+ *\n+ * Copyright (C) Cavium, Inc. 2017.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Cavium, Inc nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include \"test.h\"\n+\n+#include <stdio.h>\n+#include <unistd.h>\n+#include <inttypes.h>\n+\n+#include <rte_common.h>\n+#include <rte_cycles.h>\n+#include <rte_random.h>\n+#include <rte_reciprocal.h>\n+\n+#define MAX_ITERATIONS\t1000000\n+#define DIVIDE_ITER\t\t100\n+\n+static int\n+test_reciprocal_division_perf(void)\n+{\n+\tint result = 0;\n+\tuint32_t divisor_u32 = 0;\n+\tuint32_t dividend_u32;\n+\tuint32_t nresult_u32;\n+\tuint32_t rresult_u32;\n+\tuint64_t divisor_u64 = 0;\n+\tuint64_t dividend_u64;\n+\tuint64_t nresult_u64;\n+\tuint64_t rresult_u64;\n+\tuint64_t cur_cyc;\n+\tuint64_t tot_cyc_n = 0;\n+\tuint64_t tot_cyc_r = 0;\n+\tuint64_t i;\n+\tstruct rte_reciprocal_u32 reci_u32 = {0};\n+\tstruct rte_reciprocal_u64 reci_u64 = {0};\n+\n+\trte_srand(rte_rdtsc());\n+\tprintf(\"Validating unsigned 32bit division.\\n\");\n+\tfor (i = 0; i < MAX_ITERATIONS; i++) {\n+\t\t/* Change divisor every DIVIDE_ITER iterations. */\n+\t\tif (i % DIVIDE_ITER == 0) {\n+\t\t\tdivisor_u32 = rte_rand();\n+\t\t\treci_u32 = rte_reciprocal_value_u32(divisor_u32);\n+\t\t}\n+\n+\t\tdividend_u32 = rte_rand();\n+\t\tcur_cyc = rte_rdtsc();\n+\t\tnresult_u32 = dividend_u32 / divisor_u32;\n+\t\ttot_cyc_n += rte_rdtsc() - cur_cyc;\n+\n+\t\tcur_cyc = rte_rdtsc();\n+\t\trresult_u32 = rte_reciprocal_divide_u32(dividend_u32,\n+\t\t\t\t&reci_u32);\n+\t\ttot_cyc_r += rte_rdtsc() - cur_cyc;\n+\t\tif (nresult_u32 != rresult_u32) {\n+\t\t\tprintf(\"Division failed, expected %\"PRIu32\" \"\n+\t\t\t\t\t\"result %\"PRIu32\"\",\n+\t\t\t\t\tnresult_u32, rresult_u32);\n+\t\t\tresult = 1;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tprintf(\"32bit Division results:\\n\");\n+\tprintf(\"Total number of cycles normal division : %\"PRIu64\"\\n\",\n+\t\t\ttot_cyc_n);\n+\tprintf(\"Total number of cycles reciprocal division : %\"PRIu64\"\\n\",\n+\t\t\ttot_cyc_r);\n+\tprintf(\"Cycles per division(normal) : %3.2f\\n\",\n+\t\t\t((double)tot_cyc_n)/i);\n+\tprintf(\"Cycles per division(normal) : %3.2f\\n\\n\",\n+\t\t\t((double)tot_cyc_r)/i);\n+\n+\ttot_cyc_n = 0;\n+\ttot_cyc_r = 0;\n+\tprintf(\"Validating unsigned 64bit division.\\n\");\n+\n+\tfor (i = 0; i < MAX_ITERATIONS; i++) {\n+\t\t/* Change divisor every DIVIDE_ITER iterations. */\n+\t\tif (i % DIVIDE_ITER == 0) {\n+\t\t\tdivisor_u64 = rte_rand();\n+\t\t\treci_u64 = rte_reciprocal_value_u64(divisor_u64);\n+\t\t}\n+\n+\t\tdividend_u64 = rte_rand();\n+\t\tcur_cyc = rte_rdtsc();\n+\t\tnresult_u64 = dividend_u64 / divisor_u64;\n+\t\ttot_cyc_n += rte_rdtsc() - cur_cyc;\n+\n+\t\tcur_cyc = rte_rdtsc();\n+\t\trresult_u64 = rte_reciprocal_divide_u64(dividend_u64,\n+\t\t\t\t&reci_u64);\n+\t\ttot_cyc_r += rte_rdtsc() - cur_cyc;\n+\t\tif (nresult_u64 != rresult_u64) {\n+\t\t\tprintf(\"Division failed, expected %\"PRIu64\" \"\n+\t\t\t\t\t\"result %\"PRIu64\"\",\n+\t\t\t\t\tnresult_u64, rresult_u64);\n+\t\t\tresult = 1;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tprintf(\"64bit Division results:\\n\");\n+\tprintf(\"Total number of cycles normal division : %\"PRIu64\"\\n\",\n+\t\t\ttot_cyc_n);\n+\tprintf(\"Total number of cycles reciprocal division : %\"PRIu64\"\\n\",\n+\t\t\ttot_cyc_r);\n+\tprintf(\"Cycles per division(normal) : %3.2f\\n\",\n+\t\t\t((double)tot_cyc_n)/i);\n+\tprintf(\"Cycles per division(normal) : %3.2f\\n\\n\",\n+\t\t\t((double)tot_cyc_r)/i);\n+\n+\tprintf(\"Validating unsigned 64bit division with 32bit divisor.\\n\");\n+\tfor (i = 0; i < MAX_ITERATIONS; i++) {\n+\t\t/* Change divisor every DIVIDE_ITER iterations. */\n+\t\tif (i % DIVIDE_ITER == 0) {\n+\t\t\tdivisor_u64 = rte_rand() >> 32;\n+\t\t\treci_u64 = rte_reciprocal_value_u64(divisor_u64);\n+\t\t}\n+\n+\t\tdividend_u64 = rte_rand();\n+\t\tcur_cyc = rte_rdtsc();\n+\t\tnresult_u64 = dividend_u64 / divisor_u64;\n+\t\ttot_cyc_n += rte_rdtsc() - cur_cyc;\n+\n+\t\tcur_cyc = rte_rdtsc();\n+\t\trresult_u64 = rte_reciprocal_divide_u64(dividend_u64,\n+\t\t\t\t&reci_u64);\n+\t\ttot_cyc_r += rte_rdtsc() - cur_cyc;\n+\t\tif (nresult_u64 != rresult_u64) {\n+\t\t\tprintf(\"Division failed, expected %\"PRIu64\" \"\n+\t\t\t\t\t\"result %\"PRIu64\"\",\n+\t\t\t\t\tnresult_u64, rresult_u64);\n+\t\t\tresult = 1;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tprintf(\"64bit Division results:\\n\");\n+\tprintf(\"Total number of cycles normal division : %\"PRIu64\"\\n\",\n+\t\t\ttot_cyc_n);\n+\tprintf(\"Total number of cycles reciprocal division : %\"PRIu64\"\\n\",\n+\t\t\ttot_cyc_r);\n+\tprintf(\"Cycles per division(normal) : %3.2f\\n\",\n+\t\t\t((double)tot_cyc_n)/i);\n+\tprintf(\"Cycles per division(normal) : %3.2f\\n\",\n+\t\t\t((double)tot_cyc_r)/i);\n+\n+\ttot_cyc_n = 0;\n+\ttot_cyc_r = 0;\n+\n+\treturn result;\n+}\n+\n+REGISTER_TEST_COMMAND(reciprocal_division_perf, test_reciprocal_division_perf);\n", "prefixes": [ "dpdk-dev", "v3", "3/3" ] }{ "id": 28307, "url": "