diff options
Diffstat (limited to 'thesis/parts/design.tex')
-rw-r--r-- | thesis/parts/design.tex | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/thesis/parts/design.tex b/thesis/parts/design.tex index 796549e..ab9cbf0 100644 --- a/thesis/parts/design.tex +++ b/thesis/parts/design.tex @@ -1,9 +1,4 @@ -We now outline the design of our container selection system (Candelabra), and justify our design decisions. - -We first restate our aims and priorities for the system, illustrating its usage with an example. -We then provide an overview of the container selection process, and each part in it. - -We leave detailed discussion of implementation for chapter \ref{chap:implementation}. +We now outline the design of our container selection system (Candelabra), and justify our design decisions. We first restate our aims and priorities for the system, illustrating its usage with an example. We then provide an overview of the container selection process, and each part in it, although we leave detailed discussion of implementation for chapter \ref{chap:implementation}. \section{Aims \& Usage} @@ -54,7 +49,7 @@ Here, the code generated uses \code{Vec} as the implementation for \code{Sieve}, \begin{table}[h] \centering \begin{tabular}{|c|c|c|c|} - & Container Type & Implementation & Estimated cost \\ + Best performing & Container Type & Implementation & Estimated cost \\ \hline * & Sieve & LinkedList & 14179471355 \\ & Sieve & Vec & 26151238698 \\ @@ -97,7 +92,7 @@ Primrose allows users to specify both the traits they require (syntactic propert Each container type that we want to select an implementation for is bound by a list of traits and a list of properties (lines 11 and 12 in Listing \ref{lst:selection_example}). %% Short explanation of selection method -In brief, primrose works by: +In brief, Primrose works by: \begin{itemize} \item Finding all implementations in the container library that implement all required traits @@ -125,7 +120,7 @@ After this stage, we have a list of implementations for each container type we a \end{table} %% Abstraction over backend -Although we use primrose in our implementation, the rest of our system isn't dependent on it, and it would be relatively simple to use a different approach for selecting based on functional requirements. +Although we use Primrose in our implementation, the rest of our system isn't dependent on it, and it would be relatively simple to use a different approach for selecting based on functional requirements. \section{Cost Models} @@ -173,19 +168,25 @@ We then aggregate all results for a single container type into a list of partiti Each partition simply stores an average value for each component of our results (maximum size and a count for each operation), along with a weight indicating how many results fell into that partition. -Results are processed as follows: - -\begin{itemize} -\item We start with an empty list of partitions. -\item For each result, if there is a partition with an average max n value within 100 of that result's maximum n, add the result to that partition: - \begin{itemize} - \item Adjust the partition's average maximum n according to the new result - \item Adjust the partitions' average count of each operation according to the counts in the new result - \item Add 1 to the weight of the partition. - \end{itemize} -\item If there is no such partition, create a new one with the values from the result, and with weight 1. -\item Once all results have been processed, normalize the partition weights by dividing each by the sum of all weights. -\end{itemize} +Results are processed as in algorithm \ref{alg:results}. + +\begin{algorithm} + \caption{Results processing algorithm} + \label{alg:results} + \begin{algorithmic}[1] + \State Start with an empty list of partitions + \For{result in results} + \If{there is a partition with an average max n value within 100 of result's maximum n} + \State Adjust the partition's average maximum n according to the new result + \State Adjust the partitions' average count of each operation according to the counts in the new result + \State Add 1 to the weight of the partition. + \Else + Add a new partition with the values from the result, and with weight 1. + \EndIf + \EndFor + \State Once all results have been processed, normalize the partition weights by dividing each by the sum of all weights. + \end{algorithmic} +\end{algorithm} The use of partitions serves 3 purposes. The first is to compress the data, which speeds up processing and stops us running out of memory in more complex programs. @@ -200,8 +201,7 @@ We now combine these to estimate the total cost of each implementation. For each implementation, our estimate for its total cost is: $$ -\sum_{o\in \mathit{ops}, (r_{o}, N, W) \in \mathit{partitions}} C_o(N) * r_o -* W +\sum_{o\in \mathit{ops}, (r_{o}, N, W) \in \mathit{partitions}} C_o(N) r_o W $$ \begin{itemize} |