77 lines
2.3 KiB
TeX
77 lines
2.3 KiB
TeX
\begin{tikzpicture}
|
|
\input{src/tikz/orchestration}
|
|
|
|
% \def\N{15}
|
|
% \def\T{6}
|
|
|
|
\pgfmathtruncatemacro{\nlasttask}{\N-1}
|
|
\pgfmathtruncatemacro{\nlastthread}{\T-1}
|
|
\pgfmathtruncatemacro{\R}{mod(\N, \T)}
|
|
|
|
\begin{scope}[overlay]
|
|
\node(origin){};
|
|
\node at (origin) (t-\T) {};
|
|
\end{scope}
|
|
|
|
\begin{scope}[node distance=4mm and 4mm]
|
|
\foreach \task in {0,...,\nlasttask} {
|
|
\pgfmathtruncatemacro{\r}{mod(\task, \T)}
|
|
\ifthenelse{\r = 0}{
|
|
\pgfmathtruncatemacro{\uppertask}{\T*(\task/\T-1)}
|
|
\def\reltype{below}
|
|
\def\relnode{t\uppertask}
|
|
}{
|
|
\pgfmathtruncatemacro{\prevtask}{\task-1}
|
|
\def\reltype{right}
|
|
\def\relnode{t\prevtask}
|
|
}
|
|
\node[orch/task=black,\reltype=of \relnode] (t\task) {};
|
|
|
|
\draw[-] (t\task.north)
|
|
-- node[pos=.3,orch/subtask=black] {}
|
|
node[pos=.7,orch/subtask=black] {}
|
|
(t\task.south);
|
|
}
|
|
|
|
\ifthenelse{\R = 0}{}{
|
|
\pgfmathtruncatemacro{\ntaskfill}{mod(\T-\R, \T)-1}
|
|
\foreach \taskfill in {0,...,\ntaskfill} {
|
|
\pgfmathtruncatemacro{\task}{\nlasttask+\taskfill+1}
|
|
\pgfmathtruncatemacro{\prevtask}{\task-1}
|
|
\node[orch/task=white,draw=none,fill=none,right=of t\prevtask] (t\task) {};
|
|
\draw[-] (t\task.north) -- (t\task.south);
|
|
}
|
|
}
|
|
|
|
\foreach \thread in {0,...,\nlastthread} {
|
|
\node[above=of t\thread] (label\thread) {\en{thread}~\thread};
|
|
\draw[-] (label\thread) -- (t\thread);
|
|
|
|
\pgfmathtruncatemacro{\n}{floor((\N-1)/\T)-1}
|
|
\ifthenelse{\n = -1}{}{% only if N>T
|
|
\foreach \task in {0,...,\n} {
|
|
\pgfmathtruncatemacro{\curtask}{\thread+\task*\T}
|
|
\pgfmathtruncatemacro{\nexttask}{\curtask+\T}
|
|
\draw[-] (t\curtask) -- (t\nexttask);
|
|
}
|
|
}
|
|
|
|
\pgfmathtruncatemacro{\lasttask}{\thread+(\n+1)*\T}
|
|
\node[below=of t\lasttask] (endthread\thread) {};
|
|
\draw[-] (t\lasttask) -- (endthread\thread);
|
|
}
|
|
\end{scope}
|
|
|
|
\begin{scope}[common/overlay]
|
|
\pgfmathtruncatemacro{\n}{2*ceil(\N/\T)}
|
|
\pgfmathtruncatemacro{\nr}{(\N-1)/\T}
|
|
\pgfmathtruncatemacro{\ftlt}{\nr*\T}
|
|
|
|
\draw[decorate,decoration={brace, amplitude=4pt, raise=9mm, mirror}]
|
|
(t0.north) -- (t0.south) node[left,midway,xshift=-11mm] {$2\,T$};
|
|
|
|
\draw[decorate,decoration={brace, amplitude=4pt, raise=18mm, mirror}]
|
|
(t0.north) -- (t\ftlt.south) node[left,midway,xshift=-20mm] {$\n\,T$};
|
|
\end{scope}
|
|
\end{tikzpicture}
|