Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
659eeed1
authored
Mar 15, 2016
by
lucapegolotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve code readability and comments
parent
38a592bf
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
linearizability_tester/README.txt
+3
-3
linearizability_tester/main.cc
+16
-4
No files found.
linearizability_tester/README.txt
View file @
659eeed1
...
...
@@ -43,11 +43,11 @@ Data structures that support the following functions:
- erase an element from the structure
should be easily checkable using the Set specification contained in the
src/sequential_datastructures.h file.
In general, the checker needs a sequential implementation test against the
In general, the checker needs a sequential implementation t
o t
est against the
concurrent one (the EMBB one). The implementation should support efficient equality checks
and efficient memory management. Stick to the implementation of the already integrated
structures (stacks, queues..) for future integration.
After adding the implementation of the datastructure, it is necessary to add a worker and
experiment for the newly created datastructure in main.cc. Stick again to the already
implemented functions (it should be sufficient to change the name of the methods that are called
on the EMBB structure).
\ No newline at end of file
on the structures).
\ No newline at end of file
linearizability_tester/main.cc
View file @
659eeed1
/*
* Main script that applies the linearizability tester on embb data structures.
*/
#include <linearizability_tester.h>
#include <sequential_data_structures.h>
#include <tests.h>
#include <embb/base/thread.h>
#include <embb/containers/lock_free_stack.h>
#include <embb/containers/lock_free_mpmc_queue.h>
// Each thread executes quasi randomly operations (TryEqneueu, TryDequeue)
// on the concurrent data structure and construct the history.
template
<
std
::
size_t
N
,
class
S
>
static
void
embb_worker_stack
(
const
WorkerConfiguration
&
worker_configuration
,
...
...
@@ -16,7 +23,6 @@ static void embb_worker_stack(
std
::
uniform_int_distribution
<>
value_dist
(
'\0'
,
worker_configuration
.
max_value
);
std
::
uniform_int_distribution
<>
percentage_dist
(
0
,
100
);
// each operation returns false
bool
ret
;
char
value
;
...
...
@@ -28,6 +34,8 @@ static void embb_worker_stack(
{
value
=
value_dist
(
rd
);
percentage
=
percentage_dist
(
rd
);
// Note: this threshold affects considerably the running time of the test
// increasing threshold -> increasing running time
if
(
percentage
<
30
)
{
call_entry_ptr
=
concurrent_log
.
push_back
(
state
::
Stack
<
N
>::
make_try_push_call
(
value
));
...
...
@@ -43,6 +51,8 @@ static void embb_worker_stack(
}
}
// Each thread executes quasi randomly operations (TryEqneueu, TryDequeue)
// on the concurrent data structure and construct the history.
template
<
std
::
size_t
N
,
class
S
>
static
void
embb_worker_queue
(
const
WorkerConfiguration
&
worker_configuration
,
...
...
@@ -54,7 +64,6 @@ static void embb_worker_queue(
std
::
uniform_int_distribution
<>
value_dist
(
'\0'
,
worker_configuration
.
max_value
);
std
::
uniform_int_distribution
<>
percentage_dist
(
0
,
100
);
// each operation returns false
bool
ret
;
char
value
;
...
...
@@ -66,6 +75,8 @@ static void embb_worker_queue(
{
value
=
value_dist
(
rd
);
percentage
=
percentage_dist
(
rd
);
// Note: this threshold affects considerably the running time of the test
// increasing threshold -> increasing running time
if
(
percentage
<
20
)
{
call_entry_ptr
=
concurrent_log
.
push_back
(
state
::
Queue
<
N
>::
make_try_enqueue_call
(
value
));
...
...
@@ -81,6 +92,7 @@ static void embb_worker_queue(
}
}
// Creates the history and apply the tester on it
template
<
class
S
>
static
void
embb_experiment_stack
(
bool
is_linearizable
)
{
...
...
@@ -127,6 +139,7 @@ static void embb_experiment_stack(bool is_linearizable)
<<
seconds
.
count
()
<<
" s "
<<
std
::
endl
;
}
// Creates the history and apply the tester on it
template
<
class
S
>
static
void
embb_experiment_queue
(
bool
is_linearizable
)
{
...
...
@@ -152,7 +165,6 @@ static void embb_experiment_queue(bool is_linearizable)
std
::
ref
(
concurrent_log
),
std
::
ref
(
concurrent_queue
));
const
std
::
size_t
number_of_entries
{
concurrent_log
.
number_of_entries
()
};
const
LogInfo
<
state
::
Queue
<
N
>>
log_info
{
concurrent_log
.
info
()
};
// std::cout << log_info << std::endl;
auto
start
=
std
::
chrono
::
system_clock
::
now
();
auto
end
=
std
::
chrono
::
system_clock
::
now
();
...
...
@@ -177,7 +189,7 @@ static void embb_experiment_queue(bool is_linearizable)
int
main
()
{
// Test functions and structures in linearizability_tester.h
// Test functions and structures in linearizability_tester.h
and sequential_data_structures.h
run_tests
();
embb
::
base
::
Thread
::
SetThreadsMaxCount
(
255
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment