1 .\" Copyright (c) International Business Machines Corp., 2006
3 .\" %%%LICENSE_START(GPLv2+_SW_3_PARA)
4 .\" This program is free software; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
9 .\" This program is distributed in the hope that it will be useful,
10 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 .\" the GNU General Public License for more details.
14 .\" You should have received a copy of the GNU General Public
15 .\" License along with this manual; if not, see
16 .\" <http://www.gnu.org/licenses/>.
20 .\" 2005-09-28, created by Arnd Bergmann <arndb@de.ibm.com>
21 .\" 2006-06-16, revised by Eduardo M. Fleury <efleury@br.ibm.com>
22 .\" 2007-07-10, some polishing by mtk
23 .\" 2007-09-28, updates for newer kernels, added example
24 .\" by Jeremy Kerr <jk@ozlabs.org>
26 .\"*******************************************************************
28 .\" This file was generated with po4a. Translate the source file.
30 .\"*******************************************************************
31 .TH SPU_RUN 2 2012\-08\-05 Linux "Linux Programmer's Manual"
33 spu_run \- SPU コンテキストを実行する
36 \fB#include <sys/spu.h>\fP
38 \fBint spu_run(int \fP\fIfd\fP\fB, unsigned int *\fP\fInpc\fP\fB, unsigned int *\fP\fIevent\fP\fB);\fP
41 \fI注\fP: このシステムコールには glibc のラッパー関数は存在しない。「注意」の節を参照。
43 \fBspu_run\fP() システムコールは、Cell Broadband Engine アーキテクチャを実装した PowerPC マシンで
44 Synergistic Processor Units (SPU) にアクセスするために 使用される。 \fIfd\fP 引き数は、
45 \fBspu_create\fP(2) が返すファイルディスクリプタで、 特定の SPU コンテキストを参照する。 そのコンテキストが物理 SPU
46 に割り当てられると、 \fInpc\fP で渡された命令ポインタ (instruction pointer) から実行が開始される。
48 SPU コードの実行は同期的 (synchronously) に行われる、つまり SPU が実行中は \fBspu_run\fP() は停止 (block)
49 する。 SPU コードの実行をメイン CPU や他の SPU と並行して行う必要がある場合は、 最初に、その SPU
50 コードを実行する新しいスレッドを、(例えば \fBpthread_create\fP(3) などを使って) 生成しなければならない。
52 \fBspu_run\fP() が返るときには、SPU のプログラムカウンタの現在値が \fInpc\fP に書き込まれる。 これにより、連続する
53 \fBspu_run\fP() の呼び出しで同じ \fInpc\fP ポインタを使うことができる。
55 \fIevent\fP 引き数には、拡張ステータスコード用のバッファを指定する。 \fBSPU_CREATE_EVENTS_ENABLED\fP フラグ付きで
56 SPU コンテキストが作成されると、 \fBspu_run\fP() が返る前に Linux カーネルによりこのバッファに
59 ステータスコードには以下の定数が一つ以上入る。
61 \fBSPE_EVENT_DMA_ALIGNMENT\fP
62 DMA (direct memory access) のアライメント・エラーが発生した。
64 \fBSPE_EVENT_INVALID_DMA\fP
65 無効な MFC (Memory Flow Controller) DMA コマンドを行おうとした。
67 \fBSPE_EVENT_SPE_DATA_STORAGE\fP
70 \fBSPE_EVENT_SPE_ERROR\fP
73 NULL は \fIevent\fP 引き数として有効な値である。 この場合、イベントは呼び出し元のプロセスに報告されない。
75 成功すると、 \fBspu_run\fP() は \fIspu_status\fP レジスタの値を返す。 エラーの場合、\-1 を返し、 \fIerrno\fP
78 \fIspu_status\fP レジスタの値は、ステータスコードと SPU の \fBstop\-and\-signal\fP 命令が返す 14 ビットのコードの
79 ビットマスクで構成される。 後者の 14 ビットのコードはオプションである。 ステータスコードのビットマスクは下記の通りである。
82 SPU が \fBstop\-and\-signal\fP 命令で停止した。
85 SPU が \fBhalt (停止)\fP 命令で止まった。
97 SPU が不正なチャンネルにアクセスしようとした。
100 この値のマスクを適用して得られたビット値には、 stop\-and\-signal 命令から返されたコードが入っている。 これらのビットは 0x02
101 ビットがセットされている場合にのみ有効である。
103 \fBspu_run\fP() がエラーを返さなかった場合、下位 8 ビットのうち 1 つ以上は 常にセットされる。
107 \fIfd\fP が有効なファイルディスクリプタでない。
110 \fInpc\fP が有効なポインタでない。または \fIevent\fP が NULL 以外で、しかも無効なポインタである。
113 \fBspu_run\fP() の実行中にシグナルが発生した。 \fBsignal\fP(7) 参照。 必要であれば、 \fInpc\fP
114 の値は新しいプログラムカウンタの値に更新される。
117 \fIfd\fP が \fBspu_create\fP(2) が返した有効なファイルディスクリプタでない。
120 Memory Flow Controller (MFC) DMA により発生したページフォールトを 処理するのに必要なメモリがなかった。
123 機能が動作中のシステムで提供されていない。理由は、 ハードウェアで SPU が提供されていないか、 spufs
124 モジュールがロードされていないか、のどちらかである。
126 \fBspu_run\fP() システムコールはカーネル 2.6.16 で Linux に追加された。
128 このシステムコールは Linux 固有であり、 PowerPC アーキテクチャでのみ実装されている。
129 このシステムコールを使ったプログラムは移植性がない。
131 glibc はこのシステムコールに対するラッパー関数を提供していない。 \fBsyscall\fP(2) を使うこと。ただし、 \fBspu_run\fP()
132 は より抽象度の高い SPU へのインタフェースを実装するライブラリから 利用されることを意図したものであり、通常のアプリケーションから
133 使用は意図されていない。推奨のライブラリについては
134 .UR http://www.bsc.es\:/projects\:/deepcomputing\:/linuxoncell/
138 以下は、簡単な 1 命令の SPU プログラムを \fBspu_run\fP() システムコールを使って実行させる例である。
145 #include <sys/types.h>
148 #define handle_error(msg) \e
149 do { perror(msg); exit(EXIT_FAILURE); } while (0)
153 int context, fd, spu_status;
154 uint32_t instruction, npc;
156 context = spu_create("/spu/example\-context", 0, 0755);
158 handle_error("spu_create");
160 /* write a \(aqstop 0x1234\(aq instruction to the SPU\(aqs
163 instruction = 0x00001234;
165 fd = open("/spu/example\-context/mem", O_RDWR);
167 handle_error("open");
168 write(fd, &instruction, sizeof(instruction));
170 /* set npc to the starting instruction address of the
171 * SPU program. Since we wrote the instruction at the
172 * start of the mem file, the entry point will be 0x0
176 spu_status = spu_run(context, &npc, NULL);
177 if (spu_status == \-1)
178 handle_error("open");
180 /* we should see a status code of 0x1234002:
181 * 0x00000002 (spu was stopped due to stop\-and\-signal)
182 * | 0x12340000 (the stop\-and\-signal code)
184 printf("SPU Status: 0x%08x\en", spu_status);
190 .\" Arnd Bergmann <arndb@de.ibm.com>, Jeremy Kerr <jk@ozlabs.org>
192 \fBclose\fP(2), \fBspu_create\fP(2), \fBcapabilities\fP(7), \fBspufs\fP(7)
194 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.50 の一部
195 である。プロジェクトの説明とバグ報告に関する情報は
196 http://www.kernel.org/doc/man\-pages/ に書かれている。