changeset 7:117760bfcae9

fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 02 Jul 2015 11:26:27 +0900
parents a780e089f357
children a6907650e3e1
files cfopm.tex reference.bib
diffstat 2 files changed, 79 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/cfopm.tex	Thu Jul 02 01:21:02 2015 +0900
+++ b/cfopm.tex	Thu Jul 02 11:26:27 2015 +0900
@@ -80,7 +80,14 @@
 % As a general rule, do not put math, special symbols or citations
 % in the abstract
 \begin{abstract}
-The programming paradigm which use data segments and code segments are proposed. CbC is a slight modified C for this paradigm. CbC has standalone compiler and GCC(GNU Compiler Collection) version. GCC based CbC compiler is developed in 2008\cite{DBLP:journals/corr/abs-1109-4048} and nested function based goto with environment is implemented in 2011\cite{CbC2011}. In this study, we report a latest CbC compiler which is inplemented in LLVM and Clang 3.7. The detail of implementation and evaluation are shown.
+The programming paradigm which use data segments and code segments
+are proposed. 
+This paradigm uses Continuation based C (CbC), 
+which a slight modified C language.
+Code segments are units of calculation and
+Data segments are sets of typed data.
+We use these segments as units of computation and meta computation.
+In this paper we show the implementation of CbC on LLVM and Clang 3.7.
 \end{abstract}
 
 % no keywords
@@ -110,7 +117,16 @@
 Code segments and data segments are low level enough to represent computational details,
 and are architecture independent. They can be used as architecture independent assemblers. 
 
-CbC has standalone compiler and GCC version. Here we report new partial implementation of CbC compiler based on LLVM and Clang 3.7.
+% CbC has stand alone compiler and GCC version. Here we report new partial implementation of CbC compiler based on LLVM and Clang 3.7.
+CbC was first implemented on micro-C one path compiler.
+GCC based CbC compiler is developed in 2008\cite{DBLP:journals/corr/abs-1109-4048}.
+GCC is GNU Compiler Collection \cite{gcc}.
+In GCC version,  nested function is used to implement goto with environment in 2011\cite{CbC2011}. 
+In this study, we report a latest CbC compiler which is implemented
+in LLVM and Clang 3.7. 
+
+\verb+C--+  \cite{cminusminus} is also known as a lower level language of C. It has precise type specification and goto statement with parameters.
+CbC introduces \verb+__code++ type for code segment which makes clear separation of functions and code segments.
 
 \section{Continuation based C}
 CbC's basic programming unit is the code segment. These are not subroutines, but they look like functions because they take input and produce output. Both input and output should be data segments. Table \ref{src:example} details the definition of the data segment. 
@@ -134,7 +150,7 @@
 \label{src:example}
 \end{table}
 
-In this example, the code segment {\bf f} takes the input data segment {\bf allocate} (allocate is the data segments identifier) and sends f's outuput to the code segment {\bf g}. The CbC compiler generates the data segment definition automatically, so writing it is unnecessary. There is no return from code segment {\bf g}. {\bf G} should call another continuation using {\bf goto}. Code segments have input data segments and output data segments. Data segments have two kind of dependency with code segments.
+In this example, the code segment {\bf f} takes the input data segment {\bf allocate} (allocate is the data segments identifier) and sends f's output to the code segment {\bf g}. The CbC compiler generates the data segment definition automatically, so writing it is unnecessary. There is no return from code segment {\bf g}. {\bf G} should call another continuation using {\bf goto}. Code segments have input data segments and output data segments. Data segments have two kind of dependency with code segments.
 First, Code segments access the contents of data segments using field names. So data segments should have the named fields.
 The second dependency is a data dependency, that is all input data segments should be ready before their execution.
 
@@ -166,7 +182,7 @@
 In this hello world example, the environment of {\bf main}() and its continuation is kept in the variable {\bf \_\_environment}. The environment and the continuation can be accessed using {\bf \_\_environment} and {\bf \_\_return}.The arbitrary mixing of code segments and functions is allowed. The continuation of a {\bf goto} statement never returns to the original function, but goes to the caller or the original function. In that case, it returns the result 123 to the operating system. This continuation is called {\bf goto with environment}. 
 
 \section{LLVM and Clang}
