From 84b41395a853d43427494bd4d646690a7f5bdc17 Mon Sep 17 00:00:00 2001 From: Marcus Winter Date: Mon, 22 Feb 2016 16:32:52 +0100 Subject: [PATCH] examples, tutorial: adapted for new behavior of dataflow --- doc/examples/dataflow/dataflow_make-snippet.h | 2 +- doc/examples/dataflow/dataflow_nonlinear-fragmented.cc | 2 +- doc/tutorial/content/dataflow.tex | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/examples/dataflow/dataflow_make-snippet.h b/doc/examples/dataflow/dataflow_make-snippet.h index c132ce0..19f9aab 100644 --- a/doc/examples/dataflow/dataflow_make-snippet.h +++ b/doc/examples/dataflow/dataflow_make-snippet.h @@ -1 +1 @@ - nw.Make(2); + nw.Make(4); diff --git a/doc/examples/dataflow/dataflow_nonlinear-fragmented.cc b/doc/examples/dataflow/dataflow_nonlinear-fragmented.cc index 206c54e..4b67009 100644 --- a/doc/examples/dataflow/dataflow_nonlinear-fragmented.cc +++ b/doc/examples/dataflow/dataflow_nonlinear-fragmented.cc @@ -83,6 +83,6 @@ void RunDataflowNonLinear() { process5.GetOutput<1>() >> sink1.GetInput<2>(); process4.GetOutput<1>() >> sink1.GetInput<3>(); - nw.Make(2); + nw.Make(4); nw(); } diff --git a/doc/tutorial/content/dataflow.tex b/doc/tutorial/content/dataflow.tex index e7a07a1..6aba46d 100644 --- a/doc/tutorial/content/dataflow.tex +++ b/doc/tutorial/content/dataflow.tex @@ -104,7 +104,7 @@ This pipeline can be easily implemented using the Dataflow building block. As th % Then, we have to construct a \emph{network}. A network consists of a set of processes that are connected by communication channels. %\footnote{Pipelines belong to the most simple networks, where the processes are connected in string-like (linear) fashion.} -\embb provides a class template \lstinline|Network| that can be customized to your needs. For the moment, we are using 2 as a template argument: +\embb provides a class \lstinline|Network| that handles data routing and scheduling of your processes: % \\\inputlisting{../examples/dataflow/dataflow_network-snippet.h} % @@ -151,11 +151,14 @@ As the last step, we have to connect the processes (ports). This is straightforw % \\\inputlisting{../examples/dataflow/dataflow_connect-snippet.h} % -Once all connections have been established, we can start the network: +Once all connections have been established, we need to prepare the network for the desired maximum number of elements that can be in the network at a time. The number of elements is limited to avoid that the network is flooded with new elements before the previous elements have been processed. In a linear pipeline, for example, this may happen if the source is faster than the sink. In our example, at most four elements may be processed simultaneously: one in the source, one in the sink, and two in the middle stage (see above). Finding an optimal value depends on the application and usually requires some experimentation. In general, large values boost the throughput but also increase the latency. Conversely, small values reduce the latency but may lead to a drop of performance in terms of throughput: +% +\\\inputlisting{../examples/dataflow/dataflow_make-snippet.h} +% +Then we can start the network: % \\\inputlisting{../examples/dataflow/dataflow_run-snippet.h} % -The integer given as a template parameter to the network specifies the maximum number of elements that can be in the network at a time. The number of elements is limited to avoid that the network is flooded with new elements before the previous elements have been processed. In a linear pipeline, for example, this may happen if the source is faster than the sink. In our example, at most four elements may be processed simultaneously: one in the source, one in the sink, and two in the middle stage (see above). Finding an optimal value depends on the application and usually requires some experimentation. In general, large values boost the throughput but also increase the latency. Conversely, small values reduce the latency but may lead to a drop of performance in terms of throughput. Note that you will probably not observe a speedup when you run this program on a multicore processor. One reason for this is that input$/$output operations like reading a file from the hard disk and writing the output to the screen are typically a bottleneck. Moreover, the amount of work done in the middle stage of the pipeline (\textbf{replace}) is rather low. To outweigh the overhead for parallel execution, the amount of work must be much higher. In image processing, for example, a single pipeline stage may process a complete image. To sum up, we haven chosen this example for its simplicity, not for its efficiency. -- libgit2 0.26.0