Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PermutationBB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
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
GMYS Jan
PermutationBB
Commits
497954ba
Commit
497954ba
authored
1 year ago
by
GMYS Jan
Browse files
Options
Downloads
Patches
Plain Diff
fix random ws
parent
90f46ae1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
multicore/base/victim_selector.h
+2
-16
2 additions, 16 deletions
multicore/base/victim_selector.h
with
2 additions
and
16 deletions
multicore/base/victim_selector.h
+
2
−
16
View file @
497954ba
...
...
@@ -44,18 +44,11 @@ class RandomVictimSelector : public VictimSelector
{
public:
explicit
RandomVictimSelector
(
unsigned
_nthreads
)
:
VictimSelector
(
_nthreads
),
random_engine
((
std
::
random_device
())())
{
// auto seed = static_cast<long int>(std::time(nullptr));
// random_engine = std::mt19937(size_t(seed));
// generator = std::random_device{ } ();
// unif = std::uniform_int_distribution<int>(0,nthreads-1);
};
{};
unsigned
operator
()(
unsigned
id
)
{
unsigned
victim
=
(
id
==
0
)
?
(
nthreads
-
1
)
:
(
id
-
1
);
// unsigned int attempts = 0;
std
::
uniform_int_distribution
<
int
>
unif
(
0
,
nthreads
-
1
);
do
{
...
...
@@ -63,22 +56,15 @@ public:
victim
=
unif
(
random_engine
);
if
((
victim
<
0
)
||
(
victim
>=
nthreads
)){
std
::
cout
<<
"rand out of bounds :"
<<
victim
<<
" >= "
<<
nthreads
<<
"
\n
"
;
std
::
cout
<<
"
victim select -
rand
is
out of bounds :"
<<
victim
<<
" >= "
<<
nthreads
<<
"
\n
"
;
exit
(
-
1
);
}
// rand() / (RAND_MAX / nthreads);
// if(++attempts > nthreads){
// break;
// }
}
while
(
victim
==
id
);
return
victim
;
}
private
:
// std::random_device random_device;
std
::
mt19937
random_engine
;
// std::uniform_int_distribution<int> unif;
};
class
HonestVictimSelector
:
public
VictimSelector
...
...
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