-The LLVM Project is a collection of modular and reusable compilers and toolchain technologies, and the LLVM Core libraries provide a modern source and target independent optimizer, along with code generation support for many popular CPUs. Clang is an LLVM native C/C++/Objective-C compiler. Figure \ref{fig:structure} shows Clang and LLVM's compilation flow.
+The LLVM Project is a collection of modular and reusable compilers and tool chain technologies, and the LLVM Core libraries provide a modern source and target independent optimizer, along with code generation support for many popular CPUs. Clang is an LLVM native C/C++/Objective-C compiler. Figure \ref{fig:structure} shows Clang and LLVM's compilation flow.
 
 \begin{figure}[htp]
   \begin{center}
@@ -218,19 +234,56 @@
   return i+4;
 }
 \end{lstlisting}
-\caption{benchmark program conv1}
+\caption{benchmark program in C}
 \label{src:example}
 \end{table}
 
-It is written in C and CbC and there are several optimizations possible.
-When the argument is 1, CbC continuation is used. When the argument is 2 or 3, optimization is enabled.
-In this benchmark, inline optimization was omitted.
+Fig.\ref{src:example} is a normal C program. We can rewrite this program into CbC in several way, \verb+conv1,conv2,conv3+.
+Basicaly function call is emulated by goto statement with explicit stack. \verb+conv2,conv3+ uses extra
+argument to eliminate these stacks.  
+The CbC \verb+conv3+ source is shown in fig.\ref{src:cbc}
+Using this benchmark, function call overhead become visible.
+In order to see the overhead, inline function expansion is prohibited.
 The benchmark results are shown in TABLE \ref{result}.
 
+\begin{table}[html]
+\begin{lstlisting}
+
+struct cont_interface { // General Return Continuation
+    __code (*ret)();
+};
+
+__code f2_1(int i,char *sp) {
+    int k,j;
+    k = 3+i;
+    goto g2_1(k,i+3,sp);
+}
+
+__code g2_1(int k,int i,char *sp) {
+    goto h2_11(k,i+4,sp);
+}
+
+__code h2_1_1(int i,int k,int j,char *sp) {
+    goto f2_0_1(k,i+j,sp);
+}
+
+__code h2_11(int i,int k,char *sp) {
+    goto h2_1_1(i,k,i+4,sp);
+}
+
+__code f2_0_1(int k,int j,char *sp) {
+    goto (( (struct cont_interface *)sp)->ret)(k+4+j,sp);
+}
+
+\end{lstlisting}
+\caption{benchmark program conv3 in CbC}
+\label{src:cbc}
+\end{table}
+
 \begin{table}[htpb]
   \centering
   \begin{tabular}{|l|r|r|r|} \hline
-    & ./conv1 1 & ./conv1 2 & ./conv1 3 \\ \hline
+    & conv1 & conv2 & conv3 \\ \hline
     Micro-C  & 6.875 & 2.4562 & 3.105 \\ \hline
     GCC -O2 & 2.9438 & 0.955 & 1.265  \\ \hline
     LLVM/clang -O0 & 5.835 & 4.1887 & 5.0625 \\ \hline
--- a/reference.bib	Thu Jul 02 01:21:02 2015 +0900
+++ b/reference.bib	Thu Jul 02 11:26:27 2015 +0900
@@ -27,3 +27,20 @@
 author = "{clang documentation}",
 title = "{\\http://clang.llvm.org/docs/index.html}",
 }
+
+@misc{gcc,
+title="{GCC, the GNU Compiler Collection}",
+  url = "http://gcc.gnu.org/",
+author="{Free Software Foundation, Inc.}",
+month="March",
+year=2008
+}
+
+@inproceedings{cminusminus,
+title="A Single Intermediate Language That Supports multiple Implementations of Exceptions",
+author="Norman Ramsey and Simon Peyton Jones",
+booktitle="ACM SIGPLAN 2000 Conference on Programming Language Design and Implementation",
+month="June",
+year="2000"
+}
+