Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/28147/?format=api
https://patches.dpdk.org/api/patches/28147/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1504176415-5236-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": "<1504176415-5236-3-git-send-email-pbhagavatula@caviumnetworks.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1504176415-5236-3-git-send-email-pbhagavatula@caviumnetworks.com", "date": "2017-08-31T10:46:55", "name": "[dpdk-dev,v2,3/3] test: add tests for reciprocal based division", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "c4d334d47fef91080eb1f4ae128cdcaf5ba185c9", "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/1504176415-5236-3-git-send-email-pbhagavatula@caviumnetworks.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/28147/comments/", "check": "fail", "checks": "https://patches.dpdk.org/api/patches/28147/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 570723255;\n\tThu, 31 Aug 2017 12:47:56 +0200 (CEST)", "from NAM03-CO1-obe.outbound.protection.outlook.com\n\t(mail-co1nam03on0042.outbound.protection.outlook.com [104.47.40.42])\n\tby dpdk.org (Postfix) with ESMTP id 0F43A2E8F\n\tfor <dev@dpdk.org>; Thu, 31 Aug 2017 12:47:53 +0200 (CEST)", "from PBHAGAVATULA-LT.caveonetworks.com (111.93.218.67) by\n\tDM5PR07MB3465.namprd07.prod.outlook.com (10.164.153.20) with\n\tMicrosoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id\n\t15.1.1385.9; Thu, 31 Aug 2017 10:47:49 +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=PaXbKyVmbwXko5M/WBbmQiAMGOxuoh13pGbZuVBaeR0=;\n\tb=ZkiTDcRl10c1qD9Sj7mOK5EH91rZv9Uimu1c3oJoAgmvYDY0H/vmCaf8VkROmoeyDuuehDrOltviA4Aoom7YKsKQdxwKUl0PEZAw9MIGQJgcCbFLhzRQdhOP/7vsbmjQY/Iuov+Vdwhqnx/racIze+rvnMxeF5KtHDORSRxnGBA=", "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": "Thu, 31 Aug 2017 16:16:55 +0530", "Message-Id": "<1504176415-5236-3-git-send-email-pbhagavatula@caviumnetworks.com>", "X-Mailer": "git-send-email 2.7.4", "In-Reply-To": "<1504176415-5236-1-git-send-email-pbhagavatula@caviumnetworks.com>", "References": "<1504176415-5236-1-git-send-email-pbhagavatula@caviumnetworks.com>", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Originating-IP": "[111.93.218.67]", "X-ClientProxiedBy": "BM1PR01CA0082.INDPRD01.PROD.OUTLOOK.COM (10.174.208.150)\n\tTo DM5PR07MB3465.namprd07.prod.outlook.com (10.164.153.20)", "X-MS-PublicTrafficType": "Email", "X-MS-Office365-Filtering-Correlation-Id": "5e29ad3e-852e-4a63-bdee-08d4f05dba23", "X-Microsoft-Antispam": "UriScan:; BCL:0; PCL:0;\n\tRULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);\n\tSRVR:DM5PR07MB3465; ", "X-Microsoft-Exchange-Diagnostics": [ "1; DM5PR07MB3465;\n\t3:ioZYOu4wCPZVm32kL6Q3Lb+VUo1dmWiHhAz7SrPWS5tiyrsMbKIDr2u4HQHySW5lfq86GmCzjZd74RgTcOtL6B1KqUCBt1A/P55gYEByZy70faxJ/wkD3T88bFPc6sJHluntnNwZznF3GUPUUHeXGUul3LRGOF8WYFG58H46h16kWtfUt8HLdfKWk5bxuGEn3XaPSEtguURBGuOSvcfLtKQw3yRoSQ3SNrQE4416UrdRF+Ed9FWBJtKPEh48pP11;\n\t25:620eWvjhlIkCOle+mPgavkt+Y0JT40J7CNiWO4iF3apDp5ri/oVHU2HigCeHaOqjNtDb3qn7pLvOa0+ugdwm3obKVlwpmef/Nc3sQCOqv55I0fvV3D9gR/dtEzmADTsOas9vqTnmI6Cyx+6LV6jUVkUizyysAWLUtR0EZlNwm9QQcIwvs/v9HXGrSii/zNBJRG0B8NZfSQiyhy4mRZn8dXtsvhebziQY7qVUHjFCqE2da/D3WZSk9oMc7rfxk1TCCEjd2G432LUvx+lCXMIOWrkUnXGcOT0WFpmzhwZNAGxex55hwBADJ6bHXgpmqpa00JDROIBlh+eyHje6cmlKbg==;\n\t31:15FWpKm52mBhfBdZCJBjIWG/DUMzUNQ9rwaEsXvFr/8/QIictOdV45mU2EV5wm9U8bWhIc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], "X-MS-TrafficTypeDiagnostic": "DM5PR07MB3465:", "X-Exchange-Antispam-Report-Test": "UriScan:;", "X-Microsoft-Antispam-PRVS": "<DM5PR07MB34656C7E5F885E48EDB3D7E2809D0@DM5PR07MB3465.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)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123555025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);\n\tSRVR:DM5PR07MB3465; BCL:0; PCL:0;\n\tRULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);\n\tSRVR:DM5PR07MB3465; ", "X-Forefront-PRVS": "04163EF38A", "X-Forefront-Antispam-Report": "SFV:NSPM;\n\tSFS:(10009020)(6009001)(189002)(199003)(50226002)(69596002)(6512007)(189998001)(72206003)(47776003)(110136004)(81166006)(66066001)(107886003)(81156014)(8936002)(5009440100003)(53936002)(8676002)(6116002)(6506006)(2906002)(97736004)(6486002)(36756003)(50466002)(3846002)(68736007)(305945005)(101416001)(2361001)(7736002)(5003940100001)(5660300001)(25786009)(478600001)(6916009)(2950100002)(42882006)(6666003)(48376002)(105586002)(33646002)(53416004)(4326008)(106356001)(76176999)(2351001)(50986999)(42186005)(42262002);\n\tDIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3465;\n\tH:PBHAGAVATULA-LT.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords;\n\tMX: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": "31 Aug 2017 10:47:49.4111\n\t(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 v2 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 | 111 ++++++++++++++++++\n test/test/test_reciprocal_division_perf.c | 183 ++++++++++++++++++++++++++++++\n 3 files changed, 296 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..8a445c3\n--- /dev/null\n+++ b/test/test/test_reciprocal_division.c\n@@ -0,0 +1,111 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ * All rights reserved.\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 Intel Corporation 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_cycles.h>\n+#include <rte_common.h>\n+#include <rte_pause.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..307b3d8\n--- /dev/null\n+++ b/test/test/test_reciprocal_division_perf.c\n@@ -0,0 +1,183 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ * All rights reserved.\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 Intel Corporation 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_cycles.h>\n+#include <rte_common.h>\n+#include <rte_pause.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", "v2", "3/3" ] }{ "id": 28147, "url": "