scripts/bash_aliases: tfix
[man-pages.git] / man2 / spu_create.2
blob746a86ed6145d4f4dea923ee13ebdf77f486dee1
1 .\" Copyright (c) International Business Machines Corp., 2006
2 .\"
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.
8 .\"
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.
13 .\"
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/>.
17 .\" %%%LICENSE_END
18 .\"
19 .\" HISTORY:
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 by Jeremy Kerr <jk@ozlabs.org>
24 .\"
25 .TH SPU_CREATE 2 2021-03-22 Linux "Linux Programmer's Manual"
26 .SH NAME
27 spu_create \- create a new spu context
28 .SH SYNOPSIS
29 .nf
30 .BR "#include <sys/spu.h>" "          /* Definition of " SPU_* " constants */"
31 .BR "#include <sys/syscall.h>" "      /* Definition of " SYS_* " constants */"
32 .B #include <unistd.h>
33 .PP
34 .BI "int syscall(SYS_spu_create, const char *" pathname \
35 ", unsigned int " flags ,
36 .BI "            mode_t " mode ", int " neighbor_fd );
37 .fi
38 .PP
39 .IR Note :
40 glibc provides no wrapper for
41 .BR spu_create (),
42 necessitating the use of
43 .BR syscall (2).
44 .SH DESCRIPTION
45 The
46 .BR spu_create ()
47 system call is used on PowerPC machines that implement the
48 Cell Broadband Engine Architecture in order to access Synergistic
49 Processor Units (SPUs).
50 It creates a new logical context for an SPU in
51 .I pathname
52 and returns a file descriptor associated with it.
53 .I pathname
54 must refer to a nonexistent directory in the mount point of
55 the SPU filesystem
56 .RB ( spufs ).
58 .BR spu_create ()
59 is successful, a directory is created at
60 .I pathname
61 and it is populated with the files described in
62 .BR spufs (7).
63 .PP
64 When a context is created,
65 the returned file descriptor can only be passed to
66 .BR spu_run (2),
67 used as the
68 .I dirfd
69 argument to the
70 .B *at
71 family of system calls (e.g.,
72 .BR openat (2)),
73 or closed;
74 other operations are not defined.
75 A logical SPU
76 context is destroyed (along with all files created within the context's
77 .I pathname
78 directory) once the last reference to the context has gone;
79 this usually occurs when the file descriptor returned by
80 .BR spu_create ()
81 is closed.
82 .PP
83 The
84 .I mode
85 argument (minus any bits set in the process's
86 .BR umask (2))
87 specifies the permissions used for creating the new directory in
88 .BR spufs .
89 See
90 .BR stat (2)
91 for a full list of the possible
92 .I mode
93 values.
94 .PP
95 The
96 .I neighbor_fd
97 is used only when the
98 .B SPU_CREATE_AFFINITY_SPU
99 flag is specified; see below.
102 .I flags
103 argument can be zero or any bitwise OR-ed
104 combination of the following constants:
106 .B SPU_CREATE_EVENTS_ENABLED
107 Rather than using signals for reporting DMA errors, use the
108 .I event
109 argument to
110 .BR spu_run (2).
112 .B SPU_CREATE_GANG
113 Create an SPU gang instead of a context.
114 (A gang is a group of SPU contexts that are
115 functionally related to each other and which share common scheduling
116 parameters\(empriority and policy.
117 In the future, gang scheduling may be implemented causing
118 the group to be switched in and out as a single unit.)
120 A new directory will be created at the location specified by the
121 .I pathname
122 argument.
123 This gang may be used to hold other SPU contexts, by providing
124 a pathname that is within the gang directory to further calls to
125 .BR spu_create ().
127 .B SPU_CREATE_NOSCHED
128 Create a context that is not affected by the SPU scheduler.
129 Once the context is run,
130 it will not be scheduled out until it is destroyed by
131 the creating process.
133 Because the context cannot be removed from the SPU, some functionality
134 is disabled for
135 .BR SPU_CREATE_NOSCHED
136 contexts.
137 Only a subset of the files will be
138 available in this context directory in
139 .BR spufs .
140 Additionally,
141 .BR SPU_CREATE_NOSCHED
142 contexts cannot dump a core file when crashing.
144 Creating
145 .BR SPU_CREATE_NOSCHED
146 contexts requires the
147 .B CAP_SYS_NICE
148 capability.
150 .B SPU_CREATE_ISOLATE
151 Create an isolated SPU context.
152 Isolated contexts are protected from some
153 PPE (PowerPC Processing Element)
154 operations,
155 such as access to the SPU local store and the NPC register.
157 Creating
158 .B SPU_CREATE_ISOLATE
159 contexts also requires the
160 .B SPU_CREATE_NOSCHED
161 flag.
163 .BR SPU_CREATE_AFFINITY_SPU " (since Linux 2.6.23)"
164 .\" commit 8e68e2f248332a9c3fd4f08258f488c209bd3e0c
165 Create a context with affinity to another SPU context.
166 This affinity information is used within the SPU scheduling algorithm.
167 Using this flag requires that a file descriptor referring to
168 the other SPU context be passed in the
169 .I neighbor_fd
170 argument.
172 .BR SPU_CREATE_AFFINITY_MEM " (since Linux 2.6.23)"
173 .\" commit 8e68e2f248332a9c3fd4f08258f488c209bd3e0c
174 Create a context with affinity to system memory.
175 This affinity information
176 is used within the SPU scheduling algorithm.
177 .SH RETURN VALUE
178 On success,
179 .BR spu_create ()
180 returns a new file descriptor.
181 On failure, \-1 is returned, and
182 .I errno
183 is set to indicate the error.
184 .SH ERRORS
186 .B EACCES
187 The current user does not have write access to the
188 .BR spufs (7)
189 mount point.
191 .B EEXIST
192 An SPU context already exists at the given pathname.
194 .B EFAULT
195 .I pathname
196 is not a valid string pointer in the
197 calling process's address space.
199 .B EINVAL
200 .I pathname
201 is not a directory in the
202 .BR spufs (7)
203 mount point, or invalid flags have been provided.
205 .B ELOOP
206 Too many symbolic links were found while resolving
207 .IR pathname .
209 .B EMFILE
210 The per-process limit on the number of open file descriptors has been reached.
212 .B ENAMETOOLONG
213 .I pathname
214 is too long.
216 .B ENFILE
217 The system-wide limit on the total number of open files has been reached.
219 .B ENODEV
220 An isolated context was requested, but the hardware does not support
221 SPU isolation.
223 .B ENOENT
224 Part of
225 .I pathname
226 could not be resolved.
228 .B ENOMEM
229 The kernel could not allocate all resources required.
231 .B ENOSPC
232 There are not enough SPU resources available to create
233 a new context or the user-specific limit for the number
234 of SPU contexts has been reached.
236 .B ENOSYS
237 The functionality is not provided by the current system, because
238 either the hardware does not provide SPUs or the spufs module is not
239 loaded.
241 .B ENOTDIR
242 A part of
243 .I pathname
244 is not a directory.
246 .B EPERM
248 .B SPU_CREATE_NOSCHED
249 flag has been given, but the user does not have the
250 .B CAP_SYS_NICE
251 capability.
252 .SH FILES
253 .I pathname
254 must point to a location beneath the mount point of
255 .BR spufs .
256 By convention, it gets mounted in
257 .IR /spu .
258 .SH VERSIONS
260 .BR spu_create ()
261 system call was added to Linux in kernel 2.6.16.
262 .SH CONFORMING TO
263 This call is Linux-specific and implemented only on the PowerPC
264 architecture.
265 Programs using this system call are not portable.
266 .SH NOTES
267 .BR spu_create ()
268 is meant to be used from libraries that implement a more abstract
269 interface to SPUs, not to be used from regular applications.
271 .UR http://www.bsc.es\:/projects\:/deepcomputing\:/linuxoncell/
273 for the recommended libraries.
275 Prior to the addition of the
276 .B SPU_CREATE_AFFINITY_SPU
277 flag in Linux 2.6.23, the
278 .BR spu_create ()
279 system call took only three arguments (i.e., there was no
280 .I neighbor_fd
281 argument).
282 .SH EXAMPLES
284 .BR spu_run (2)
285 for an example of the use of
286 .BR spu_create ()
287 .SH SEE ALSO
288 .BR close (2),
289 .BR spu_run (2),
290 .BR capabilities (7),
291 .BR spufs (7)