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
1f48dc23
authored
Mar 15, 2016
by
lucapegolotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable assertions in Release mode and improve function consistency in main.cc
parent
659eeed1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
21 deletions
+24
-21
linearizability_tester/main.cc
+24
-19
linearizability_tester/src/sequential_data_structures.h
+0
-1
linearizability_tester/src/tests.h
+0
-1
No files found.
linearizability_tester/main.cc
View file @
1f48dc23
...
@@ -2,6 +2,12 @@
...
@@ -2,6 +2,12 @@
* Main script that applies the linearizability tester on embb data structures.
* Main script that applies the linearizability tester on embb data structures.
*/
*/
// Enable assertions even in Release mode
#ifdef NDEBUG
#undef NDEBUG
#include <assert.h>
#endif
#include <linearizability_tester.h>
#include <linearizability_tester.h>
#include <sequential_data_structures.h>
#include <sequential_data_structures.h>
#include <tests.h>
#include <tests.h>
...
@@ -51,7 +57,7 @@ static void embb_worker_stack(
...
@@ -51,7 +57,7 @@ static void embb_worker_stack(
}
}
}
}
// Each thread executes quasi randomly operations (TryE
qneueu
, TryDequeue)
// Each thread executes quasi randomly operations (TryE
nqueue
, TryDequeue)
// on the concurrent data structure and construct the history.
// on the concurrent data structure and construct the history.
template
<
std
::
size_t
N
,
class
S
>
template
<
std
::
size_t
N
,
class
S
>
static
void
embb_worker_queue
(
static
void
embb_worker_queue
(
...
@@ -94,7 +100,7 @@ static void embb_worker_queue(
...
@@ -94,7 +100,7 @@ static void embb_worker_queue(
// Creates the history and apply the tester on it
// Creates the history and apply the tester on it
template
<
class
S
>
template
<
class
S
>
static
void
embb_experiment_stack
(
bool
is_linearizable
)
static
void
embb_experiment_stack
()
{
{
constexpr
std
::
chrono
::
hours
max_duration
{
1
};
constexpr
std
::
chrono
::
hours
max_duration
{
1
};
constexpr
std
::
size_t
N
=
560000U
;
constexpr
std
::
size_t
N
=
560000U
;
...
@@ -106,12 +112,11 @@ static void embb_experiment_stack(bool is_linearizable)
...
@@ -106,12 +112,11 @@ static void embb_experiment_stack(bool is_linearizable)
ConcurrentLog
<
state
::
Stack
<
N
>>
concurrent_log
{
2U
*
log_size
};
ConcurrentLog
<
state
::
Stack
<
N
>>
concurrent_log
{
2U
*
log_size
};
S
concurrent_stack
(
N
);
S
concurrent_stack
(
N
);
if
(
!
is_linearizable
)
// Check if push and pop operations are possible
{
char
value
;
bool
ok
=
concurrent_stack
.
TryPush
(
5
);
assert
(
concurrent_stack
.
TryPush
(
5
));
assert
(
ok
);
assert
(
concurrent_stack
.
TryPop
(
value
));
}
// create history
// create history
start_threads
(
number_of_threads
,
embb_worker_stack
<
N
,
S
>
,
std
::
cref
(
worker_configuration
),
start_threads
(
number_of_threads
,
embb_worker_stack
<
N
,
S
>
,
std
::
cref
(
worker_configuration
),
std
::
ref
(
concurrent_log
),
std
::
ref
(
concurrent_stack
));
std
::
ref
(
concurrent_log
),
std
::
ref
(
concurrent_stack
));
...
@@ -130,7 +135,8 @@ static void embb_experiment_stack(bool is_linearizable)
...
@@ -130,7 +135,8 @@ static void embb_experiment_stack(bool is_linearizable)
LinearizabilityTester
<
state
::
Stack
<
N
>
,
Option
::
LRU_CACHE
>
tester
{
log_copy
.
info
(),
max_duration
};
LinearizabilityTester
<
state
::
Stack
<
N
>
,
Option
::
LRU_CACHE
>
tester
{
log_copy
.
info
(),
max_duration
};
tester
.
check
(
result
);
tester
.
check
(
result
);
assert
(
result
.
is_timeout
()
||
result
.
is_linearizable
()
==
is_linearizable
);
// If structure is not linearizabile break run using assertion
assert
(
result
.
is_timeout
()
||
result
.
is_linearizable
());
}
}
end
=
std
::
chrono
::
system_clock
::
now
();
end
=
std
::
chrono
::
system_clock
::
now
();
seconds
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
end
-
start
);
seconds
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
end
-
start
);
...
@@ -141,7 +147,7 @@ static void embb_experiment_stack(bool is_linearizable)
...
@@ -141,7 +147,7 @@ static void embb_experiment_stack(bool is_linearizable)
// Creates the history and apply the tester on it
// Creates the history and apply the tester on it
template
<
class
S
>
template
<
class
S
>
static
void
embb_experiment_queue
(
bool
is_linearizable
)
static
void
embb_experiment_queue
()
{
{
constexpr
std
::
chrono
::
hours
max_duration
{
1
};
constexpr
std
::
chrono
::
hours
max_duration
{
1
};
constexpr
std
::
size_t
N
=
560000U
;
constexpr
std
::
size_t
N
=
560000U
;
...
@@ -154,11 +160,10 @@ static void embb_experiment_queue(bool is_linearizable)
...
@@ -154,11 +160,10 @@ static void embb_experiment_queue(bool is_linearizable)
ConcurrentLog
<
state
::
Queue
<
N
>>
concurrent_log
{
2U
*
log_size
};
ConcurrentLog
<
state
::
Queue
<
N
>>
concurrent_log
{
2U
*
log_size
};
S
concurrent_queue
(
N
);
S
concurrent_queue
(
N
);
if
(
!
is_linearizable
)
// check if enqueue and dequeue operations are possible
{
char
value
;
bool
ok
=
concurrent_queue
.
TryEnqueue
(
5
);
assert
(
concurrent_queue
.
TryEnqueue
(
5
));
assert
(
ok
);
assert
(
concurrent_queue
.
TryDequeue
(
value
));
}
// create history
// create history
start_threads
(
number_of_threads
,
embb_worker_queue
<
N
,
S
>
,
std
::
cref
(
worker_configuration
),
start_threads
(
number_of_threads
,
embb_worker_queue
<
N
,
S
>
,
std
::
cref
(
worker_configuration
),
...
@@ -176,7 +181,8 @@ static void embb_experiment_queue(bool is_linearizable)
...
@@ -176,7 +181,8 @@ static void embb_experiment_queue(bool is_linearizable)
assert
(
log_copy
.
number_of_entries
()
==
number_of_entries
);
assert
(
log_copy
.
number_of_entries
()
==
number_of_entries
);
LinearizabilityTester
<
state
::
Queue
<
N
>
,
Option
::
LRU_CACHE
>
tester
{
log_copy
.
info
(),
max_duration
};
LinearizabilityTester
<
state
::
Queue
<
N
>
,
Option
::
LRU_CACHE
>
tester
{
log_copy
.
info
(),
max_duration
};
tester
.
check
(
result
);
tester
.
check
(
result
);
assert
(
result
.
is_timeout
()
||
result
.
is_linearizable
()
==
is_linearizable
);
// If structure is not linearizabile break run using assertion
assert
(
result
.
is_timeout
()
||
result
.
is_linearizable
());
}
}
end
=
std
::
chrono
::
system_clock
::
now
();
end
=
std
::
chrono
::
system_clock
::
now
();
seconds
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
end
-
start
);
seconds
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
end
-
start
);
...
@@ -191,14 +197,13 @@ int main()
...
@@ -191,14 +197,13 @@ int main()
// Test functions and structures in linearizability_tester.h and sequential_data_structures.h
// Test functions and structures in linearizability_tester.h and sequential_data_structures.h
run_tests
();
run_tests
();
embb
::
base
::
Thread
::
SetThreadsMaxCount
(
255
);
embb
::
base
::
Thread
::
SetThreadsMaxCount
(
255
);
std
::
cout
<<
"Linearizability test on LockFreeMPMCQueue"
<<
std
::
endl
;
std
::
cout
<<
"Linearizability test on LockFreeMPMCQueue"
<<
std
::
endl
;
embb_experiment_queue
<
embb
::
containers
::
LockFreeMPMCQueue
<
char
>>
(
true
);
embb_experiment_queue
<
embb
::
containers
::
LockFreeMPMCQueue
<
char
>>
();
std
::
cout
<<
"Linearizability test on LockFreeStack"
<<
std
::
endl
;
std
::
cout
<<
"Linearizability test on LockFreeStack"
<<
std
::
endl
;
embb_experiment_stack
<
embb
::
containers
::
LockFreeStack
<
char
>>
(
true
);
embb_experiment_stack
<
embb
::
containers
::
LockFreeStack
<
char
>>
();
return
0
;
return
0
;
}
}
linearizability_tester/src/sequential_data_structures.h
View file @
1f48dc23
...
@@ -314,7 +314,6 @@ class Stack
...
@@ -314,7 +314,6 @@ class Stack
if
(
m_vector
.
size
()
<
value
+
1U
)
if
(
m_vector
.
size
()
<
value
+
1U
)
m_vector
.
resize
(
value
+
1U
);
m_vector
.
resize
(
value
+
1U
);
assert
(
value
<
m_vector
.
size
());
NodePtr
&
node_ptr
=
m_vector
[
value
];
NodePtr
&
node_ptr
=
m_vector
[
value
];
if
(
node_ptr
==
nullptr
)
if
(
node_ptr
==
nullptr
)
...
...
linearizability_tester/src/tests.h
View file @
1f48dc23
...
@@ -2039,7 +2039,6 @@ void run_tests(){
...
@@ -2039,7 +2039,6 @@ void run_tests(){
test_state_set_op
();
test_state_set_op
();
test_state_stack
();
test_state_stack
();
test_state_stack_op
();
test_state_stack_op
();
test_state_queue
();
test_state_queue
();
test_state_queue_op
();
test_state_queue_op
();
...
...
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