Mercurial > hg > Papers > 2010 > aplas-2010
changeset 0:b6c8eda48e39 default tip
first try
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 17 Jun 2010 04:38:29 +0900 |
parents | |
children | |
files | CbC and Test.mm cbc.ind |
diffstat | 2 files changed, 245 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CbC and Test.mm Thu Jun 17 04:38:29 2010 +0900 @@ -0,0 +1,96 @@ +<map version="0.8.1"> +<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net --> +<node CREATED="1276424436877" ID="Freemind_Link_17871268" MODIFIED="1276424450036" TEXT="CbC and Test"> +<node CREATED="1276424451251" ID="_" MODIFIED="1276424455572" POSITION="right" TEXT="Code Segment"> +<node CREATED="1276424575942" ID="Freemind_Link_489366142" MODIFIED="1276424583425" TEXT="Multi level description"/> +<node CREATED="1276424631330" ID="Freemind_Link_475145977" MODIFIED="1276424636733" TEXT="Abstract Execution"/> +</node> +<node CREATED="1276424456024" ID="Freemind_Link_1757687940" MODIFIED="1276424459484" POSITION="right" TEXT="Data Segment"> +<node CREATED="1276424593965" ID="Freemind_Link_1762509035" MODIFIED="1276424598264" TEXT="Input Interface"/> +<node CREATED="1276424598708" ID="Freemind_Link_210877953" MODIFIED="1276424602192" TEXT="Output Interface"/> +</node> +<node CREATED="1276424684902" ID="Freemind_Link_1407576949" MODIFIED="1276424693392" POSITION="right" TEXT="Language and Runtime"> +<node CREATED="1276424704243" ID="Freemind_Link_94163212" MODIFIED="1276424710814" TEXT="SEDA architecture"/> +<node CREATED="1276424750639" ID="Freemind_Link_1675193473" MODIFIED="1276424757746" TEXT="gcc implementation"/> +<node CREATED="1276424828201" ID="Freemind_Link_1922111862" MODIFIED="1276424837227" TEXT="Running on various runtime"/> +</node> +<node CREATED="1276424643464" ID="Freemind_Link_362002356" MODIFIED="1276424650891" POSITION="right" TEXT="Reflection in Continuation based C"/> +<node CREATED="1276424716274" ID="Freemind_Link_1812288208" MODIFIED="1276424719238" POSITION="right" TEXT="What for?"> +<node CREATED="1276424720170" ID="Freemind_Link_588280186" MODIFIED="1276424727909" TEXT="Server side"/> +<node CREATED="1276424730057" ID="Freemind_Link_852142285" MODIFIED="1276424736268" TEXT="Interpreter/Compiler"/> +</node> +<node CREATED="1276424743544" ID="Freemind_Link_910574846" MODIFIED="1276424785808" POSITION="right" TEXT="Module"> +<node CREATED="1276424792092" ID="Freemind_Link_631128678" MODIFIED="1276424794505" TEXT="naming"> +<node CREATED="1276424795571" ID="Freemind_Link_1211558810" MODIFIED="1276424802847" TEXT="variable name is not important"/> +</node> +</node> +<node CREATED="1276570148161" ID="Freemind_Link_1183229541" MODIFIED="1276570155976" POSITION="right" TEXT="story"> +<node CREATED="1276570156261" ID="Freemind_Link_893480232" MODIFIED="1276590735742" TEXT="Language for Code generation"> +<node CREATED="1276570417799" ID="Freemind_Link_1701107658" MODIFIED="1276570421634" TEXT="Continuation based C"/> +<node CREATED="1276570422638" ID="Freemind_Link_367386816" MODIFIED="1276570425177" TEXT="Correctness"/> +<node CREATED="1276570432660" ID="Freemind_Link_96585008" MODIFIED="1276570437182" TEXT="Readability"/> +<node CREATED="1276570440378" ID="Freemind_Link_943325128" MODIFIED="1276570456491" TEXT="Optimization Completeness"/> +</node> +<node CREATED="1276570176145" ID="Freemind_Link_1923412767" MODIFIED="1276570180683" TEXT="Software Architecture"> +<node CREATED="1276570403186" ID="Freemind_Link_1689485035" MODIFIED="1276570406045" TEXT="SEDA"/> +<node CREATED="1276570406473" ID="Freemind_Link_1448308278" MODIFIED="1276570409740" TEXT="Therad Pool"/> +</node> +<node CREATED="1276570181527" ID="Freemind_Link_610543299" MODIFIED="1276570197640" TEXT="Alogorthm and Implementation"> +<node CREATED="1276570227806" ID="Freemind_Link_317446567" MODIFIED="1276570235680" TEXT="Sequential representation"/> +<node CREATED="1276570236252" ID="Freemind_Link_1612139511" MODIFIED="1276570249477" TEXT="Highly concurrent execution"/> +<node CREATED="1276570337271" ID="Freemind_Link_118873289" MODIFIED="1276570341506" TEXT="Technology mapping"/> +</node> +<node CREATED="1276570199476" ID="Freemind_Link_1430286119" MODIFIED="1276570205862" TEXT="Data Storage"> +<node CREATED="1276570206218" ID="Freemind_Link_226936421" MODIFIED="1276570217444" TEXT="Short Term"/> +<node CREATED="1276570218064" ID="Freemind_Link_1123763861" MODIFIED="1276570220003" TEXT="Long Term"/> +<node CREATED="1276570257648" ID="Freemind_Link_1846342342" MODIFIED="1276570266666" TEXT="Garbage Collection"/> +</node> +<node CREATED="1276570282427" ID="Freemind_Link_457585241" MODIFIED="1276570292940" TEXT="Execution Model"> +<node CREATED="1276570855429" ID="Freemind_Link_1139914124" MODIFIED="1276570860391" TEXT="Code Segment"> +<node CREATED="1276570875337" ID="Freemind_Link_46458622" MODIFIED="1276570880747" TEXT="Basic Block"/> +</node> +<node CREATED="1276570860804" ID="Freemind_Link_1182656215" MODIFIED="1276570863223" TEXT="Data Segment"> +<node CREATED="1276570867051" ID="Freemind_Link_1710001393" MODIFIED="1276570873781" TEXT="2^n memory pool"/> +</node> +<node CREATED="1276570889374" ID="Freemind_Link_615060457" MODIFIED="1276570896656" TEXT="Multiple Execution pattern"> +<node CREATED="1276570897084" ID="Freemind_Link_768022003" MODIFIED="1276570901815" TEXT="Stack base"/> +<node CREATED="1276570902611" ID="Freemind_Link_1404453715" MODIFIED="1276570904198" TEXT="Queue base"> +<node CREATED="1276570913089" ID="Freemind_Link_1960228756" MODIFIED="1276570915996" TEXT="Pipelined"/> +</node> +<node CREATED="1276570904827" ID="Freemind_Link_1526539917" MODIFIED="1276570907294" TEXT="Distributed"/> +<node CREATED="1276570930541" ID="Freemind_Link_308218517" MODIFIED="1276570934104" TEXT="Emulation"/> +</node> +<node CREATED="1276570919256" ID="Freemind_Link_11049576" MODIFIED="1276570924010" TEXT="Technology mapping"/> +</node> +<node CREATED="1276570297352" ID="Freemind_Link_583543389" MODIFIED="1276570808754" TEXT="Test Method"> +<node CREATED="1276570301671" ID="Freemind_Link_1156884115" MODIFIED="1276570308729" TEXT="local correctness"> +<node CREATED="1276570319235" ID="Freemind_Link_1300107129" MODIFIED="1276570329205" TEXT="functional equivalence"/> +<node CREATED="1276570330481" ID="Freemind_Link_1891549541" MODIFIED="1276570332580" TEXT="input and output"/> +</node> +<node CREATED="1276570309253" ID="Freemind_Link_66802159" MODIFIED="1276570314040" TEXT="global correctness"> +<node CREATED="1276570343326" ID="Freemind_Link_1298553642" MODIFIED="1276570346569" TEXT="Fairness"/> +<node CREATED="1276570348085" ID="Freemind_Link_1379304651" MODIFIED="1276570353200" TEXT="Synchronization"/> +<node CREATED="1276570353484" ID="Freemind_Link_674483959" MODIFIED="1276570355687" TEXT="Performance"/> +<node CREATED="1276570356036" ID="Freemind_Link_1140932943" MODIFIED="1276570362174" TEXT="Scalability"/> +</node> +</node> +<node CREATED="1276570365362" ID="Freemind_Link_6377009" MODIFIED="1276570368613" TEXT="Comparison"> +<node CREATED="1276570369009" ID="Freemind_Link_1705557897" MODIFIED="1276570380258" TEXT="Structured Programming"/> +<node CREATED="1276570775095" ID="Freemind_Link_1974404720" MODIFIED="1276570778608" TEXT="Open CL"/> +<node CREATED="1276570779356" ID="Freemind_Link_336950305" MODIFIED="1276570781648" TEXT="LLVM"/> +<node CREATED="1276570783668" ID="Freemind_Link_971747592" MODIFIED="1276570786148" TEXT="C--"/> +<node CREATED="1276591053661" ID="Freemind_Link_1903597398" MODIFIED="1276591062391" TEXT="Xunit"/> +<node CREATED="1276591062875" ID="Freemind_Link_1549281636" MODIFIED="1276591065687" TEXT="TDD"/> +</node> +</node> +<node CREATED="1276424489565" ID="Freemind_Link_911790496" MODIFIED="1276424493377" POSITION="left" TEXT="Coverage"/> +<node CREATED="1276424498389" ID="Freemind_Link_1753489909" MODIFIED="1276424506297" POSITION="left" TEXT="Test"> +<node CREATED="1276424507068" ID="Freemind_Link_469069717" MODIFIED="1276424531974" TEXT="Local Correctness"/> +<node CREATED="1276424532642" ID="Freemind_Link_777776311" MODIFIED="1276424538925" TEXT="Global Correctness"/> +<node CREATED="1276424539369" ID="Freemind_Link_1793063899" MODIFIED="1276424550676" TEXT="Temporal logical property"/> +</node> +<node CREATED="1276424607627" ID="Freemind_Link_340183616" MODIFIED="1276424612439" POSITION="left" TEXT="State Enumeration"/> +<node CREATED="1276424613659" ID="Freemind_Link_1334450074" MODIFIED="1276424618862" POSITION="left" TEXT="State Abstraction"/> +<node CREATED="1276424814466" ID="Freemind_Link_61781081" MODIFIED="1276424822421" POSITION="left" TEXT="Type correct stack"/> +</node> +</map>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbc.ind Thu Jun 17 04:38:29 2010 +0900 @@ -0,0 +1,149 @@ +-title: Testing and Equivalence using Continuation based C + +--abstract: + +Continuation based C (CbC) is a language without function call. We have implemented +the language in GCC. This language is suitable for embedded systems or +many core architecture such as Cell, GPGPU or Core i7 architecture. In order +to achieve high performance, special features are necessary like vector processing, +stream arithmetic or Open CL like parallel processing, +which is usually difficult to use and its correctness is uncertain. +In CbC, these special features themselves can be expressed. +We show how to use CbC in Testing and +Equivalence when we use special features. + +--Programming Language for Code Generation + +Today, quite large size softwares are written and working. +Many of them are half generated by computer itselves. +For an example, GCC (GNU compiler collection)\cite{gcc} generates many insn-*.c +file from machine description. Another example is Scala\cige{scala}, which +generates Java Byte Code. Ruby on rails generates ruby scripts. + +We are developping Continuation based C, here after CbC \cite{cbc}, which is suitable for +state machine description, which is also good for compiler target language. +CbC has two basic elements, code segment and data segment. Code segements are +connected by parameterised goto statements. Data segments are exchanged among code segments. Data segment is designed to fit in various Many Core Architecture such as Cell\cite{cell}. + +Generated code is supposed to work efficiently, but it have to running on sepcial +hardware sometimes. Often generated code is modified or is implemeted in a hardware +to achieve high performance. We can use any programming language as a generation +target, but we focus on these points, + + Effective usage of special architecture, + Representation of behavior, + Modularity, + Testability, + Memory awareness. + +In CbC, a large software is divided into units which roughly equal basic block +of compiler. Since CbC has no implicit environment, that is stack, code state +is fully represented in an input interface of the code segment. Of course, +the input interface may have complex state, for example, simulated stack, +but we can insert test code between two code segments. This is our basic +idea. + +In this paper, we describe Continuation based C and its code segment and data +segment system and its implementation on gcc. We will discuss the software +architecture of CbC and Cerium Task Manager for PS3\cite{ps3}, then we +discuss our testing method for CbC. + +--Continuation based C + +A code segment in CbC is a normal C function actually. It has no return value and +no return statement, if it has it it will be an error. To exit the code segment, +goto statement to other or same code segment is used. Besides return statement, +any C statement can be used, normal C function is allowed also. + + __code code1(int a, int b) { + goto code2(a,b); + } + +\verb+__code+ is a type of function. Arguments of code segment arel called input +interface and arguments of goto statement are called output interface. In our +system, input / output interfaces are usually a set of data segments, which we +discuss it later. + +It is possible to convert C program into CbC with no funcion calls, using a +kind of CPS transformation \cite{cbc-c} (in Japanese). + +A pointer to a code segment is a light weight continuation, since it has no +environment. This is becase code segment has no return. In this way code +segment is different from normal C function. + +Unfortunately, ANSI-C has no recursive type, we cannot write exact type +of continuation, but it is not a seriaus problem. It is written like this. +Detailed parameter definitions are ommited. + + __code code1(int a, int b, __code (*cont)(int a, int b, __code (*cont1)()) ) ; + goto (*cont1)(a,b, cont1); + } + +In many case, many forward reference requires many prototype declaration. In CbC, +these definitions are automatically generated (by scripts). + +---Interaction with C function + +Since CbC is a C, any C function can be called in a code segment. To enter a +code segment from a C function, a parameterised goto is used, but it has +no return. To return from a code segment, full continuation ( continuation +with full environment) is used. A buitl-in function \verb+__CbC_return+ and +\verb+__CbC_environment+. + + typedef __code (*return_type)(int, void*); + __code f(return_type cont,void *env) { + goto (*cont)(10,env); + } + + int + main(int argc, char **argv) + { + return_type cont = _CbC_return; + void *env = _CbC_environment; + goto f(cont,env); + } + +In a function \verb+f+, cont contains a code segment to return value +from \verb+main()+. \verb+env+ is a pointr to the environment, that is +a frame pointer or stack pointer. + +If you want to return to a middle of a fuction, put a function call. + +Of course, in Unix, you can simply \verb+exit()+ from a code segment. +This is much simpler. + +--Langugage Implementation + +We have to implementation of CbC, one is a hand writtern compiler and +the other one is a patched gcc. + +The modification of GCC is not so large. In a \+verb+c-parse.c+ and +\verb+exapnd_call.c+. In a parse, \verb+__code+ type , CbC_return, +CbC_environment+ is added. CbC_return geneartes a code segment using +a nested function in GCC. + +In call.c, a code segment is handle as a forced tail call eliminaton. +In GCC, tail call elimination is easily gave up, which is not allowed +in CbC. So some modification is necessary. + +In GCC, CbC code segment has fixed stack frame size. If called +stack frame size is small than caller, no TCE is performed. +Argmeents in goto statement parmeter must not overrapped. +In order to assure this, we simplly copy argments to newly +created variable at the parse level. + +If we use normal C sype ABI (argument passing convention), +i386 version runs very slow, becase all arguments have to +be in a stack. To avoid this, FASTCAlL option is +forced in all code segments. This is quite good in EMT64 modee +which has more register. + +--Data Storage Implemantation + +--Software Architecture + +--Execution Model + +--Testing method +--Comparison +