Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/111922/?format=api
http://patches.dpdk.org/api/patches/111922/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20220526202653.99796-2-stephen@networkplumber.org/", "project": { "id": 1, "url": "http://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": "<20220526202653.99796-2-stephen@networkplumber.org>", "list_archive_url": "https://inbox.dpdk.org/dev/20220526202653.99796-2-stephen@networkplumber.org", "date": "2022-05-26T20:26:51", "name": "[v5,1/3] random: add rte_drand() function", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "cffe1be5badf652d8618687c03303534e6e8dbc5", "submitter": { "id": 27, "url": "http://patches.dpdk.org/api/people/27/?format=api", "name": "Stephen Hemminger", "email": "stephen@networkplumber.org" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20220526202653.99796-2-stephen@networkplumber.org/mbox/", "series": [ { "id": 23188, "url": "http://patches.dpdk.org/api/series/23188/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=23188", "date": "2022-05-26T20:26:50", "name": "introduce random floating point function", "version": 5, "mbox": "http://patches.dpdk.org/series/23188/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/111922/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/111922/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 22B34A0547;\n\tThu, 26 May 2022 22:27:04 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 6E4D4427EC;\n\tThu, 26 May 2022 22:27:02 +0200 (CEST)", "from mail-pf1-f172.google.com (mail-pf1-f172.google.com\n [209.85.210.172])\n by mails.dpdk.org (Postfix) with ESMTP id 71FD140DF7\n for <dev@dpdk.org>; Thu, 26 May 2022 22:26:58 +0200 (CEST)", "by mail-pf1-f172.google.com with SMTP id x143so2581041pfc.11\n for <dev@dpdk.org>; Thu, 26 May 2022 13:26:58 -0700 (PDT)", "from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199])\n by smtp.gmail.com with ESMTPSA id\n c20-20020a170902b69400b0015e8d4eb1e5sm2025316pls.47.2022.05.26.13.26.56\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 26 May 2022 13:26:56 -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=HeE7fHxqMA863zxLIscJSWOqklG7gOFE2iJ5Kfe2h7s=;\n b=4P2it92/N4pJQZnWLrp5dwqD6XE+OAUCqZVgrntkR3sreIt/0ljQY3A3Yp72zhditn\n 60NXOrHDKfLKr19oSFkKUm44dF6/XuMWXcn2Il8tSRBiZkGbYtIMSSCDKwZT+ZXRpR7E\n RbK4dZ4L3WmiWnemPdgZyJr8wqKhqB7cX0U90w7XLf1+wWHdN28erClnKtwTCulfLxkm\n 2XhQk5bd2PsfKYkCmvDGmPdPQLcGPs/DfcbiT/rAad2OZiQ/PNQPx33Vuhf9FS3JYn+B\n afy3Pa1l+k+4bkIDAtgJZU53K3GUlL1E/569vLtfU6K8nIqkRpKxNsxUL5DFbZ4ANPVH\n COWg==", "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=HeE7fHxqMA863zxLIscJSWOqklG7gOFE2iJ5Kfe2h7s=;\n b=eeqWNFWsw0jBEwFgkUnizOZ1ARRfk2J9PMT0Wj2YoDwzVLug6B2RSBDQeuwAHmJAL/\n lcZa3riD5wTMX/v/5ftyDGAfLN/YzNmbKa4RNmEK3Iv+8+e6AASHVS9IXL+c1grQQbxb\n 0cNiQgr7jz3F05k8d0zM+Dpc1KLcH2WRlVrSGO7AdRPKLoqspJnsVmEYX7MRrs6jvWDX\n fcxmrUkQs8K659x+HxS5Jc4u1EhYx+Z6sV04l6md8+SfqmXZb4aDHkF361EcZpin+03K\n vbWjhRVAoTF6SZweMhFRFnGgHkcDM6kfaNN5cqVGSDL6ZNjkGEZ5iyoLQ87v7CnFQYzP\n 3XNA==", "X-Gm-Message-State": "AOAM530uFjKGojGtSZJnhe8gS4u8wBywIOhc3X1Y5D4EM2lN9vzuyeQo\n CgoS3zI5TZydUmOmMIfbjhqhEc9NQG8cjA==", "X-Google-Smtp-Source": "\n ABdhPJx6qeJEd5px6XHwgN3l8S7yeF44/xq28wpu1k1q6w7MZYnCtWpUwRlRhw9Vqj/NJlGr4K51vQ==", "X-Received": "by 2002:a63:4d2:0:b0:3fa:b0a0:450e with SMTP id\n 201-20020a6304d2000000b003fab0a0450emr12380899pge.95.1653596817309;\n Thu, 26 May 2022 13:26:57 -0700 (PDT)", "From": "Stephen Hemminger <stephen@networkplumber.org>", "To": "dev@dpdk.org", "Cc": "Stephen Hemminger <stephen@networkplumber.org>,\n Ray Kinsella <mdr@ashoe.eu>,\n =?utf-8?q?Mattias_R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>,\n Ray Kinsella <mdr@ashroe.eu>", "Subject": "[PATCH v5 1/3] random: add rte_drand() function", "Date": "Thu, 26 May 2022 13:26:51 -0700", "Message-Id": "<20220526202653.99796-2-stephen@networkplumber.org>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20220526202653.99796-1-stephen@networkplumber.org>", "References": "<20220524184623.480646-1-stephen@networkplumber.org>\n <20220526202653.99796-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>\nAcked-by: Ray Kinsella <mdr@ashoe.eu>\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 | 19 +++++++++++++++++++\n lib/eal/include/rte_random.h | 18 ++++++++++++++++++\n lib/eal/version.map | 1 +\n 5 files changed, 50 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..b131ea577226 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..166b0d8921c9 100644\n--- a/lib/eal/common/rte_random.c\n+++ b/lib/eal/common/rte_random.c\n@@ -173,6 +173,25 @@ rte_rand_max(uint64_t upper_bound)\n \treturn res;\n }\n \n+double\n+rte_drand(void)\n+{\n+\tstatic const uint64_t denom = (uint64_t)1 << 53;\n+\tuint64_t rand64 = rte_rand();\n+\n+\t/*\n+\t * The double mantissa only has 53 bits, so we uniformly mask off the\n+\t * high 11 bits and then floating-point divide by 2^53 to achieve a\n+\t * result in [0, 1).\n+\t *\n+\t * We are not allowed to emit 1.0, so denom must be one greater than\n+\t * the possible range of the preceding step.\n+\t */\n+\n+\trand64 &= denom - 1;\n+\treturn (double)rand64 / denom;\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": [ "v5", "1/3" ] }{ "id": 111922, "url": "