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
c5f8174b
authored
Feb 02, 2015
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed cpplint warnings
parent
49c254b4
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
36 additions
and
30 deletions
+36
-30
algorithms_cpp/include/embb/algorithms/invoke.h
+2
-1
base_c/include/embb/base/c/internal/platform.h
+1
-1
base_c/src/thread.c
+2
-1
base_cpp/include/embb/base/internal/platform.h
+1
-1
base_cpp/test/memory_allocation_test.cc
+6
-3
containers_cpp/test/main.cc
+3
-3
containers_cpp/test/queue_test-inl.h
+14
-13
containers_cpp/test/queue_test.h
+4
-3
mtapi_cpp/src/continuation.cc
+1
-3
mtapi_cpp/src/node.cc
+2
-1
No files found.
algorithms_cpp/include/embb/algorithms/invoke.h
View file @
c5f8174b
...
@@ -74,7 +74,8 @@ void Invoke(
...
@@ -74,7 +74,8 @@ void Invoke(
Function1
func1
,
Function1
func1
,
/**< [in] Function to invoke */
/**< [in] Function to invoke */
...,
...,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
/**< [in] ExecutionPolicy to use */
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
/**< [in] ExecutionPolicy to use */
);
);
#else // DOXYGEN
#else // DOXYGEN
...
...
base_c/include/embb/base/c/internal/platform.h
View file @
c5f8174b
...
@@ -71,7 +71,7 @@ typedef CONDITION_VARIABLE embb_condition_t;
...
@@ -71,7 +71,7 @@ typedef CONDITION_VARIABLE embb_condition_t;
#define EMBB_THREAD_SPECIFIC static __declspec(thread)
#define EMBB_THREAD_SPECIFIC static __declspec(thread)
#elif defined EMBB_PLATFORM_THREADING_POSIXTHREADS
/* EMBB_PLATFORM_THREADING_WINTHREADS */
#elif defined EMBB_PLATFORM_THREADING_POSIXTHREADS
#include <pthread.h>
#include <pthread.h>
#include <errno.h>
#include <errno.h>
...
...
base_c/src/thread.c
View file @
c5f8174b
...
@@ -207,7 +207,8 @@ int embb_thread_create(embb_thread_t* thread, const embb_core_set_t* core_set,
...
@@ -207,7 +207,8 @@ int embb_thread_create(embb_thread_t* thread, const embb_core_set_t* core_set,
int
status
=
pthread_attr_init
(
&
attr
);
int
status
=
pthread_attr_init
(
&
attr
);
if
(
status
!=
0
)
return
EMBB_ERROR
;
if
(
status
!=
0
)
return
EMBB_ERROR
;
if
(
core_set
!=
NULL
)
{
if
(
core_set
!=
NULL
)
{
#if defined(EMBB_PLATFORM_HAS_GLIB_CPU) || defined(EMBB_PLATFORM_HAS_HEADER_CPUSET)
#if defined(EMBB_PLATFORM_HAS_GLIB_CPU) || \
defined(EMBB_PLATFORM_HAS_HEADER_CPUSET)
assert
(
embb_core_count_available
()
<
CPU_SETSIZE
&&
assert
(
embb_core_count_available
()
<
CPU_SETSIZE
&&
"Core sets are only supported up to CPU_SETSIZE processors!"
);
"Core sets are only supported up to CPU_SETSIZE processors!"
);
#ifdef EMBB_PLATFORM_HAS_GLIB_CPU
#ifdef EMBB_PLATFORM_HAS_GLIB_CPU
...
...
base_cpp/include/embb/base/internal/platform.h
View file @
c5f8174b
...
@@ -49,7 +49,7 @@ typedef embb_condition_t ConditionVariableType;
...
@@ -49,7 +49,7 @@ typedef embb_condition_t ConditionVariableType;
}
// namespace base
}
// namespace base
}
// namespace embb
}
// namespace embb
#elif defined EMBB_PLATFORM_THREADING_POSIXTHREADS
// EMBB_PLATFORM_THREADING_WINTHREADS
#elif defined EMBB_PLATFORM_THREADING_POSIXTHREADS
namespace
embb
{
namespace
embb
{
namespace
base
{
namespace
base
{
...
...
base_cpp/test/memory_allocation_test.cc
View file @
c5f8174b
...
@@ -85,7 +85,8 @@ void MemoryAllocationTest::ClassAllocationTest() {
...
@@ -85,7 +85,8 @@ void MemoryAllocationTest::ClassAllocationTest() {
#ifdef EMBB_DEBUG
#ifdef EMBB_DEBUG
size_t
n
=
(
sizeof
(
DummyClassForAlignedAllocation
)
size_t
n
=
(
sizeof
(
DummyClassForAlignedAllocation
)
+
(
EMBB_PLATFORM_CACHE_LINE_SIZE
-
1
))
/
EMBB_PLATFORM_CACHE_LINE_SIZE
;
+
(
EMBB_PLATFORM_CACHE_LINE_SIZE
-
1
))
/
EMBB_PLATFORM_CACHE_LINE_SIZE
;
expected
+=
(
n
+
1
)
*
EMBB_PLATFORM_CACHE_LINE_SIZE
+
(
sizeof
(
size_t
)
*
3
-
1
);
expected
+=
(
n
+
1
)
*
EMBB_PLATFORM_CACHE_LINE_SIZE
+
(
sizeof
(
size_t
)
*
3
-
1
);
#endif // else EMBB_DEBUG
#endif // else EMBB_DEBUG
//check that the memory is aligned!
//check that the memory is aligned!
...
@@ -136,14 +137,16 @@ void MemoryAllocationTest::ClassAllocationTest() {
...
@@ -136,14 +137,16 @@ void MemoryAllocationTest::ClassAllocationTest() {
#ifdef EMBB_DEBUG
#ifdef EMBB_DEBUG
size_t
n
=
(
sizeof
(
DummyClassForAlignedAllocation
)
*
alloc_iterations
size_t
n
=
(
sizeof
(
DummyClassForAlignedAllocation
)
*
alloc_iterations
+
(
EMBB_PLATFORM_CACHE_LINE_SIZE
-
1
))
/
EMBB_PLATFORM_CACHE_LINE_SIZE
;
+
(
EMBB_PLATFORM_CACHE_LINE_SIZE
-
1
))
/
EMBB_PLATFORM_CACHE_LINE_SIZE
;
expected
+=
(
n
+
1
)
*
EMBB_PLATFORM_CACHE_LINE_SIZE
+
(
sizeof
(
size_t
)
*
3
-
1
);
expected
+=
(
n
+
1
)
*
EMBB_PLATFORM_CACHE_LINE_SIZE
+
(
sizeof
(
size_t
)
*
3
-
1
);
#endif // else EMBB_DEBUG
#endif // else EMBB_DEBUG
// This assert does _not_ hold, but is left for documentation.
// This assert does _not_ hold, but is left for documentation.
// It is not guaranteed that the pointer to the array is aligned.
// It is not guaranteed that the pointer to the array is aligned.
// See the documentation of the overloaded new[] operator in
// See the documentation of the overloaded new[] operator in
// class MemoryAllocation.
// class MemoryAllocation.
// PT_ASSERT_EQ((uintptr_t)aligned_allocated % EMBB_PLATFORM_CACHE_LINE_SIZE, 0);
// PT_ASSERT_EQ((uintptr_t)aligned_allocated %
// EMBB_PLATFORM_CACHE_LINE_SIZE, 0);
//delete!
//delete!
expected
=
0
;
expected
=
0
;
...
...
containers_cpp/test/main.cc
View file @
c5f8174b
...
@@ -55,11 +55,11 @@ PT_MAIN("Data Structures C++") {
...
@@ -55,11 +55,11 @@ PT_MAIN("Data Structures C++") {
PT_RUN
(
embb
::
containers
::
test
::
HazardPointerTest
);
PT_RUN
(
embb
::
containers
::
test
::
HazardPointerTest
);
PT_RUN
(
embb
::
containers
::
test
::
QueueTest
<
PT_RUN
(
embb
::
containers
::
test
::
QueueTest
<
embb
::
containers
::
WaitFreeSPSCQueue
<
::
std
::
pair
<
size_t
COMMA
int
>
>
>
);
embb
::
containers
::
WaitFreeSPSCQueue
<
::
std
::
pair
<
size_t
COMMA
int
>
>
>
);
PT_RUN
(
embb
::
containers
::
test
::
QueueTest
<
PT_RUN
(
embb
::
containers
::
test
::
QueueTest
<
embb
::
containers
::
LockFreeMPMCQueue
<
::
std
::
pair
<
size_t
COMMA
int
>
>
embb
::
containers
::
LockFreeMPMCQueue
<
::
std
::
pair
<
size_t
COMMA
int
>
>
COMMA
true
COMMA
true
>
);
COMMA
true
COMMA
true
>
);
PT_RUN
(
embb
::
containers
::
test
::
StackTest
<
PT_RUN
(
embb
::
containers
::
test
::
StackTest
<
...
...
containers_cpp/test/queue_test-inl.h
View file @
c5f8174b
...
@@ -45,7 +45,7 @@ QueueTest<Queue_t, MultipleProducers, MultipleConsumers>::QueueTest() :
...
@@ -45,7 +45,7 @@ QueueTest<Queue_t, MultipleProducers, MultipleConsumers>::QueueTest() :
next_producer_id
(
0
),
next_producer_id
(
0
),
next_consumer_id
(
0
),
next_consumer_id
(
0
),
n_producer_elements
(
n_producer_elements
(
static_cast
<
int
>
(
partest
::
TestSuite
::
GetDefaultNumIterations
()
*
static_cast
<
int
>
(
partest
::
TestSuite
::
GetDefaultNumIterations
()
*
MIN_ENQ_ELEMENTS
))
{
MIN_ENQ_ELEMENTS
))
{
CreateUnit
(
"QueueTestSingleThreadEnqueueDequeue"
).
CreateUnit
(
"QueueTestSingleThreadEnqueueDequeue"
).
Pre
(
&
QueueTest
::
QueueTestSingleThreadEnqueueDequeue_Pre
,
this
).
Pre
(
&
QueueTest
::
QueueTestSingleThreadEnqueueDequeue_Pre
,
this
).
...
@@ -105,10 +105,11 @@ template<typename Queue_t, bool MultipleProducers, bool MultipleConsumers>
...
@@ -105,10 +105,11 @@ template<typename Queue_t, bool MultipleProducers, bool MultipleConsumers>
void
QueueTest
<
Queue_t
,
MultipleProducers
,
MultipleConsumers
>::
void
QueueTest
<
Queue_t
,
MultipleProducers
,
MultipleConsumers
>::
QueueTestOrderMPMC_Post
()
{
QueueTestOrderMPMC_Post
()
{
delete
queue
;
delete
queue
;
// Tally for all elements enqueued by all producers,
// Tally for all elements enqueued by all producers,
// initialized with all 0:
// initialized with all 0:
::
std
::
vector
<
unsigned
char
>
total_tally
;
::
std
::
vector
<
unsigned
char
>
total_tally
;
size_t
n_elements_total
=
static_cast
<
size_t
>
(
n_producers
*
n_producer_elements
);
size_t
n_elements_total
=
static_cast
<
size_t
>
(
n_producers
*
n_producer_elements
);
for
(
size_t
i
=
0
;
i
<
n_elements_total
/
8
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
n_elements_total
/
8
;
++
i
)
{
total_tally
.
push_back
(
0
);
total_tally
.
push_back
(
0
);
}
}
...
@@ -118,10 +119,10 @@ QueueTestOrderMPMC_Post() {
...
@@ -118,10 +119,10 @@ QueueTestOrderMPMC_Post() {
total_tally
[
e
]
|=
consumers
[
c
].
Tally
()[
e
];
total_tally
[
e
]
|=
consumers
[
c
].
Tally
()[
e
];
}
}
}
}
// Test if all elements have been dequeued by any
// Test if all elements have been dequeued by any
// consumer.
// consumer.
// To avoid static cast warning:
// To avoid static cast warning:
for
(
size_t
t
=
0
;
for
(
size_t
t
=
0
;
t
<
static_cast
<
size_t
>
(
n_producers
*
n_producer_elements
/
8
);
t
<
static_cast
<
size_t
>
(
n_producers
*
n_producer_elements
/
8
);
++
t
)
{
++
t
)
{
PT_ASSERT_EQ_MSG
(
total_tally
[
t
],
0xff
,
PT_ASSERT_EQ_MSG
(
total_tally
[
t
],
0xff
,
...
@@ -146,13 +147,13 @@ QueueTestOrderMPMC_ConsumerThreadMethod() {
...
@@ -146,13 +147,13 @@ QueueTestOrderMPMC_ConsumerThreadMethod() {
template
<
typename
Queue_t
,
bool
MultipleProducers
,
bool
MultipleConsumers
>
template
<
typename
Queue_t
,
bool
MultipleProducers
,
bool
MultipleConsumers
>
void
QueueTest
<
Queue_t
,
MultipleProducers
,
MultipleConsumers
>::
Producer
::
void
QueueTest
<
Queue_t
,
MultipleProducers
,
MultipleConsumers
>::
Producer
::
Run
()
{
Run
()
{
// Enqueue pairs of (producer id, counter):
// Enqueue pairs of (producer id, counter):
for
(
int
i
=
0
;
i
<
n_producer_elements
;
++
i
)
{
for
(
int
i
=
0
;
i
<
n_producer_elements
;
++
i
)
{
while
(
!
q
->
TryEnqueue
(
element_t
(
producer_id
,
i
)))
{
while
(
!
q
->
TryEnqueue
(
element_t
(
producer_id
,
i
)))
{
embb
::
base
::
Thread
::
CurrentYield
();
embb
::
base
::
Thread
::
CurrentYield
();
}
}
}
}
// Enqueue -1 as terminator element of this producer:
// Enqueue -1 as terminator element of this producer:
while
(
!
q
->
TryEnqueue
(
element_t
(
producer_id
,
-
1
)))
{
while
(
!
q
->
TryEnqueue
(
element_t
(
producer_id
,
-
1
)))
{
embb
::
base
::
Thread
::
CurrentYield
();
embb
::
base
::
Thread
::
CurrentYield
();
}
}
...
@@ -161,14 +162,14 @@ Run() {
...
@@ -161,14 +162,14 @@ Run() {
template
<
typename
Queue_t
,
bool
MultipleProducers
,
bool
MultipleConsumers
>
template
<
typename
Queue_t
,
bool
MultipleProducers
,
bool
MultipleConsumers
>
QueueTest
<
Queue_t
,
MultipleProducers
,
MultipleConsumers
>::
Consumer
::
QueueTest
<
Queue_t
,
MultipleProducers
,
MultipleConsumers
>::
Consumer
::
Consumer
(
Queue_t
*
const
queue
,
int
numProducers
,
int
numProducerElements
)
:
Consumer
(
Queue_t
*
const
queue
,
int
numProducers
,
int
numProducerElements
)
:
q
(
queue
),
q
(
queue
),
n_producers
(
numProducers
),
n_producers
(
numProducers
),
n_producer_elements
(
numProducerElements
)
{
n_producer_elements
(
numProducerElements
)
{
for
(
int
p_id
=
0
;
p_id
<
n_producers
;
++
p_id
)
{
for
(
int
p_id
=
0
;
p_id
<
n_producers
;
++
p_id
)
{
// Initialize last value dequeued from producers with
// Initialize last value dequeued from producers with
// below-minimum value:
// below-minimum value:
sequence_number
.
push_back
(
-
1
);
sequence_number
.
push_back
(
-
1
);
// Initialize element tally for producer with all 0,
// Initialize element tally for producer with all 0,
// 8 flags / char:
// 8 flags / char:
for
(
int
i
=
0
;
i
<
n_producer_elements
/
8
;
++
i
)
{
for
(
int
i
=
0
;
i
<
n_producer_elements
/
8
;
++
i
)
{
consumer_tally
.
push_back
(
0
);
consumer_tally
.
push_back
(
0
);
...
@@ -193,9 +194,9 @@ Run() {
...
@@ -193,9 +194,9 @@ Run() {
producerId
=
element
.
first
;
producerId
=
element
.
first
;
// Assert on dequeued element:
// Assert on dequeued element:
PT_ASSERT_LT_MSG
(
producerId
,
static_cast
<
size_t
>
(
n_producers
),
PT_ASSERT_LT_MSG
(
producerId
,
static_cast
<
size_t
>
(
n_producers
),
"Invalid producer id in dequeue"
);
"Invalid producer id in dequeue"
);
PT_ASSERT_LT_MSG
(
sequence_number
[
producerId
],
element
.
second
,
PT_ASSERT_LT_MSG
(
sequence_number
[
producerId
],
element
.
second
,
"Invalid element sequence"
);
"Invalid element sequence"
);
// Store last value received from the element's producer:
// Store last value received from the element's producer:
sequence_number
[
producerId
]
=
element
.
second
;
sequence_number
[
producerId
]
=
element
.
second
;
const
size_t
pos
((
producerId
*
n_producer_elements
)
+
const
size_t
pos
((
producerId
*
n_producer_elements
)
+
...
...
containers_cpp/test/queue_test.h
View file @
c5f8174b
...
@@ -41,6 +41,7 @@ template<typename Queue_t,
...
@@ -41,6 +41,7 @@ template<typename Queue_t,
class
QueueTest
:
public
partest
::
TestCase
{
class
QueueTest
:
public
partest
::
TestCase
{
public
:
public
:
typedef
::
std
::
pair
<
size_t
,
int
>
element_t
;
typedef
::
std
::
pair
<
size_t
,
int
>
element_t
;
private
:
private
:
/// Minimum number of elements enqueued by every producer
/// Minimum number of elements enqueued by every producer
/// in MP/MC unit test. Must be a multiple of 8.
/// in MP/MC unit test. Must be a multiple of 8.
...
@@ -69,8 +70,8 @@ class QueueTest : public partest::TestCase {
...
@@ -69,8 +70,8 @@ class QueueTest : public partest::TestCase {
int
n_producer_elements
;
int
n_producer_elements
;
public
:
public
:
Producer
(
Queue_t
*
const
queue
,
size_t
id
,
int
numProducerElements
)
:
Producer
(
Queue_t
*
const
queue
,
size_t
id
,
int
numProducerElements
)
:
q
(
queue
),
q
(
queue
),
producer_id
(
id
),
producer_id
(
id
),
n_producer_elements
(
numProducerElements
)
{}
n_producer_elements
(
numProducerElements
)
{}
void
Run
();
void
Run
();
};
};
...
@@ -108,7 +109,7 @@ class QueueTest : public partest::TestCase {
...
@@ -108,7 +109,7 @@ class QueueTest : public partest::TestCase {
void
QueueTestSingleThreadEnqueueDequeue_Pre
();
void
QueueTestSingleThreadEnqueueDequeue_Pre
();
void
QueueTestSingleThreadEnqueueDequeue_Post
();
void
QueueTestSingleThreadEnqueueDequeue_Post
();
void
QueueTestSingleThreadEnqueueDequeue_ThreadMethod
();
void
QueueTestSingleThreadEnqueueDequeue_ThreadMethod
();
public
:
public
:
QueueTest
();
QueueTest
();
};
};
...
...
mtapi_cpp/src/continuation.cc
View file @
c5f8174b
...
@@ -87,9 +87,7 @@ Task Continuation::Spawn(ExecutionPolicy execution_policy) {
...
@@ -87,9 +87,7 @@ Task Continuation::Spawn(ExecutionPolicy execution_policy) {
return
node
.
Spawn
(
return
node
.
Spawn
(
Action
(
Action
(
embb
::
base
::
MakeFunction
(
*
this
,
&
Continuation
::
ExecuteContinuation
),
embb
::
base
::
MakeFunction
(
*
this
,
&
Continuation
::
ExecuteContinuation
),
ExecutionPolicy
(
execution_policy
)
ExecutionPolicy
(
execution_policy
)));
)
);
}
}
}
// namespace mtapi
}
// namespace mtapi
...
...
mtapi_cpp/src/node.cc
View file @
c5f8174b
...
@@ -152,7 +152,8 @@ void Node::Initialize(
...
@@ -152,7 +152,8 @@ void Node::Initialize(
assert
(
MTAPI_SUCCESS
==
status
);
assert
(
MTAPI_SUCCESS
==
status
);
embb_core_set_t
cs
;
embb_core_set_t
cs
;
embb_core_set_init
(
&
cs
,
0
);
embb_core_set_init
(
&
cs
,
0
);
for
(
unsigned
int
ii
=
0
;
embb_core_set_count
(
&
cs
)
<
core_set
.
Count
();
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
embb_core_set_count
(
&
cs
)
<
core_set
.
Count
();
ii
++
)
{
if
(
core_set
.
IsContained
(
ii
))
{
if
(
core_set
.
IsContained
(
ii
))
{
embb_core_set_add
(
&
cs
,
ii
);
embb_core_set_add
(
&
cs
,
ii
);
}
}
...
...
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