Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/111841/?format=api
http://patchwork.dpdk.org/api/patches/111841/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20220525171231.200035-2-stephen@networkplumber.org/", "project": { "id": 1, "url": "http://patchwork.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": "<20220525171231.200035-2-stephen@networkplumber.org>", "list_archive_url": "https://inbox.dpdk.org/dev/20220525171231.200035-2-stephen@networkplumber.org", "date": "2022-05-25T17:12:28", "name": "[v3,1/3] random: add rte_drand() funciton", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "6c4315fccc5b9d5d0c43fc294a3126a7756d7db9", "submitter": { "id": 27, "url": "http://patchwork.dpdk.org/api/people/27/?format=api", "name": "Stephen Hemminger", "email": "stephen@networkplumber.org" }, "delegate": { "id": 1, "url": "http://patchwork.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20220525171231.200035-2-stephen@networkplumber.org/mbox/", "series": [ { "id": 23161, "url": "http://patchwork.dpdk.org/api/series/23161/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=23161", "date": "2022-05-25T17:12:27", "name": "introduce random floating point function", "version": 3, "mbox": "http://patchwork.dpdk.org/series/23161/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/111841/comments/", "check": "warning", "checks": "http://patchwork.dpdk.org/api/patches/111841/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id A78E8A0555;\n\tWed, 25 May 2022 19:12:41 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id D63CB4113D;\n\tWed, 25 May 2022 19:12:37 +0200 (CEST)", "from mail-pj1-f52.google.com (mail-pj1-f52.google.com\n [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id 8D14C400EF\n for <dev@dpdk.org>; Wed, 25 May 2022 19:12:36 +0200 (CEST)", "by mail-pj1-f52.google.com with SMTP id\n pq9-20020a17090b3d8900b001df622bf81dso5690627pjb.3\n for <dev@dpdk.org>; Wed, 25 May 2022 10:12:36 -0700 (PDT)", "from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199])\n by smtp.gmail.com with ESMTPSA id\n s23-20020a170902b19700b001622c377c3esm6139599plr.117.2022.05.25.10.12.34\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 25 May 2022 10:12:34 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20210112.gappssmtp.com; s=20210112;\n h=from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding;\n bh=Tygx89Zhqtg6Bhg8l7jVAKmZEg/X3T+sUwkuOfRrSkQ=;\n b=neON6zVKr9WgjWkcomR1Z9TY32IgXJHvrpxt1EvJzQgEunlqGg0sExfEzk4P3cwQ3K\n 5J+zUcwOVgdg0v9RQPYL0UMNdDHUsIi5YVXG6BcZB2Ar1oOr0QUAv//bqKhef8C7K7gU\n FUFDX4BOQT9p9RdzdjcPXCb59SBAuFDK2/YcZ3gUN3WN4liDII2awl7mRHEEyJszqc4N\n lD0PHWpjJU1XXFD7714uPFW6Xnu9u43/JLGA54CIZZy6ouDgNmKLoO0kDdGYO4yxc6du\n 44Ny1waObqyEL7byuGwdSaeNbtyouyV9o97J+A78an12J+vny0/Rd7sx+6w+P1fd+JRu\n yx/A==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20210112;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references:mime-version:content-transfer-encoding;\n bh=Tygx89Zhqtg6Bhg8l7jVAKmZEg/X3T+sUwkuOfRrSkQ=;\n b=EWo0tRbt/3N9+geiue5Hdbe5xTyFPe3RqG52sU9dUtwoigZTHior35gk4rcjv5/RbY\n gVw9p8T2YM/X8Zlc3q7v5T0ehoWj2jzoZm+INg4xU4ExZufHakR0wxg4gXsauftvCtW1\n vs4whLMWaDkBXTiP/xussPnVXyV0IREy3ETlZ3JUTpH6n7YZPGRG5x8/FdlRtJQYBMd9\n 0/YSi24TGWvQ3eVO/I/DfCfS9kFMLWBhz4DZ4kwXwPaibETVt8WIUKw8sTdaGIFKV4IS\n LWJn3h9GWRVK73dPtAfoZA7s9d0V7nrw6CQn9Oqyreo3HsedcOzQUgxGRiWynkzUN0YS\n YMlA==", "X-Gm-Message-State": "AOAM5300q5gKxF+xZ5MlcalSHVLXy719PPjLRTozUaZ1JpvPLzKhgj5C\n NWgoaIEZlL4n0uJdbBMaExtM4ST2bj10fw==", "X-Google-Smtp-Source": "\n ABdhPJxp5MmWssaUPDjDa5L+a0TW3kUhhZ+fFypez3IGEu/cCnqoiIEwKQNLitDORUJL9kDgDk2J6A==", "X-Received": "by 2002:a17:90a:68c7:b0:1e0:a8b9:a85e with SMTP id\n q7-20020a17090a68c700b001e0a8b9a85emr4886389pjj.134.1653498755513;\n Wed, 25 May 2022 10:12:35 -0700 (PDT)", "From": "Stephen Hemminger <stephen@networkplumber.org>", "To": "dev@dpdk.org", "Cc": "Stephen Hemminger <stephen@networkplumber.org>, =?utf-8?q?Mattias_R?=\n\t=?utf-8?q?=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>,\n Ray Kinsella <mdr@ashroe.eu>", "Subject": "[PATCH v3 1/3] random: add rte_drand() funciton", "Date": "Wed, 25 May 2022 10:12:28 -0700", "Message-Id": "<20220525171231.200035-2-stephen@networkplumber.org>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20220525171231.200035-1-stephen@networkplumber.org>", "References": "<20220524184623.480646-1-stephen@networkplumber.org>\n <20220525171231.200035-1-stephen@networkplumber.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "The PIE code and other applications can benefit from having a\nfast way to get a random floating point value. This new function\nis equivalent to drand() in the standard library.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n app/test/test_rand_perf.c | 7 +++++++\n doc/guides/rel_notes/release_22_07.rst | 5 +++++\n lib/eal/common/rte_random.c | 24 ++++++++++++++++++++++++\n lib/eal/include/rte_random.h | 18 ++++++++++++++++++\n lib/eal/version.map | 1 +\n 5 files changed, 55 insertions(+)", "diff": "diff --git a/app/test/test_rand_perf.c b/app/test/test_rand_perf.c\nindex fe797ebfa1ca..26fb1d9a586e 100644\n--- a/app/test/test_rand_perf.c\n+++ b/app/test/test_rand_perf.c\n@@ -20,6 +20,7 @@ static volatile uint64_t vsum;\n \n enum rand_type {\n \trand_type_64,\n+\trand_type_float,\n \trand_type_bounded_best_case,\n \trand_type_bounded_worst_case\n };\n@@ -30,6 +31,8 @@ rand_type_desc(enum rand_type rand_type)\n \tswitch (rand_type) {\n \tcase rand_type_64:\n \t\treturn \"Full 64-bit [rte_rand()]\";\n+\tcase rand_type_float:\n+\t\treturn \"Floating point [rte_drand()]\";\n \tcase rand_type_bounded_best_case:\n \t\treturn \"Bounded average best-case [rte_rand_max()]\";\n \tcase rand_type_bounded_worst_case:\n@@ -55,6 +58,9 @@ test_rand_perf_type(enum rand_type rand_type)\n \t\tcase rand_type_64:\n \t\t\tsum += rte_rand();\n \t\t\tbreak;\n+\t\tcase rand_type_float:\n+\t\t\tsum += 1000. * rte_drand();\n+\t\t\tbreak;\n \t\tcase rand_type_bounded_best_case:\n \t\t\tsum += rte_rand_max(BEST_CASE_BOUND);\n \t\t\tbreak;\n@@ -83,6 +89,7 @@ test_rand_perf(void)\n \tprintf(\"Pseudo-random number generation latencies:\\n\");\n \n \ttest_rand_perf_type(rand_type_64);\n+\ttest_rand_perf_type(rand_type_float);\n \ttest_rand_perf_type(rand_type_bounded_best_case);\n \ttest_rand_perf_type(rand_type_bounded_worst_case);\n \ndiff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst\nindex e49cacecefd4..128d4fca85b3 100644\n--- a/doc/guides/rel_notes/release_22_07.rst\n+++ b/doc/guides/rel_notes/release_22_07.rst\n@@ -104,6 +104,11 @@ New Features\n * ``RTE_EVENT_QUEUE_ATTR_WEIGHT``\n * ``RTE_EVENT_QUEUE_ATTR_AFFINITY``\n \n+* ** Added function get random floating point number.**\n+\n+ Added the function ``rte_drand()`` to provide a pseudo-random\n+ floating point number.\n+\n \n Removed Items\n -------------\ndiff --git a/lib/eal/common/rte_random.c b/lib/eal/common/rte_random.c\nindex 4535cc980cec..a30bb104015b 100644\n--- a/lib/eal/common/rte_random.c\n+++ b/lib/eal/common/rte_random.c\n@@ -6,6 +6,7 @@\n #include <x86intrin.h>\n #endif\n #include <unistd.h>\n+#include <ieee754.h>\n \n #include <rte_branch_prediction.h>\n #include <rte_cycles.h>\n@@ -173,6 +174,29 @@ rte_rand_max(uint64_t upper_bound)\n \treturn res;\n }\n \n+double\n+rte_drand(void)\n+{\n+\tstruct rte_rand_state *state = __rte_rand_get_state();\n+\tunion ieee754_double u = {\n+\t\t.ieee = {\n+\t\t\t.negative = 0,\n+\t\t\t.exponent = IEEE754_DOUBLE_BIAS,\n+\t\t},\n+\t};\n+\tuint64_t val;\n+\n+\t/* Take 64 bit random value and put it into the mantissa\n+\t * This uses direct access to IEEE format to avoid doing\n+\t * any direct floating point math here.\n+\t */\n+\tval = __rte_rand_lfsr258(state);\n+\tu.ieee.mantissa0 = val >> 32;\n+\tu.ieee.mantissa1 = val;\n+\n+\treturn u.d - 1.0;\n+}\n+\n static uint64_t\n __rte_random_initial_seed(void)\n {\ndiff --git a/lib/eal/include/rte_random.h b/lib/eal/include/rte_random.h\nindex 29f5f1325a30..f6541c2b0f08 100644\n--- a/lib/eal/include/rte_random.h\n+++ b/lib/eal/include/rte_random.h\n@@ -65,6 +65,24 @@ rte_rand(void);\n uint64_t\n rte_rand_max(uint64_t upper_bound);\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * Generates a pseudo-random floating point number.\n+ *\n+ * This function returns a nonnegative double-precision floating random\n+ * number uniformly distributed over the interval [0.0, 1.0).\n+ *\n+ * The generator is not cryptographically secure.\n+ * If called from lcore threads, this function is thread-safe.\n+ *\n+ * @return\n+ * A pseudo-random value between 0 and 1.0.\n+ */\n+__rte_experimental\n+double rte_drand(void);\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/eal/version.map b/lib/eal/version.map\nindex d49e30bd042f..cfbade9a33e9 100644\n--- a/lib/eal/version.map\n+++ b/lib/eal/version.map\n@@ -422,6 +422,7 @@ EXPERIMENTAL {\n \trte_intr_type_set;\n \n \t# added in 22.07\n+\trte_drand;\n \trte_thread_get_affinity_by_id;\n \trte_thread_self;\n \trte_thread_set_affinity_by_id;\n", "prefixes": [ "v3", "1/3" ] }{ "id": 111841, "url": "