-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
292 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,62 @@ | ||
\chapter{序論} | ||
\label{chap:introduction} | ||
|
||
\section{本研究の背景} | ||
\section{背景} | ||
\label{section:background} | ||
|
||
低消費電力デバイスの性能向上と低価格化により、身の回りの家具や家電をはじめとしたあらゆるものがインターネットに接続し、 | ||
組み込み向けデバイスの性能向上と低価格化により、身の回りの家具や家電をはじめとしたあらゆるものがインターネットに接続し、 | ||
協調して動作することで生活を豊かにするInternet of Things(IoT)が普及しつつある。 | ||
|
||
また、低消費電力デバイスの性能向上は、これらの上にTLSやHTTPといった比較的高負荷・高フットプリントなプロトコルを実装することも可能とした。 | ||
これにより、端末間の接続、また端末とデータを集約するサーバとの接続に汎用的なプロトコルを用いることができるようになり、高い相互接続性を実現できるようになった。 | ||
|
||
また、単一のチップでWi-FiやBluetooth、Bluetooth Low Energy(BLE)による接続を提供するものも登場している。 | ||
こうした端末を用いることで、電波環境や電力消費といったリソースを効率的に利用することが可能なため、IoTシステムを適用できる環境は大きく広がっている。 | ||
|
||
たとえば、Espressif Systems社のESP32\cite{esp32}は、以下の仕様を持っている。 | ||
Espressif Systemsによって開発されたESP32\cite{esp32}は、組み込み向けデバイスの中でも比較的高性能かつ廉価なSoCの一つである。 | ||
|
||
\begin{itemize} | ||
\item Xtensa single-/dual-core 32-bit LX6 microprocessor(s), up to 600 MIPS | ||
\item 448 KB ROM, 536 KB SRAM | ||
\item QSPI supports multiple flash/SRAM chips | ||
\item 802.11 b/g/n | ||
\item Compliant with Bluetooth v4.2 BR/EDR and BLE specifications | ||
\end{itemize} | ||
|
||
ESP32は豊富な計算資源と高度な無線接続機能を提供する一方で、ESP32が搭載しているXtensaマイクロプロセッサが用いるXtensa命令セットアーキテクチャ\cite{xtensa_isa}は、幅広い開発環境にサポートされているとは言えない。 | ||
現在、ESP32向けのソフトウェア開発環境としてEspressif Systemsにより公式に提供されているのは、以下の2通りの手段である\cite{esp_toolchain}。 | ||
\begin{itemize} | ||
\item C/C++でプログラムを記述し、ESP32 Toolchainによりコンパイルする | ||
\item Arduino言語でプログラムを記述し、Arduino IDEと | ||
Arduino core for ESP32 WiFi chipによりコンパイルする | ||
\end{itemize} | ||
|
||
一方で、各デバイス上で動作するソフトウェアは、依然としてそれぞれの開発環境に合わせて実装する必要がある。 | ||
x86やARMといったアーキテクチャが一般に用いられる個人向けコンピュータやサーバと異なり、低消費電力デバイスが搭載するマイクロコントローラの | ||
アーキテクチャは多岐にわたる。また、サポートされているコンパイラもそれぞれに異なり、開発者はデバイス毎に切り替えて開発を行わなければならない。 | ||
|
||
(FreeRTOSがサポートするマイコンのアーキテクチャ一覧の表?) | ||
|
||
\section{本研究の目的} | ||
|
||
本研究の目的は、異なるCPUアーキテクチャを搭載した低消費電力デバイス間で、同一のWebAssemblyバイナリを実行できることを示すことである。 | ||
x86やARMといった、広く利用されている命令セットアーキテクチャを搭載するPCやサーバ向けのソフトウェア開発では、開発者には多くの開発環境を選択肢として選択できる。 | ||
例えばプログラミング言語の選択という観点では、LLVMが機械語生成の対象としてサポートされているハードウェアであれば、LLVMを機械語生成に用いるプログラミング言語の全てが選択肢となりうる。 | ||
しかし、組み込み向けマイクロコントローラなど、用途が限定されているアーキテクチャの中でサポートされているものは限られている\cite{llvm_matrix}。 | ||
Xtensaも、LLVMによってサポートされていないアーキテクチャの一つである。 | ||
|
||
一般に、複数のアーキテクチャで共通のバイナリを実行することは、それぞれのアーキテクチャ向けにコンパイルされたバイナリを実行するよりも | ||
オーバーヘッドが大きく、CPUの性能やメモリの容量が限られている低消費電力デバイスには向かない。 | ||
\section{本研究が着目する課題} | ||
|
||
そこで本研究では、低消費電力デバイスでも低オーバーヘッドで実行可能なバイナリ表現としてWebAssemblyを用いることを提案する。 | ||
まず、既存の手法(JVM、CPUエミュレーション)と比べ、また実行環境の実装が容易であること、少ないオーバーヘッドで実行できることを示す。 | ||
続いて、C言語でクロスプラットフォームなWebAssemblyランタイムを実装し、ESP32と(ラズパイ?)で同一のバイナリを実行することで、 | ||
異なる低消費電力デバイスで同一のバイナリを実行できることを示す。 | ||
本研究では、\ref{section:background}節で述べた、ESP32向けのソフトウェア開発環境が限られている点に着目する。 | ||
多くの開発環境でサポートされているアーキテクチャをESP32上で実行することができれば、ESP32に向けたソフトウェア開発環境の選択肢を広げることができる。 | ||
|
||
\section{本研究が対象とする環境} | ||
\section{本研究の目的とアプローチ} | ||
|
||
RFC 7228\cite{rfc7228}では、CPU、メモリおよび電力といったリソースにおいて強い制約を持つデバイスを | ||
{\it constrained device}として定義し、いくつかの{\it class}に分類している。 | ||
本研究の目的は、Xtensaアーキテクチャよりも多くの開発環境でサポートされているアーキテクチャ向けにコンパイルされたプログラムを、ESP32上で実行することである。 | ||
|
||
\begin{itembox}[l]{とりあえずコピペした表} | ||
\begin{verbatim} | ||
+-------------+-----------------------+-------------------------+ | ||
| Name | data size (e.g., RAM) | code size (e.g., Flash) | | ||
+-------------+-----------------------+-------------------------+ | ||
| Class 0, C0 | << 10 KiB | << 100 KiB | | ||
| | | | | ||
| Class 1, C1 | ~ 10 KiB | ~ 100 KiB | | ||
| | | | | ||
| Class 2, C2 | ~ 50 KiB | ~ 250 KiB | | ||
+-------------+-----------------------+-------------------------+ | ||
\end{verbatim} | ||
\end{itembox} | ||
そこで、本研究では仮想命令セットアーキテクチャとしてWebAssemblyを用いることを提案する。 | ||
また、実行形式としてWebAssemblyバイナリフォーマットを用いることを提案する。 | ||
|
||
本研究では、ある程度使用できるリソースに制約を持ちながら、すでに広く用いられているプロトコルスタック(TCP/IP、HTTP、TLSなど)を | ||
利用できる程度のリソースを持つ、{\it Class 2}以上のデバイスを想定している。 | ||
本研究では、WebAssembly実行環境をESP32上に実装し、汎用的な開発環境を用いて生成されたプログラムを実行できることを示す。 | ||
これにより、仮想命令セットアーキテクチャとしてWebAssemblyを用いることで、ESP32の開発環境の選択肢を広げられることを示す。 | ||
|
||
\begin{quote} | ||
Class 2 devices are less constrained and fundamentally capable of | ||
supporting most of the same protocol stacks as used on notebooks or | ||
servers | ||
\end{quote} | ||
\begin{figure}[htbp] | ||
\caption{現状と展望} | ||
\label{fig:new_world} | ||
\begin{center} | ||
\includegraphics[bb=0 0 800 600,width=12cm]{img/new_world.pdf} | ||
\end{center} | ||
\end{figure} | ||
|
||
\section{本研究の構成} | ||
|
||
本論文における以降の構成は次の通りである。 | ||
|
||
\ref{chap:related_works}章では、異なるCPUアーキテクチャで同一のバイナリを実行するための既存の手法を示す。 | ||
\ref{chap:comparison}章では、既存の各手法では低消費電力デバイスでの利用が難しいことを示し、WebAssemblyを用いる利点について述べる。 | ||
\ref{chap:implementation}章では、本研究で実装するWebAssemblyランタイムとそれを実行するプログラムについて、設計と実装を示す。 | ||
\ref{chap:evaluation}章では、本研究の実装の有効性を評価し、その結果を考察する。 | ||
\ref{chap:conclusion}章では、本研究の結論についてまとめるとともに、今後の展望を示す。 | ||
\ref{chap:related_works}章では、関連技術として〜。 | ||
\ref{chap:implementation}章では、本研究で実装するWebAssembly実行環境について、設計と実装を示す。 | ||
\ref{chap:evaluation}章では、〜。 | ||
\ref{chap:conclusion}章では、〜。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,57 @@ | ||
\chapter{既存研究} | ||
\chapter{関連技術} | ||
\label{chap:related_works} | ||
|
||
\section{JVM} | ||
\section{WebAssembly} | ||
|
||
\section{CPUエミュレータ} | ||
WebAssemblyは、Google、Microsoft、MozillaおよびAppleの主導によって開発された仮想命令セットである\cite{webassembly}。 | ||
従来、WebブラウザにおいてはECMAScript(JavaScript)が事実上唯一の標準化された実行形式であった。 | ||
しかし、ECMAScriptはスクリプト言語({\it scripting language})として設計された言語であり\cite{ecma2018}、実行速度や実行効率といった面で最適化されていない。 | ||
そこで、WebAssemblyはWebブラウザにおいて高速で安全な実行が可能な形式として設計された。 | ||
|
||
\subsection{バイナリフォーマット} | ||
|
||
\begin{figure}[htbp] | ||
\caption{WebAssemblyバイナリフォーマットの構成} | ||
\label{fig:wasm_module} | ||
\begin{center} | ||
\includegraphics[bb=0 0 800 600,width=12cm]{img/wasm_module.pdf} | ||
\end{center} | ||
\end{figure} | ||
|
||
\paragraph{型} | ||
|
||
i32、i64、f32、f64。 | ||
|
||
\paragraph{関数} | ||
|
||
\paragraph{テーブル} | ||
|
||
外部の関数への参照テーブルのサイズ情報と型情報。 | ||
|
||
\paragraph{エレメント} | ||
|
||
テーブルを初期化するためのデータ。 | ||
|
||
\paragraph{メモリ領域} | ||
|
||
線形なメモリ領域(ヒープ)のサイズ情報。 | ||
|
||
\paragraph{データ} | ||
|
||
メモリ領域を初期化するためのデータ。 | ||
|
||
\paragraph{グローバル変数} | ||
|
||
グローバル変数の初期値。 | ||
|
||
\paragraph{インポート} | ||
|
||
他のモジュールの型/テーブル/メモリ/グローバル変数への参照。 | ||
|
||
\paragraph{エクスポート} | ||
|
||
他のモジュールへ公開する型/テーブル/メモリ/グローバル変数。 | ||
|
||
\subsection{検証} | ||
|
||
\subsection{実行} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
\chapter{設計と実装} | ||
\label{chap:implementation} | ||
|
||
\section{構成} | ||
|
||
本研究において実装したESP32上で動作するプログラムの実装の構成を示す。 | ||
|
||
まず、WebAssembly Core Specification\cite{wasm_spec}により規定された仕様を基に、WebAssemblyインタプリタをライブラリとして実装した(libwasm)。 | ||
libwasmは、標準C(C11)により規定された仕様のみを用いて、プラットフォーム非依存な形で実装した。 | ||
|
||
次に、定数として保持した静的なWebAssemblyバイナリをlibwasmを用いて実行し、結果を出力するだけの簡単なプログラムを、ESP-IDF\cite{esp_idf}を用いてFreeRTOS上に実装した。 | ||
|
||
構成の概観を図\ref{fig:esp32_libwasm}に示した。 | ||
|
||
\begin{figure}[htbp] | ||
\caption{本実装の構成} | ||
\label{fig:esp32_libwasm} | ||
\begin{center} | ||
\includegraphics[bb=0 0 800 300,width=12cm]{img/esp32_libwasm.pdf} | ||
\end{center} | ||
\end{figure} | ||
|
||
\begin{figure}[htbp] | ||
\caption{libwasmの構成} | ||
\label{fig:libwasm_arch} | ||
\begin{center} | ||
\includegraphics[bb=0 0 800 600,width=12cm]{img/libwasm_arch.pdf} | ||
\end{center} | ||
\end{figure} |
Oops, something went wrong.