Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Side by Side Diff: native_client_sdk/src/doc/reference/pnacl-c-cpp-language-support.rst

Issue 419803005: PNaCl documentation: clarify vector alignment, and update navigation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « native_client_sdk/doc_generated/reference/pnacl-c-cpp-language-support.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ============================ 1 ============================
2 PNaCl C/C++ Language Support 2 PNaCl C/C++ Language Support
3 ============================ 3 ============================
4 4
5 .. contents:: 5 .. contents::
6 :local: 6 :local:
7 :backlinks: none 7 :backlinks: none
8 :depth: 3 8 :depth: 3
9 9
10 Source language support 10 Source language support
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 Portable SIMD Vectors 209 Portable SIMD Vectors
210 ===================== 210 =====================
211 211
212 SIMD vectors aren't part of the C/C++ standards and are traditionally 212 SIMD vectors aren't part of the C/C++ standards and are traditionally
213 very hardware-specific. Portable Native Client offers a portable version 213 very hardware-specific. Portable Native Client offers a portable version
214 of SIMD vector datatypes and operations which map well to modern 214 of SIMD vector datatypes and operations which map well to modern
215 architectures and offer performance which matches or approaches 215 architectures and offer performance which matches or approaches
216 hardware-specific uses. 216 hardware-specific uses.
217 217
218 SIMD vector support was added to Portable Native Client for version 37 218 SIMD vector support was added to Portable Native Client for version 37 of Chrome
219 of Chrome and more features, including performance enhancements, are 219 and more features, including performance enhancements, have been added in
220 expected to be added in subsequent releases. 220 subsequent releases, see the :ref:`Release Notes <sdk-release-notes>` for more
221 details.
221 222
222 Hand-Coding Vector Extensions 223 Hand-Coding Vector Extensions
223 ----------------------------- 224 -----------------------------
224 225
225 The initial vector support in Portable Native Client adds `LLVM vectors 226 The initial vector support in Portable Native Client adds `LLVM vectors
226 <http://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors >`_ 227 <http://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors >`_
227 and `GCC vectors 228 and `GCC vectors
228 <http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html>`_ since these 229 <http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html>`_ since these
229 are well supported by different hardware platforms and don't require any 230 are well supported by different hardware platforms and don't require any
230 new compiler intrinsics. 231 new compiler intrinsics.
(...skipping 16 matching lines...) Expand all
247 .. naclcode:: 248 .. naclcode::
248 249
249 typedef int v4s __attribute__((vector_size(16))); 250 typedef int v4s __attribute__((vector_size(16)));
250 v4s snip(v4s in) { 251 v4s snip(v4s in) {
251 v4s limit = {32,64,128,256}; 252 v4s limit = {32,64,128,256};
252 v4s mask = in > limit; 253 v4s mask = in > limit;
253 v4s ret = in & mask; 254 v4s ret = in & mask;
254 return ret; 255 return ret;
255 } 256 }
256 257
257 Vector datatypes are currently expected to be 128-bit wide with one of 258 Vector datatypes are currently expected to be 128-bit wide with one of the
258 the following element types: 259 following element types, and they're expected to be aligned to the underlying
260 element's bit width (loads and store will otherwise be broken up into scalar
261 accesses to prevent faults):
259 262
260 ============ ============ ================ 263 ============ ============ ================ ======================
261 Type Num Elements Vector Bit Width 264 Type Num Elements Vector Bit Width Expected Bit Alignment
262 ============ ============ ================ 265 ============ ============ ================ ======================
263 ``uint8_t`` 16 128 266 ``uint8_t`` 16 128 8
264 ``int8_t`` 16 128 267 ``int8_t`` 16 128 8
265 ``uint16_t`` 8 128 268 ``uint16_t`` 8 128 16
266 ``int16_t`` 8 128 269 ``int16_t`` 8 128 16
267 ``uint32_t`` 4 128 270 ``uint32_t`` 4 128 32
268 ``int32_t`` 4 128 271 ``int32_t`` 4 128 32
269 ``float`` 4 128 272 ``float`` 4 128 32
270 ============ ============ ================ 273 ============ ============ ================ ======================
271 274
272 64-bit integers and double-precision floating point will be supported in 275 64-bit integers and double-precision floating point will be supported in
273 a future release, as will 256-bit and 512-bit vectors. 276 a future release, as will 256-bit and 512-bit vectors.
274 277
278 Vector element bit width alignment can be stated explicitly (this is assumed by
279 PNaCl, but not necessarily by other compilers), and smaller alignments can also
280 be specified:
281
282 .. naclcode::
283
284 typedef int v4s_element __attribute__((vector_size(16), aligned(4)));
285 typedef int v4s_unaligned __attribute__((vector_size(16), aligned(1)));
286
287
275 The following operators are supported on vectors: 288 The following operators are supported on vectors:
276 289
277 +----------------------------------------------+ 290 +----------------------------------------------+
278 | unary ``+``, ``-`` | 291 | unary ``+``, ``-`` |
279 +----------------------------------------------+ 292 +----------------------------------------------+
280 | ``++``, ``--`` | 293 | ``++``, ``--`` |
281 +----------------------------------------------+ 294 +----------------------------------------------+
282 | ``+``, ``-``, ``*``, ``/``, ``%`` | 295 | ``+``, ``-``, ``*``, ``/``, ``%`` |
283 +----------------------------------------------+ 296 +----------------------------------------------+
284 | ``&``, ``|``, ``^``, ``~`` | 297 | ``&``, ``|``, ``^``, ``~`` |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 A similar feature is **thread suspension**: The ability to 467 A similar feature is **thread suspension**: The ability to
455 asynchronously suspend and resume a thread and inspect or modify its 468 asynchronously suspend and resume a thread and inspect or modify its
456 execution state (such as register state). 469 execution state (such as register state).
457 470
458 Neither PNaCl nor NaCl currently support asynchronous interruption 471 Neither PNaCl nor NaCl currently support asynchronous interruption
459 or suspension of threads. 472 or suspension of threads.
460 473
461 If PNaCl were to support either of these, the interaction of 474 If PNaCl were to support either of these, the interaction of
462 ``volatile`` and atomics with same-thread signal handling would need 475 ``volatile`` and atomics with same-thread signal handling would need
463 to be carefully detailed. 476 to be carefully detailed.
OLDNEW
« no previous file with comments | « native_client_sdk/doc_generated/reference/pnacl-c-cpp-language-support.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698