File: spu_run.2

package info (click to toggle)
manpages-ja 0.5.0.0.20120606-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 25,964 kB
  • sloc: perl: 161; makefile: 116
file content (191 lines) | stat: -rw-r--r-- 8,727 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
.\" Copyright (c) International Business Machines Corp., 2006
.\"
.\" This program is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
.\" the GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program; if not, write to the Free Software
.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston,
.\" MA 02111-1307 USA
.\"
.\" HISTORY:
.\" 2005-09-28, created by Arnd Bergmann <arndb@de.ibm.com>
.\" 2006-06-16, revised by Eduardo M. Fleury <efleury@br.ibm.com>
.\" 2007-07-10, some polishing by mtk
.\" 2007-09-28, updates for newer kernels, added example
.\"             by Jeremy Kerr <jk@ozlabs.org>
.\"
.\"*******************************************************************
.\"
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
.TH SPU_RUN 2 2007\-11\-25 Linux "Linux Programmer's Manual"
.SH 名前
spu_run \- SPU コンテキストを実行する
.SH 書式
.nf
\fB#include <sys/spu.h>\fP

\fBint spu_run(int \fP\fIfd\fP\fB, unsigned int *\fP\fInpc\fP\fB, unsigned int *\fP\fIevent\fP\fB);\fP
.fi
.SH 説明
\fBspu_run\fP()  システムコールは、Cell Broadband Engine アーキテクチャを実装した PowerPC マシンで
Synergistic Processor Units (SPU) にアクセスするために 使用される。 \fIfd\fP 引き数は、
\fBspu_create\fP(2)  が返すファイルディスクリプタで、 特定の SPU コンテキストを参照する。 そのコンテキストが物理 SPU
に割り当てられると、 \fInpc\fP で渡された命令ポインタ (instruction pointer) から実行が開始される。

SPU コードの実行は同期的 (synchronously) に行われる、つまり SPU が実行中は \fBspu_run\fP()  は停止 (block)
する。 SPU コードの実行をメイン CPU や他の SPU と並行して行う必要がある場合は、 最初に、その SPU
コードを実行する新しいスレッドを、(例えば \fBpthread_create\fP(3)  などを使って) 生成しなければならない。

\fBspu_run\fP()  が返るときには、SPU のプログラムカウンタの現在値が \fInpc\fP に書き込まれる。 これにより、連続する
\fBspu_run\fP()  の呼び出しで同じ \fInpc\fP ポインタを使うことができる。

\fIevent\fP 引き数には、拡張ステータスコード用のバッファを指定する。 \fBSPU_CREATE_EVENTS_ENABLED\fP フラグ付きで
SPU コンテキストが作成されると、 \fBspu_run\fP()  が返る前に Linux カーネルによりこのバッファに
拡張ステータスコードが格納される。

ステータスコードには以下の定数が一つ以上入る。
.TP 
\fBSPE_EVENT_DMA_ALIGNMENT\fP
DMA (direct memory access) のアライメント・エラーが発生した。
.TP 
\fBSPE_EVENT_INVALID_DMA\fP
無効な MFC (Memory Flow Controller) DMA コマンドを行おうとした。
.TP 
\fBSPE_EVENT_SPE_DATA_STORAGE\fP
DMA ストレージ・エラーが発生した。
.TP 
\fBSPE_EVENT_SPE_ERROR\fP
不正な命令が実行された。
.PP
NULL は \fIevent\fP 引き数として有効な値である。 この場合、イベントは呼び出し元のプロセスに報告されない。
.SH 返り値
成功すると、 \fBspu_run\fP()  は \fIspu_status\fP レジスタの値を返す。 エラーの場合、\-1 を返し、 \fIerrno\fP
を下記のエラーコードのいずれかに設定する。

