Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
specx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRAMAS Berenger
specx
Commits
10f03e82
"README.md" did not exist on "c9ced2228bc11a8d010d29ac9ac4b059c073265c"
Commit
10f03e82
authored
4 years ago
by
CARDOSI Paul
Browse files
Options
Downloads
Patches
Plain Diff
Remove force_computation_ boolean.
parent
f92f1958
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Src/Random/SpPhiloxGenerator.hpp
+11
-20
11 additions, 20 deletions
Src/Random/SpPhiloxGenerator.hpp
with
11 additions
and
20 deletions
Src/Random/SpPhiloxGenerator.hpp
+
11
−
20
View file @
10f03e82
...
...
@@ -37,7 +37,7 @@ class SpPhiloxGenerator {
explicit
philox4x32
(
uint64
seed
,
int
cycles
=
DEFAULT_CYCLES
)
:
counter_
(),
temp_results_
(),
key_
(),
temp_counter_
(
0
),
cycles_
(
cycles
),
force_computation_
(
true
),
operatorPPcounter
(
0
)
operatorPPcounter
(
0
)
{
// Splitting the seed in two
key_
[
0
]
=
static_cast
<
uint32
>
(
seed
);
...
...
@@ -66,16 +66,10 @@ class SpPhiloxGenerator {
count
-=
nbStepsToNextMultipleOf4
;
// We need to add 1 to the counter because we have moved past
// all the 4 results from the current temp_results_ array. This
// also includes the special case where we already are on the edge
// (temp_counter_ == 4) but we haven't triggered a counter increment yet.
// We can safely add 1 here (instead of calling SkipOne). I won't cause any
// overfow since we are dividing the value of count by 4 and count has a
// width of 64 bits.
const
auto
nbOfCounterIncrements
=
count
/
4
+
1
;
temp_counter_
=
4
;
// we set it to 4 to trigger computation the next time operator() is called
temp_counter_
=
count
%
4
;
const
auto
nbOfCounterIncrements
=
count
/
4
;
const
auto
newTempCounter
=
count
%
4
;
const
auto
count_lo
=
static_cast
<
uint32
>
(
nbOfCounterIncrements
);
auto
count_hi
=
static_cast
<
uint32
>
(
nbOfCounterIncrements
>>
32
);
...
...
@@ -94,7 +88,11 @@ class SpPhiloxGenerator {
}
}
force_computation_
=
true
;
if
(
newTempCounter
>
0
)
{
temp_counter_
=
newTempCounter
;
temp_results_
=
counter_
;
ExecuteRounds
();
}
}
}
...
...
@@ -104,12 +102,6 @@ class SpPhiloxGenerator {
if
(
temp_counter_
==
4
)
{
temp_counter_
=
0
;
SkipOne
();
force_computation_
=
true
;
}
if
(
force_computation_
)
{
force_computation_
=
false
;
temp_results_
=
counter_
;
ExecuteRounds
();
}
...
...
@@ -152,9 +144,6 @@ class SpPhiloxGenerator {
// The number of cycles used to generate randomness
int
cycles_
;
// To force the engine to compute the rounds to populates temp_results_
bool
force_computation_
;
// The number of times operator () is called to ensure that the STL
// always call it once
uint32
operatorPPcounter
;
...
...
@@ -189,6 +178,8 @@ class SpPhiloxGenerator {
temp_results_
=
ComputeSingleRound
(
temp_results_
,
key
);
RaiseKey
(
&
key
);
}
SkipOne
();
}
// Helper function for a single round of the underlying Philox algorithm.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment