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

Side by Side Diff: native_client_sdk/doc_generated/reference/pnacl-c-cpp-language-support.html

Issue 255813009: PNaCl SIMD documentation: improve documentation on casts and __builtin_convertvector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Number of elements must match. Created 6 years, 7 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 | « no previous file | native_client_sdk/src/doc/reference/pnacl-c-cpp-language-support.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {{+bindTo:partials.standard_nacl_article}} 1 {{+bindTo:partials.standard_nacl_article}}
2 2
3 <section id="pnacl-c-c-language-support"> 3 <section id="pnacl-c-c-language-support">
4 <h1 id="pnacl-c-c-language-support">PNaCl C/C++ Language Support</h1> 4 <h1 id="pnacl-c-c-language-support">PNaCl C/C++ Language Support</h1>
5 <div class="contents local" id="contents" style="display: none"> 5 <div class="contents local" id="contents" style="display: none">
6 <ul class="small-gap"> 6 <ul class="small-gap">
7 <li><p class="first"><a class="reference internal" href="#source-language-suppor t" id="id3">Source language support</a></p> 7 <li><p class="first"><a class="reference internal" href="#source-language-suppor t" id="id3">Source language support</a></p>
8 <ul class="small-gap"> 8 <ul class="small-gap">
9 <li><a class="reference internal" href="#versions" id="id4">Versions</a></li> 9 <li><a class="reference internal" href="#versions" id="id4">Versions</a></li>
10 <li><a class="reference internal" href="#preprocessor-definitions" id="id5">Prep rocessor definitions</a></li> 10 <li><a class="reference internal" href="#preprocessor-definitions" id="id5">Prep rocessor definitions</a></li>
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 of Chrome, and more features are expected to be added in subsequent 196 of Chrome, and more features are expected to be added in subsequent
197 releases.</p> 197 releases.</p>
198 <section id="hand-coding-vector-extensions"> 198 <section id="hand-coding-vector-extensions">
199 <h3 id="hand-coding-vector-extensions">Hand-Coding Vector Extensions</h3> 199 <h3 id="hand-coding-vector-extensions">Hand-Coding Vector Extensions</h3>
200 <p>The initial vector support in Portable Native Client adds <a class="reference external" href="http://clang.llvm.org/docs/LanguageExtensions.html#vectors-and- extended-vectors">LLVM vectors</a> 200 <p>The initial vector support in Portable Native Client adds <a class="reference external" href="http://clang.llvm.org/docs/LanguageExtensions.html#vectors-and- extended-vectors">LLVM vectors</a>
201 and <a class="reference external" href="http://gcc.gnu.org/onlinedocs/gcc/Vector -Extensions.html">GCC vectors</a> since these 201 and <a class="reference external" href="http://gcc.gnu.org/onlinedocs/gcc/Vector -Extensions.html">GCC vectors</a> since these
202 are well supported by different hardware platforms and don&#8217;t require any 202 are well supported by different hardware platforms and don&#8217;t require any
203 new compiler intrinsics.</p> 203 new compiler intrinsics.</p>
204 <p>Vector types can be used through the <code>vector_size</code> attribute:</p> 204 <p>Vector types can be used through the <code>vector_size</code> attribute:</p>
205 <pre class="prettyprint"> 205 <pre class="prettyprint">
206 typedef int v4si __attribute__((vector_size(16))); 206 typedef int v4s __attribute__((vector_size(16)));
207 v4si a = {1,2,3,4}; 207 v4s a = {1,2,3,4};
208 v4si b = {5,6,7,8}; 208 v4s b = {5,6,7,8};
209 v4si c, d, e; 209 v4s c, d, e;
210 c = b + 1; /* c = b + {1,1,1,1}; */ 210 c = b + 1; /* c = b + {1,1,1,1}; */
211 d = 2 * b; /* d = {2,2,2,2} * b; */ 211 d = 2 * b; /* d = {2,2,2,2} * b; */
212 e = c + d; 212 e = c + d;
213 </pre> 213 </pre>
214 <p>Vector comparisons are represented as a bitmask as wide as the compared 214 <p>Vector comparisons are represented as a bitmask as wide as the compared
215 elements of all <code>0</code> or all <code>1</code>:</p> 215 elements of all <code>0</code> or all <code>1</code>:</p>
216 <pre class="prettyprint"> 216 <pre class="prettyprint">
217 typedef int v4si __attribute__((vector_size(16))); 217 typedef int v4s __attribute__((vector_size(16)));
218 v4si snip(v2si in) { 218 v4s snip(v4s in) {
219 v4si limit = {32,64,128,256}; 219 v4s limit = {32,64,128,256};
220 vs4i mask = in &gt; limit; 220 v4s mask = in &gt; limit;
221 vs4i ret = in &amp; mask; 221 v4s ret = in &amp; mask;
222 return ret; 222 return ret;
223 } 223 }
224 </pre> 224 </pre>
225 <p>Vector datatypes are currently expected to be 128-bit wide with one of 225 <p>Vector datatypes are currently expected to be 128-bit wide with one of
226 the following element types:</p> 226 the following element types:</p>
227 <table border="1" class="docutils"> 227 <table border="1" class="docutils">
228 <colgroup> 228 <colgroup>
229 </colgroup> 229 </colgroup>
230 <thead valign="bottom"> 230 <thead valign="bottom">
231 <tr class="row-odd"><th class="head">Type</th> 231 <tr class="row-odd"><th class="head">Type</th>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 <tr class="row-odd"><td><code>&gt;&gt;</code>, <code>&lt;&lt;</code></td> 282 <tr class="row-odd"><td><code>&gt;&gt;</code>, <code>&lt;&lt;</code></td>
283 </tr> 283 </tr>
284 <tr class="row-even"><td><code>!</code>, <code>&amp;&amp;</code>, <code>||</code ></td> 284 <tr class="row-even"><td><code>!</code>, <code>&amp;&amp;</code>, <code>||</code ></td>
285 </tr> 285 </tr>
286 <tr class="row-odd"><td><code>==</code>, <code>!=</code>, <code>&gt;</code>, <co de>&lt;</code>, <code>&gt;=</code>, <code>&lt;=</code></td> 286 <tr class="row-odd"><td><code>==</code>, <code>!=</code>, <code>&gt;</code>, <co de>&lt;</code>, <code>&gt;=</code>, <code>&lt;=</code></td>
287 </tr> 287 </tr>
288 <tr class="row-even"><td><code>=</code></td> 288 <tr class="row-even"><td><code>=</code></td>
289 </tr> 289 </tr>
290 </tbody> 290 </tbody>
291 </table> 291 </table>
292 <p>Furthermore, C-style casts can be used for:</p> 292 <p>C-style casts can be used to convert one vector type to another without
293 <ul class="small-gap"> 293 modifying the underlying bits. <code>__builtin_convertvector</code> can be used
294 <li>Truncation.</li> 294 to convert from one type to another provided both types have the same
295 <li>Zero- and sign-extension.</li> 295 number of elements, truncating when converting from floating-point to
296 <li>Conversion to/from floating-point and signed/unsigned integer.</li> 296 integer.</p>
297 </ul> 297 <pre class="prettyprint">
298 typedef unsigned v4u __attribute__((vector_size(16)));
299 typedef float v4f __attribute__((vector_size(16)));
300 v4u a = {0x3f19999a,0x40000000,0x40490fdb,0x66ff0c30};
301 v4f b = (v4f) a; /* b = {0.6,2,3.14159,6.02214e+23} */
302 v4u c = __builtin_convertvector(b, v4u); /* c = {0,2,3,0} */
303 </pre>
298 <p>It is also possible to use array-style indexing into vectors to extract 304 <p>It is also possible to use array-style indexing into vectors to extract
299 individual elements using <code>[]</code>.</p> 305 individual elements using <code>[]</code>.</p>
306 <pre class="prettyprint">
307 typedef unsigned v4u __attribute__((vector_size(16)));
308 template&lt;typename T&gt;
309 void print(const T v) {
310 for (size_t i = 0; i != sizeof(v) / sizeof(v[0]); ++i)
311 std::cout &lt;&lt; v[i] &lt;&lt; ' ';
312 std::cout &lt;&lt; std::endl;
313 }
314 </pre>
300 <p>Vector shuffles are currently unsupported but will be added soon.</p> 315 <p>Vector shuffles are currently unsupported but will be added soon.</p>
301 </section><section id="auto-vectorization"> 316 </section><section id="auto-vectorization">
302 <h3 id="auto-vectorization">Auto-Vectorization</h3> 317 <h3 id="auto-vectorization">Auto-Vectorization</h3>
303 <p>Auto-vectorization is currently not enabled for Portable Native Client, 318 <p>Auto-vectorization is currently not enabled for Portable Native Client,
304 but will be in a future release.</p> 319 but will be in a future release.</p>
305 </section></section><section id="undefined-behavior"> 320 </section></section><section id="undefined-behavior">
306 <h2 id="undefined-behavior">Undefined Behavior</h2> 321 <h2 id="undefined-behavior">Undefined Behavior</h2>
307 <p>The C and C++ languages expose some undefined behavior which is 322 <p>The C and C++ languages expose some undefined behavior which is
308 discussed in <a class="reference internal" href="/native-client/reference/pnacl- undefined-behavior.html#undefined-behavior"><em>PNaCl Undefined Behavior</em></a >.</p> 323 discussed in <a class="reference internal" href="/native-client/reference/pnacl- undefined-behavior.html#undefined-behavior"><em>PNaCl Undefined Behavior</em></a >.</p>
309 </section><section id="floating-point"> 324 </section><section id="floating-point">
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 <p>Neither PNaCl nor NaCl currently support asynchronous interruption 390 <p>Neither PNaCl nor NaCl currently support asynchronous interruption
376 or suspension of threads.</p> 391 or suspension of threads.</p>
377 </li> 392 </li>
378 </ul> 393 </ul>
379 <p>If PNaCl were to support either of these, the interaction of 394 <p>If PNaCl were to support either of these, the interaction of
380 <code>volatile</code> and atomics with same-thread signal handling would need 395 <code>volatile</code> and atomics with same-thread signal handling would need
381 to be carefully detailed.</p> 396 to be carefully detailed.</p>
382 </section></section></section> 397 </section></section></section>
383 398
384 {{/partials.standard_nacl_article}} 399 {{/partials.standard_nacl_article}}
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/doc/reference/pnacl-c-cpp-language-support.rst » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698