# HG changeset patch # User Nobuyasu Oshiro # Date 1339758444 -32400 # Node ID 680becde8c9fc806e71b0e25fcb48859236c34ef # Parent 18ee51dfe7fc66a92229a2d9820f653f79a9bf6a modify coparison diff -r 18ee51dfe7fc -r 680becde8c9f paper/Makefile --- a/paper/Makefile Fri Jun 15 17:50:50 2012 +0900 +++ b/paper/Makefile Fri Jun 15 20:07:24 2012 +0900 @@ -1,6 +1,6 @@ -DEPENDENCY = rectype.ind figure/code.pdf figure/tree1.pdf figure/tree2.pdf +DEPENDENCY = rectype.ind graphics[width=6cm]figure/code.pdf graphicsfigure/tree1.pdf graphicsfigure/tree2.pdf -DEPENDOHP = ohp.tex graphics[width=6cm] graphics[width=6cm]figure/code.pdf graphicsfigure/tree1.pdf graphicsfigure/tree2.pdf +DEPENDOHP = ohp.tex graphics[width=6cm]figure/code.pdf graphicsfigure/tree1.pdf graphicsfigure/tree2.pdf PAPER = rectype.ind diff -r 18ee51dfe7fc -r 680becde8c9f paper/rectype.ind --- a/paper/rectype.ind Fri Jun 15 17:50:50 2012 +0900 +++ b/paper/rectype.ind Fri Jun 15 20:07:24 2012 +0900 @@ -40,7 +40,6 @@ only, because it is sufficient to implement C to CbC translation. In this case, code segment has one input interface and several output interfaces (fig.\ref{code}). -\includegraphics[width=6cm]{ \begin{figure}[htb] \begin{center} \includegraphics[width=6cm]{figure/code.pdf} @@ -50,7 +49,6 @@ \end{figure} - \verb+__code+ and parameterized global goto statement is an extension of Continuation based C. Unlike \verb+C--+ \cite{cminusminus}'s parameterized goto, we cannot goto into normal C function. @@ -89,15 +87,11 @@ CbC is a kind of high level assembler language. It can do several original C language cannot do. For examples, -{\small -\begin{verbatim} Thread Scheduler Context Switch Synchronization Primitives I/O wait semantics -\end{verbatim} -} are impossible to write in C. Usually it requires some help of assembler language such as \verb+__asm+ statement extension which is @@ -202,11 +196,11 @@ The syntax of C Must be declared recursively. The following declaration if it may be that the type checking of p. - __code csA( __code (*p)( __code )) { + __code csA( __code (*p)( __code(*)())) { goto p(csB); } -However this declaration is long. +However this declaration is to require long typing. Therefore we implemented \rectype syntax in CbC on GCC. \rectype syntax is declare a recursive type. @@ -326,26 +320,90 @@ Recursively program does not occur. +--Comparison -\section{Comparision} +Here is CbC program that finds the Fibonacci sequence. + __code print(__rectype *p, long int num, + long int count, long int result, long int prev) { + printf("fibonacci(%d) = %ld\n",num,result); + goto cs_while(print, num, count, result, prev); + } + + __code fibonacci(__rectype *p, long int num, + long int count, long int result, long int prev) { + if (count == 0) { + result += 0; + count++; + } else if (count == 1) { + result += 1; + count++; + } else if (count > 1){ + long int tmp = prev; + prev = result; + result = result + tmp; + count++; + } else { + printf("please enter nutural number\n"); + exit(0); + } + if (num < count) { + goto p(fibonacci, num, count, result, prev); + } + goto fibonacci(p, num, count, result, prev); + } + __code cs_while(__rectype *p, long int num, + long int count, long int result, long int prev) { + if (num > 0) { + num--; + goto fibonacci(print, num, 0, 0, 0); + } + exit(0); + } + +It is written using \rectype syntax. +Do not use the \rectype syntax program would be the following declaration. + + __code print(__code (*p)(__code(*)(),long int,long int,long int,long int), + long int num, long int count, long int result, long int prev); + __code fibonacci(__code (*p)(__code(*)(),long int,long int, long int,long int), + long int num, long int count, long int result, long int prev); + __code cs_while(__code (*p)(__code(*)(),long int, long int, long int, long int), + long int num, long int count, long int result, long int prev); + +Comparing the program that made the declaration of each. +AST is almost the same should be created both. +Therefore, there should be no difference was the result. + +Here is the result. \begin{table}[htpb] \centering \small \begin{tabular}{|l|r|r|r|} \hline -(unit: s) & ./conv1 1 & ./conv1 2 & ./conv1 3 \\ \hline -GCC -O3(32bit) & 2.52 & 2.34 & 1.53 \\ \hline -GCC -O3(64bit) & 1.80 & 1.20 & 1.44 \\ \hline +(unit: s) & ./fibonacci 1000 \\ \hline +using rectype & 0.7 \\ \hline +not use rectype & 0.7 \\ \hline \end{tabular} -\caption{Micro-C, GCC bench mark (in sec)} +\caption{GCC bench mark (in sec)} \label{tab:gcc,compare} \end{table} +There was no difference in the results are as we predicted. --Conclusion +We have designed and implemented Continuation based language for practical use. +We have implemented \rectype syntax. +Thereby Easily be able to write code than previous. + + + + + + +