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
172d4ed3
authored
Jan 26, 2015
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dataflow_cpp: fixed bug causing the network to hang
parent
e6fe323c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
31 deletions
+32
-31
dataflow_cpp/include/embb/dataflow/internal/process.h
+18
-12
dataflow_cpp/include/embb/dataflow/internal/sink.h
+12
-14
dataflow_cpp/include/embb/dataflow/internal/source.h
+1
-4
dataflow_cpp/test/dataflow_cpp_test_simple.cc
+1
-1
No files found.
dataflow_cpp/include/embb/dataflow/internal/process.h
View file @
172d4ed3
...
...
@@ -55,7 +55,7 @@ class Process< Slices, Serial, Inputs<Slices, I1, I2, I3, I4, I5>,
explicit
Process
(
FunctionType
function
)
:
executor_
(
function
)
{
input_clock_expected
_
=
0
;
next_clock
_
=
0
;
inputs_
.
SetListener
(
this
);
}
...
...
@@ -68,16 +68,7 @@ class Process< Slices, Serial, Inputs<Slices, I1, I2, I3, I4, I5>,
}
virtual
void
Run
(
int
clock
)
{
bool
ordered
=
Serial
;
if
(
ordered
)
{
// force ordering
while
(
input_clock_expected_
!=
clock
)
embb
::
base
::
Thread
::
CurrentYield
();
}
executor_
.
Execute
(
clock
,
inputs_
,
outputs_
);
//inputs_.Clear(clock);
input_clock_expected_
=
clock
+
1
;
}
InputsType
&
GetInputs
()
{
...
...
@@ -104,20 +95,35 @@ class Process< Slices, Serial, Inputs<Slices, I1, I2, I3, I4, I5>,
}
virtual
void
OnClock
(
int
clock
)
{
const
int
idx
=
clock
%
Slices
;
if
(
!
inputs_
.
AreAtClock
(
clock
))
EMBB_THROW
(
embb
::
base
::
ErrorException
,
"Some inputs are not at expected clock."
)
bool
ordered
=
Serial
;
if
(
ordered
)
{
lock_
.
Lock
();
for
(
int
ii
=
next_clock_
;
ii
<
next_clock_
+
Slices
;
ii
++
)
{
if
(
!
inputs_
.
AreAtClock
(
ii
))
{
break
;
}
next_clock_
=
ii
+
1
;
Run
(
ii
);
}
lock_
.
Unlock
();
}
else
{
const
int
idx
=
clock
%
Slices
;
action_
[
idx
]
=
Action
(
this
,
clock
);
sched_
->
Spawn
(
action_
[
idx
]);
}
}
private
:
InputsType
inputs_
;
OutputsType
outputs_
;
ExecutorType
executor_
;
embb
::
base
::
Atomic
<
int
>
input_clock_expected
_
;
int
next_clock
_
;
Action
action_
[
Slices
];
SpinLock
lock_
;
};
}
// namespace internal
...
...
dataflow_cpp/include/embb/dataflow/internal/sink.h
View file @
172d4ed3
...
...
@@ -51,7 +51,7 @@ class Sink< Slices, Inputs<Slices, I1, I2, I3, I4, I5> >
explicit
Sink
(
FunctionType
function
)
:
executor_
(
function
)
{
input_clock_expected
_
=
0
;
next_clock
_
=
0
;
inputs_
.
SetListener
(
this
);
}
...
...
@@ -64,17 +64,10 @@ class Sink< Slices, Inputs<Slices, I1, I2, I3, I4, I5> >
}
virtual
void
Run
(
int
clock
)
{
//const int idx = clock % Slices;
// force ordering
while
(
input_clock_expected_
!=
clock
)
embb
::
base
::
Thread
::
CurrentYield
();
if
(
inputs_
.
AreNoneBlank
(
clock
))
{
executor_
.
Execute
(
clock
,
inputs_
);
}
listener_
->
OnClock
(
clock
);
input_clock_expected_
=
clock
+
1
;
}
InputsType
&
GetInputs
()
{
...
...
@@ -87,26 +80,31 @@ class Sink< Slices, Inputs<Slices, I1, I2, I3, I4, I5> >
}
virtual
void
OnClock
(
int
clock
)
{
lock_
.
Lock
();
TrySpawn
(
clock
);
lock_
.
Unlock
();
}
private
:
InputsType
inputs_
;
ExecutorType
executor_
;
embb
::
base
::
Atomic
<
int
>
input_clock_expected
_
;
int
next_clock
_
;
Action
action_
[
Slices
];
ClockListener
*
listener_
;
SpinLock
lock_
;
void
TrySpawn
(
int
clock
)
{
const
int
idx
=
clock
%
Slices
;
if
(
!
inputs_
.
AreAtClock
(
clock
))
EMBB_THROW
(
embb
::
base
::
ErrorException
,
"Some inputs are not at expected clock."
)
action_
[
idx
]
=
Action
(
this
,
clock
);
sched_
->
Spawn
(
action_
[
idx
]);
lock_
.
Lock
();
for
(
int
ii
=
next_clock_
;
ii
<
next_clock_
+
Slices
;
ii
++
)
{
if
(
!
inputs_
.
AreAtClock
(
ii
))
{
break
;
}
next_clock_
=
ii
+
1
;
Run
(
ii
);
}
lock_
.
Unlock
();
}
};
...
...
dataflow_cpp/include/embb/dataflow/internal/source.h
View file @
172d4ed3
...
...
@@ -66,11 +66,8 @@ class Source< Slices, Outputs<Slices, O1, O2, O3, O4, O5> >
}
virtual
bool
Start
(
int
clock
)
{
while
(
clock
!=
next_clock_
)
embb
::
base
::
Thread
::
CurrentYield
();
if
(
not_done_
)
{
const
int
idx
=
clock
%
Slices
;
action_
[
idx
]
=
Action
(
this
,
clock
);
sched_
->
Spawn
(
action_
[
idx
]);
Run
(
clock
);
}
return
not_done_
;
}
...
...
dataflow_cpp/test/dataflow_cpp_test_simple.cc
View file @
172d4ed3
...
...
@@ -36,7 +36,7 @@
#include <embb/dataflow/dataflow.h>
typedef
embb
::
dataflow
::
Network
<
4
>
MyNetwork
;
typedef
embb
::
dataflow
::
Network
<
8
>
MyNetwork
;
typedef
MyNetwork
::
ConstantSource
<
int
>
MyConstantSource
;
typedef
MyNetwork
::
Source
<
int
>
MySource
;
typedef
MyNetwork
::
SerialProcess
<
MyNetwork
::
Inputs
<
int
>::
Type
,
...
...
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