Skip to content

Commit

Permalink
Add proof.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Nov 20, 2024
1 parent 4eb241b commit b9fa5c8
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions cost-models.tex
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,38 @@ \chapter{Cost Models}
Writing $T_{i}$ for the time taken to execute a program on $i$
processors,
\[
\frac{T_{1}}{p} \leq T_{p} \leq T_{\infty} + \frac{T_{1}-T_{\infty}}{p}
\frac{T_{1}}{p} \leq T_{p} \leq T_{\infty} + \frac{T_{1}}{p}
\]
where $p$ is the number of available processors.

% \begin{proof}
% At level $j$ of the computation DAG there are $M_{j}$ independent
% operations, which can clearly be executed by $p$ processors in
% time
% \[
% \Bigl\lceil{\frac{M_{j}}{p}}\Bigr\rceil
% \]
% Now we have
% \begin{align*}
% \frac{T_{1}}{p} &= \frac{\sum _{j} {M_{j}}}{p} & \text{(By definition)} \\
% & \leq \sum _{j} \Bigl\lceil{\frac{M_{j}}{p}}\Bigr\rceil \\
% & \leq \sum _{j} \Bigl\lceil{M_{j}}\Bigr\rceil
% \end{align*}
% \end{proof}
\begin{proof}
Suppose that the computation DAG has $n$ levels, and at level $j$
of the computation DAG there are $M_{j}$ independent operations.
Then the total work of our program, and the time taken on a single
processor, is
\[
T_{1} = \sum_{i=1}^{n}M_{i}.
\]
In the case where we have an infinite number of processors, each of
the $M_{j}$ independent operations can be executed in a single step, so we also have
\[
T_{\infty} = n
\]
because each level can be executed in one step. For the case where we
have $p$ processors, we denote the time taken to execute level $i$
of the DAG by $T_{p}^{i}$, where
\[
T_{i}^{p} = \Bigl\lceil{\frac{M_{i}}{p}}\Bigr\rceil \leq
\frac{M_{i}}{p}+1.
\]
The intuition behind the inequality is that if we need to execute
$k$ independent nodes and we have $p$ processors, then we can
perform $\lceil \frac{k}{n} \rceil$ sequential iterations, with each
chunk executing (up to) $p$ nodes in parallel. Finally,
\[
T_{p} = \sum_{i=1}^{n}T_{i}^{p} \leq \sum_{i=1}^{n}\Bigl(\frac{M_{i}}{p}+1\Bigr) = \frac{T_{1}}{p} + T_{\infty}
\]
\end{proof}

\end{theorem}

Expand Down

0 comments on commit b9fa5c8

Please sign in to comment.