\fIspu_status\fP レジスタの値は、ステータスコードと SPU の \fBstop\-and\-signal\fP 命令が返す 14 ビットのコードの
ビットマスクで構成される。 後者の 14 ビットのコードはオプションである。 ステータスコードのビットマスクは下記の通りである。
.TP 
\fB0x02\fP
SPU が \fBstop\-and\-signal\fP 命令で停止した。
.TP 
\fB0x04\fP
SPU が \fBhalt (停止)\fP 命令で止まった。
.TP 
\fB0x08\fP
SPU はチャンネルのウェイト中である。
.TP 
\fB0x10\fP
SPU はシングルステップモードであった。
.TP 
\fB0x20\fP
SPU が不正な命令を実行しようとした。
.TP 
\fB0x40\fP
SPU が不正なチャンネルにアクセスしようとした。
.TP 
\fB0x3fff0000\fP
この値のマスクを適用して得られたビット値には、 stop\-and\-signal 命令から返されたコードが入っている。 これらのビットは 0x02
ビットがセットされている場合にのみ有効である。
.PP
\fBspu_run\fP()  がエラーを返さなかった場合、下位 8 ビットのうち 1 つ以上は 常にセットされる。
.SH エラー
.TP 
\fBEBADF\fP
\fIfd\fP が有効なファイルディスクリプタでない。
.TP 
\fBEFAULT\fP
\fInpc\fP が有効なポインタでない。または \fIevent\fP が NULL 以外で、しかも無効なポインタである。
.TP 
\fBEINTR\fP
\fBspu_run\fP()  の実行中にシグナルが発生した。 \fBsignal\fP(7)  参照。 必要であれば、 \fInpc\fP
の値は新しいプログラムカウンタの値に更新される。
.TP 
\fBEINVAL\fP
\fIfd\fP が \fBspu_create\fP(2)  が返した有効なファイルディスクリプタでない。
.TP 
\fBENOMEM\fP
Memory Flow Controller (MFC) DMA により発生したページフォールトを 処理するのに必要なメモリがなかった。
.TP 
\fBENOSYS\fP
機能が動作中のシステムで提供されていない。理由は、 ハードウェアで SPU が提供されていないか、 spufs
モジュールがロードされていないか、のどちらかである。
.SH バージョン
\fBspu_run\fP()  システムコールはカーネル 2.6.16 で Linux に追加された。
.SH 準拠
このシステムコールは Linux 固有であり、 PowerPC アーキテクチャでのみ実装されている。
このシステムコールを使ったプログラムは移植性がない。
.SH 注意
glibc はこのシステムコールに対するラッパー関数を提供していない。 \fBsyscall\fP(2)  を使うこと。ただし、 \fBspu_run\fP()
は より抽象度の高い SPU へのインタフェースを実装するライブラリから 利用されることを意図したものであり、通常のアプリケーションから
使用は意図されていない。推奨のライブラリについては
\fIhttp://www.bsc.es/projects/deepcomputing/linuxoncell/\fP を参照のこと。
.SH 例
以下は、簡単な 1 命令の SPU プログラムを \fBspu_run\fP()  システムコールを使って実行させる例である。

.nf
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>

#define handle_error(msg) \e
    do { perror(msg); exit(EXIT_FAILURE); } while (0)

int main(void)
{
    int context, fd, spu_status;
    uint32_t instruction, npc;

    context = spu_create("/spu/example\-context", 0, 0755);
    if (context == \-1)
        handle_error("spu_create");

    /* write a \(aqstop 0x1234\(aq instruction to the SPU\(aqs
     * local store memory
     */
    instruction = 0x00001234;

    fd = open("/spu/example\-context/mem", O_RDWR);
    if (fd == \-1)
        handle_error("open");
    write(fd, &instruction, sizeof(instruction));

    /* set npc to the starting instruction address of the
     * SPU program. Since we wrote the instruction at the
     * start of the mem file, the entry point will be 0x0
     */
    npc = 0;

    spu_status = spu_run(context, &npc, NULL);
    if (spu_status == \-1)
        handle_error("open");

    /* we should see a status code of 0x1234002:
     *   0x00000002 (spu was stopped due to stop\-and\-signal)
     * | 0x12340000 (the stop\-and\-signal code)
     */
    printf("SPU Status: 0x%08x\en", spu_status);

    exit(EXIT_SUCCESS);
}
.fi
.\" .SH AUTHORS
.\" Arnd Bergmann <arndb@de.ibm.com>, Jeremy Kerr <jk@ozlabs.org>
.SH 関連項目
\fBclose\fP(2), \fBspu_create\fP(2), \fBcapabilities\fP(7), \fBspufs\fP(7)
.SH この文書について
この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.41 の一部
である。プロジェクトの説明とバグ報告に関する情報は
http://www.kernel.org/doc/man\-pages/ に書かれている。