# Changeset 4782 for docs/Working/icGrep/architecture.tex

Ignore:
Timestamp:
Sep 21, 2015, 12:42:53 PM (4 years ago)
Message:

Figure placement according to Springer

File:
1 edited

### Legend:

Unmodified
 r4501 \section{Architecture}\label{sec:architecture} \paragraph{Regular Expression Preprocessing.} As shown in Fig.~\ref{fig:compiler}, compilation in \icGrep{} comprises three logical layers: \RegularExpression{}, \Pablo{} and the LLVM layer, each with their own intermediate representation (IR), transformation and compilation modules. As we traverse the layers, the IR becomes more complex as it begins to mirror the final machine code. The layering enables further optimization based on information available at each stage. The \REParser{} validates and transforms the input \RegularExpression{} into an abstract syntax tree (AST). Successive \RegularExpression{} Transformations exploit domain knowledge to optimize the regular expressions. The aforementioned \texttt{toUTF8} transformation also applies during this phase to generate code unit classes. \input{fig-compiler} As shown in Figure \ref{fig:compiler}, compilation in \icGrep{} comprises three logical layers: \RegularExpression{}, \Pablo{} and the LLVM layer, each with their own intermediate representation (IR), transformation and compilation modules. % As we traverse the layers, the IR becomes more complex as it begins to mirror the final machine code. % The layering enables further optimization based on information available at each stage. % The \REParser{} validates and transforms the input \RegularExpression{} into an abstract syntax tree (AST). % %The AST is a minimalistic representation that, unlike traditional \RegularExpression{}, is not converted into a NFA or DFA for further processing. % %Instead, \icGrep{} passes the AST into the transformation module, which includes a set of \RegularExpression{} specific optimization passes. % Successive \RegularExpression{} Transformations exploit domain knowledge to optimize the regular expressions. % %An initial \emph{Nullable} pass, determines whether the \RegularExpression{} %contains prefixes or suffixes that may be removed or %modified whilst matching the same lines of text as the original expression. % %For example, \verb|a*bc+|'' is equivalent to \verb|bc|'' because the Kleene Star (Plus) operator matches zero (one) or more instances of a %specific character. % The aforementioned \texttt{toUTF8} transformation also applies during this phase to generate code unit classes. %The \emph{toUTF8} pass converts the Unicode character classes in the input \RegularExpression{} into equivalent expression(s) that represent sequences %of 8-bit code units necessary to identify occurrences of the class. % %Since some characters have multiple logically equivalent representations, such as \textcolor{red}{\textbf{????}}, this may produce nested sequences or alternations. % %This is described in more detail in \S\ref{sec:Unicode:toUTF8}. % %A final \emph{Simplification} pass flattens nested structures into their simplest legal form. % %For example, \verba(b((c|d)|e))'' becomes \verbab(c|d|e)'' and \verb([0-9]{3,5}){3,5}'' becomes \verb[0-9]{9,25}''. % %% DISCUSS ANALYSIS MODULE? The next layer transforms this AST into the instructions in the \Pablo{} IR. % %has two compilers: the \CodeUnitCompiler{} and \RegularExpressionCompiler{}, both of which produce \Pablo{} IR. % Recall that the \Pablo{} layer assumes a transposed view of the input data. % The \emph{\RegularExpressionCompiler{}} first transforms all input code unit classes, analogous to non-Unicode character classes, These optimizations exploit redundancies that are harder to recognize in the \RegularExpression{} AST itself. % %The \emph{\CodeUnitCompiler{}} transforms the input code unit classes, %either extracted from the \RegularExpression{} or produced by the \emph{toUTF8} transformation, %into a series of bit stream equations. % %The \emph{\RegularExpressionCompiler{}} %assumes that these have been calculated and %transforms the \RegularExpression{} AST into %a sequence of instructions. %\Pablo{} instructions that use the results of these equations. % %For instance, it converts alternations into a sequence of calculations that are merged with \verb|OR|s. % %The results of these passes are combined and transformed through a series of typical optimization passes, including dead code elimination %(DCE), common subexpression elimination (CSE), and constant folding. % %These optimizations exploit redundancies that are harder to recognize in the \RegularExpression{} AST itself. %These are necessary at this stage because the \RegularExpression{} AST may include common subsequences that are costly to recognize in %that form. % %Similarly, to keep the \CodeUnitCompiler{} a linear time function, it may introduce redundant IR instructions as it applies traditional Boolean %algebra transformations, such as de Morgan's law, to the computed streams. % %An intended side-effect of these passes is that they eliminate the need to analyze the data-dependencies inherent in the carry-bit logic, %which is necessary for some \Pablo{} instructions but problematic for optimizers to reason about non-conservatively. % The \PabloCompiler{} then directly converts the \Pablo{} IR into LLVM IR. % %This is a relatively straightforward conversion: % %the only complexities it introduces is the generation of Phi nodes, linking of statically-compiled functions, and assignment of carry variables. % The LLVM Compiler framework provides flexible APIs for compilation and linking. Using these, \icGrep{} dynamically generates a match function for identifying \paragraph{Dynamic Grep Engine.} \input{fig-executor} Figure~\ref{fig:execution} shows the structure of the \icGrep{} matching engine. The input data is transposed into 8 parallel bit streams through the Transposition module. The Dynamic Matcher returns one bitstream that marks all the positions that fully match the compiled regular expression. Finally, a Match Scanner scans through the returned bitstream to select the matching lines and generate the normal grep output. \input{fig-executor} We can also apply a pipeline parallelism strategy to further speed up the process of \icGrep{}.