annotate paper/resume.tex @ 12:f0a7ebdf9d3f draft

modify
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Wed, 22 Feb 2012 18:37:06 +0900
parents 8bf97bf22f54
children b3ebb4a6ae75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 \documentclass[twocolumn,twoside,9.5pt]{jarticle}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 %\usepackage[dvips]{graphicx}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 \usepackage[dvipdfm]{graphicx}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 \usepackage{picins}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 \usepackage{fancyhdr}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 \usepackage{listings}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 \usepackage{url}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 \lhead{\parpic{\includegraphics[height=1zw,clip,keepaspectratio]{figure/emblem-bitmap.eps}}琉球大学主催 工学部情報工学科 卒業研究発表会}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 \rhead{}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 \cfoot{}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 \setlength{\topmargin}{-1in \addtolength{\topmargin}{15mm}}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 \setlength{\headheight}{0mm}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 \setlength{\headsep}{5mm}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 \setlength{\oddsidemargin}{-1in \addtolength{\oddsidemargin}{11mm}}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 \setlength{\evensidemargin}{-1in \addtolength{\evensidemargin}{21mm}}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 \setlength{\textwidth}{181mm}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 \setlength{\textheight}{261mm}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 \setlength{\footskip}{0mm}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 \pagestyle{empty}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 \begin{document}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 \title{Continuation based C コンパイラのGCC-4.6における実装}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 \author{学籍番号:085711E 氏名:大城信康 {}{} 指導教員 : 河野真治}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 %\date{H23 11/18 fri}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 %\date{平成23 年11 月18 日}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 \maketitle
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 \thispagestyle{fancy}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 \section{研究背景と目的}
6
b6584cc0f737 modify resume.tex
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
32 当研究室ではプログラムをコードセグメント (Code Segment) 単位で記述するプログラミング言語 Continuation based C (以下 CbC) を提案している.
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 コードセグメントは並列実行の単位として使うことができ, プログラムの正しさを示す単位としても使用することができる.これにより,
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 Many Core での並列実行を高い性能と高い信頼性で実現することができると考えている.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 GCC をベースとした CbC のコンパイラ (以下 CbC-GCC)は, GCC のアップデートに合わせて変更する必要がある.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 本研究では, GCC-4.5 をベースとしていた CbC-GCC を GCC-4.6 へのアップデートを行い, Intel64 に対応するとともに, CbC の拡張を行う.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 \section{Continuation basede C (CbC)}
12
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
40 Continuation based C (以下 CbC) は状態遷移記述が行うことができる C を基本としたプログラミング言語である.
6
b6584cc0f737 modify resume.tex
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
41 構文は C と同じであるが, 継続(goto) やコードセグメントの導入によりループ制御や関数コールが取り除かれる.
7
1f5bfcd8b685 modify resume.tex
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
42 CbC のプログラムはコードセグメントの末尾から次のコードセグメントへの継続を記述することで作られる.
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 図\ref{fig:cs}はコードセグメント間の処理の流れを表している.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 \begin{figure}[htpb]
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 \begin{center}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 \scalebox{0.35}{\includegraphics{figure/codesegment.pdf}}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 \end{center}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 \caption{コードセグメント間の継続(goto)}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 \label{fig:cs}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 \end{figure}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 \section{GCC-4.6 への実装}
12
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
55 CbC 環境を保持しない継続は軽量継続と呼ばれる.
9
942888c0f8aa modify explanation of tailcall elimination
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
56 GCC における軽量継続は Tail Call Ellimination (末尾除去)を強制することで実装する.
10
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
57 これにより, コードセグメント間の移動を, call ではなく jmp 命令で行う.
12
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
58 この為コードセグメントからのは戻値は無くなる.
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 図\ref{fig:continue}は Tail Call Elimination によるプログラムの処理の流れを表す.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 \begin{figure}[htpb]
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 \begin{center}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 \scalebox{0.30}{\includegraphics{figure/continuation.pdf}}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 \end{center}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 \caption{Tail Call Elimination の例}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 \label{fig:continue}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 \end{figure}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
10
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
68 \subsection{Tail Call Elimination の矯正付与}
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
69 関数が Tail Call Elimination にかかる為には, ``呼び出し先関数と呼び出し元関数の方が一致している''
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
70 等といった幾つかの条件をクリアしなければならない.
9
942888c0f8aa modify explanation of tailcall elimination
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
71 これまでの実装ではコードセグメントに条件をクリアさせる為, 専用の関数を用意していた.
12
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
72 しかし今回の実装ではその関数を廃止し, 末尾除去にかかるフラグを落とさせない
10
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
73 コードを追加することで Tail Call Elimination の条件をクリアさせるようになった.
9
942888c0f8aa modify explanation of tailcall elimination
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
74 これにより GCC のアップデート時に伴う専用関数の修正が不要となり, 楽な管理が行えるようになった.
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 \subsection{環境付き継続}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 CbC には通常の C の関数からコードセグメントに継続する際,
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 その関数から値を戻す処理への継続を得ることができる.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 これを環境付き継続という.
10
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
80 環境付き継続は, \verb+__environment+ と \verb+__return+ キーワードを
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
81 引数に渡しコードセグメントとして扱うことで使用できる.
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
82 %\verb+environment+ は 環境を表す情報を持つ.
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
83 %\verb+__return+ は環境付き継続の行き先であり, 関数の戻り値と\verb+__environment+ の二つの引数を
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
84 %持つコードセグメントになる.
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
85 %GCC内部では, \verb+__return+ は, 関数内で定義された \verb+_cbc_internal_return+関数へのポインタを返す.
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
86 %戻値は, \verb+cbc_internal_return+ 関数内で定義された変数\verb+retval+を通して返される(Listing\ref{code:retval}) .
12
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
87 実際には \verb+__return+ キーワードにより GCC 内部でlisting\ref{code:retval}のコードが生成されている.
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 \begin{figure}[h]
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 \begin{minipage}[b]{.45\textwidth}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 \begin{lstlisting}[caption=環境付き継続を行うコード,label=code:retval]
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 ({
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 __label__ _cbc_exit0;
11
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
93 static int retval;
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 void _cbc_internal_return(int retval_,
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 void *_envp){
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 retval = retval_;
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 goto _cbc_exit0;
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 }
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 if (0) {
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 _cbc_exit0:
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 return retval;
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 }
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 _cbc_internal_return;
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 })
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 \end{lstlisting}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 \end{minipage}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 \hfill
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 \end{figure}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 \subsubsection{環境付き継続の問題と改良}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 環境付き継続で特に重要になってくるのが retval 変数の値をどこに確保するかである.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 元々の実装ではListing\ref{code:retval}の様に static で値の確保を行なっていた.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 しかしこれではスレッドセーフではない.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 そこで retval 変数の値を static thread local で確保することでこの問題の解決を行った.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115
11
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
116 \subsection{構文の追加}
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117
11
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
118 \subsubsection{``\_\_rectype'', ``selftype'' 構文}
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 %\verb+__rectype+キーワードはリカーシブタイプを宣言する時に使われる.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 通常, 関数定義において引数の中に自分自身を指す関数ポインタを入れることはできない.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 そこで, \verb+__rectype+を使うことでlisting\ref{code:rectype}の用な宣言が行うことができる.
8
42e6dd499688 modify resume.tex
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
122 また, 構造体の宣言時に宣言中の構造体を指す``selftype'' 構文の追加も行った.
42e6dd499688 modify resume.tex
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
123 listing\ref{code:rectype}の様な宣言が行えるようになった.
42e6dd499688 modify resume.tex
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
124 この時\verb+__rectype+は funcPtr を指し, selftype は struct node を指す.
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 \begin{figure}[h]
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 \begin{minipage}[b]{.45\textwidth}
10
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
127 \begin{lstlisting}[caption=\_\_rectype\, selftype 構文の使用例,label=code:rectype]
9
942888c0f8aa modify explanation of tailcall elimination
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
128 typedef __code (*funcPtr)(int,__rectype*);
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 struct node {
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 int num;
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 selftype child;
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 }
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 \end{lstlisting}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 \end{minipage}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 \hfill
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 \end{figure}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 \section{評価}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 今回実装を行った GCC-4.6 ベース と安定版である GCC-4.4 ベース,
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 それと Micro-C の CbC コンパイラでベンチマークを行った.
10
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
141 プログラムは Micro-C のベンチマークにも使用されるものである.
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
142 引数 1 は C で書かれたプログラムをただ CbC へと変換したプログラムになる.
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
143 引数 2 と 3 は Micro-C 用に手動で最適化を行ったプログラムである.
12
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
144 また評価は \verb+x86_64+ 上の CentOS 5.7 で行った.
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
145 %また評価は \verb+x86_64+ 上の OS X(10.7) で 32bit と 64bit それぞれに最適化オプション(-O2)をつけての評価を行った.
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
146 %結果を図\ref{fig:conv1}の様になった(斜線は segmentation fault を示す).
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
147
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 \begin{figure}[htpb]
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 \begin{center}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 \scalebox{0.33}{\includegraphics{figure/conv1_linux.pdf}}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 \end{center}
9
942888c0f8aa modify explanation of tailcall elimination
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
152 \caption{各種コンパイラにより生成されたコードの速度比較}
12
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
153 \label{fig:conv1}
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 \end{figure}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 \subsection{評価の考察}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 まず, Micro-C 版より GCC 版コンパイラの方が結果が良いことが確認できる.
12
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
158 次に GCC-4.5 と GCC-4.6 を比較してみる.
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
159 手動で最適化を行なっている引数 2 と 3 の時は余り差は無い.
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
160 だが, 引数 1 の時は GCC-4.6 版が GCC-4.5 に比べて 1.67 倍程早い.
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
161 この結果から GCC-4.5 に比べ GCC-4.6 の最適化が修正されよりよくなっているのが確認できる.
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 \section{今後の課題}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 今回, CbC コンパイラを GCC-4.6 へとアップデートを行った.
12
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
165 アップデートに伴い実装の修正と Intel64 bit への対応を行った.
4
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 また, CbC の記述に便利な新たな構文の追加も行うことができた.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 GCC 版 CbC コンパイラは細かい実装の除けば, 以後 GCC のアップデートに合わせていくだけとなる.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 CbC コンパイラの今後としては LLVM への実装, もしくは Google go 言語での実装の検討を行なっていく予定である.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 %今後は本稿で述べた CbC-GCC の問題点を改善していく必要がある.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 %また,CbC を GCC だけでなく LLVM での実装や,C 言語以外の言語への変更も検討していく.
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 \thispagestyle{fancy}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 \begin{thebibliography}{3}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 \bibitem{1}{河野真治}:
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 ``継続を基本とした言語 CbC の gcc 上の実装''. 日本ソフトウェア科学会第 19 回大会論文集, Sep, 2002
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 \bibitem{2}{与儀健人,河野真治}:
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 ``Continuation based CコンパイラのGCC-4.2による実装''. 琉球大学 情報工学科 学位論文, 2008
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 \bibitem{3}{GNU Compiler Collection (GCC) Internals}:
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 ``http://gcc.gnu.org/onlinedocs/gccint/''
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 \end{thebibliography}
be5b510b6d44 add some files
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 \end{document}