Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
2965-Optimize-mwc59-float-generation-for-speed....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2965-Optimize-mwc59-float-generation-for-speed.patch of Package erlang
From 0ca7af2271414e8610e02148f604dcdae1fde9a9 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen <raimo@erlang.org> Date: Tue, 10 May 2022 16:55:24 +0200 Subject: [PATCH 5/8] Optimize mwc59 float generation for speed High bits are better, but the low 53 bits contain fairly many hight bits, and the code for generating a float becomes faster, so sacrifice a little quality for a little speed. --- lib/stdlib/src/rand.erl | 8 ++++---- lib/stdlib/test/rand_SUITE.erl | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/stdlib/src/rand.erl b/lib/stdlib/src/rand.erl index ac61acd955..5f8d3a4c59 100644 --- a/lib/stdlib/src/rand.erl +++ b/lib/stdlib/src/rand.erl @@ -1533,10 +1533,10 @@ mwc59_value(CX1) -> % when is_integer(CX1), 1 =< CX1, CX1 < ?MWC59_P -> -spec mwc59_float(CX :: mwc59_state()) -> V :: float(). mwc59_float(CX1) -> - CX = ?MASK(59, CX1), - CX2 = CX bxor ?BSL(59, CX, ?MWC59_XS1), - CX3 = CX2 bxor ?BSL(59, CX2, ?MWC59_XS2), - (CX3 bsr (59-53)) * ?TWO_POW_MINUS53. + CX = ?MASK(53, CX1), + CX2 = CX bxor ?BSL(53, CX, ?MWC59_XS1), + CX3 = CX2 bxor ?BSL(53, CX2, ?MWC59_XS2), + CX3 * ?TWO_POW_MINUS53. -spec mwc59_seed() -> CX :: mwc59_state(). mwc59_seed() -> diff --git a/lib/stdlib/test/rand_SUITE.erl b/lib/stdlib/test/rand_SUITE.erl index 5f3df66bee..f1b2a33808 100644 --- a/lib/stdlib/test/rand_SUITE.erl +++ b/lib/stdlib/test/rand_SUITE.erl @@ -237,7 +237,7 @@ mwc59_api(CX0, 0) -> W = 269866568368142303, {W, W} = {W0, W}, F0 = rand:mwc59_float(CX0), - F = (W bsr (59-53)) * (1 / (1 bsl 53)), + F = (W band ((1 bsl 53)-1)) * (1 / (1 bsl 53)), {F, F} = {F0, F}, ok; mwc59_api(CX, N) -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor