Skip to content

Commit

Permalink
Update documentation for branch main
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jul 17, 2024
1 parent d1f4ca5 commit 17346f1
Show file tree
Hide file tree
Showing 33 changed files with 293 additions and 281 deletions.
4 changes: 2 additions & 2 deletions main/dsppp_building.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="md_src_building"></a> </p>
<h1><a class="anchor" id="autotoc_md31"></a>
<h1><a class="anchor" id="autotoc_md32"></a>
To build</h1>
<p>First time:</p>
<div class="fragment"><div class="line">cbuild -O cprj test.csolution.yml --toolchain AC6 -c example.Release+VHT-Corstone-300 -p -r --update-rte</div>
</div><!-- fragment --><p>Other times:</p>
<div class="fragment"><div class="line">cbuild -O cprj test.csolution.yml --toolchain AC6 -c example.Release+VHT-Corstone-300</div>
</div><!-- fragment --><p>If you want to select another test, edit the file <code>example.cproject.yml</code> and uncomment the test.</p>
<h1><a class="anchor" id="autotoc_md32"></a>
<h1><a class="anchor" id="autotoc_md33"></a>
To run</h1>
<p>If the tools have been installed with <code>vcpkg</code>:</p>
<div class="fragment"><div class="line">FVP_Corstone_SSE-300_Ethos-U55.exe -f fvp_configs/VHT-Corstone-300.txt -a cpu0=cprj\out\example\VHT-Corstone-300\Release\example.axf</div>
Expand Down
4 changes: 2 additions & 2 deletions main/dsppp_intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="md_src_introduction"></a> </p>
<h2><a class="anchor" id="autotoc_md5"></a>
<h2><a class="anchor" id="autotoc_md6"></a>
Dot product example</h2>
<p>If you want to compute the dot product:</p>
<p class="formulaDsp">
Expand All @@ -157,7 +157,7 @@ <h2><a class="anchor" id="autotoc_md5"></a>
<p>With this new C++ template library, you can write:</p>
<div class="fragment"><div class="line">r = dot(scale*(a+b),c*d);</div>
</div><!-- fragment --><p>The code generated by this line computes the dot product in one pass with all the operators (<code>+</code>, <code>*</code>) included in the loop. There is no more any temporary buffers.</p>
<h2><a class="anchor" id="autotoc_md6"></a>
<h2><a class="anchor" id="autotoc_md7"></a>
Vector operations</h2>
<p>Let's look at another example:</p>
<p class="formulaDsp">
Expand Down
52 changes: 26 additions & 26 deletions main/dsppp_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,47 @@ var dsppp_main =
[
[ "Introduction", "dsppp_intro.html", null ],
[ "What you need to know about C++ templates", "dsppp_template.html", [
[ "What is a template useful for ?", "dsppp_template.html#autotoc_md7", null ],
[ "Templates for datatypes", "dsppp_template.html#autotoc_md8", null ],
[ "Implicit parameters", "dsppp_template.html#autotoc_md9", null ],
[ "How to use templates ?", "dsppp_template.html#autotoc_md10", null ],
[ "Example", "dsppp_template.html#autotoc_md11", null ]
[ "What is a template useful for ?", "dsppp_template.html#autotoc_md8", null ],
[ "Templates for datatypes", "dsppp_template.html#autotoc_md9", null ],
[ "Implicit parameters", "dsppp_template.html#autotoc_md10", null ],
[ "How to use templates ?", "dsppp_template.html#autotoc_md11", null ],
[ "Example", "dsppp_template.html#autotoc_md12", null ]
] ],
[ "Vector operation example", "dsppp_vector_example.html", [
[ "Include the headers", "dsppp_vector_example.html#autotoc_md12", null ],
[ "Creation of the vectors", "dsppp_vector_example.html#autotoc_md13", null ],
[ "Initialization of the vectors", "dsppp_vector_example.html#autotoc_md14", null ],
[ "Computation", "dsppp_vector_example.html#autotoc_md15", null ],
[ "Displaying the result", "dsppp_vector_example.html#autotoc_md16", null ]
[ "Include the headers", "dsppp_vector_example.html#autotoc_md13", null ],
[ "Creation of the vectors", "dsppp_vector_example.html#autotoc_md14", null ],
[ "Initialization of the vectors", "dsppp_vector_example.html#autotoc_md15", null ],
[ "Computation", "dsppp_vector_example.html#autotoc_md16", null ],
[ "Displaying the result", "dsppp_vector_example.html#autotoc_md17", null ]
] ],
[ "Memory allocation", "dsppp_memory_allocator.html", null ],
[ "Static / dynamic", "dsppp_memory_static_dynamic.html", [
[ "Static objects", "dsppp_memory_static_dynamic.html#autotoc_md17", null ],
[ "Dynamic objects", "dsppp_memory_static_dynamic.html#autotoc_md18", null ]
[ "Static objects", "dsppp_memory_static_dynamic.html#autotoc_md18", null ],
[ "Dynamic objects", "dsppp_memory_static_dynamic.html#autotoc_md19", null ]
] ],
[ "Code size", "dsppp_code_size.html", null ],
[ "Fusion", "dsppp_fusion.html", null ],
[ "Vector", "dsppp_vector.html", [
[ "Q15 example", "dsppp_vector.html#autotoc_md19", null ],
[ "VectorView", "dsppp_vector.html#autotoc_md20", null ]
[ "Q15 example", "dsppp_vector.html#autotoc_md20", null ],
[ "VectorView", "dsppp_vector.html#autotoc_md21", null ]
] ],
[ "Matrix", "dsppp_matrix.html", [
[ "VectorView", "dsppp_matrix.html#autotoc_md21", [
[ "Row vector", "dsppp_matrix.html#autotoc_md22", null ],
[ "Column vector", "dsppp_matrix.html#autotoc_md23", null ]
[ "VectorView", "dsppp_matrix.html#autotoc_md22", [
[ "Row vector", "dsppp_matrix.html#autotoc_md23", null ],
[ "Column vector", "dsppp_matrix.html#autotoc_md24", null ]
] ],
[ "MatrixView", "dsppp_matrix.html#autotoc_md24", null ],
[ "Matrix operations", "dsppp_matrix.html#autotoc_md25", [
[ "dot", "dsppp_matrix.html#autotoc_md26", null ],
[ "diagonal", "dsppp_matrix.html#autotoc_md27", null ],
[ "identity", "dsppp_matrix.html#autotoc_md28", null ],
[ "transpose", "dsppp_matrix.html#autotoc_md29", null ],
[ "outer product", "dsppp_matrix.html#autotoc_md30", null ]
[ "MatrixView", "dsppp_matrix.html#autotoc_md25", null ],
[ "Matrix operations", "dsppp_matrix.html#autotoc_md26", [
[ "dot", "dsppp_matrix.html#autotoc_md27", null ],
[ "diagonal", "dsppp_matrix.html#autotoc_md28", null ],
[ "identity", "dsppp_matrix.html#autotoc_md29", null ],
[ "transpose", "dsppp_matrix.html#autotoc_md30", null ],
[ "outer product", "dsppp_matrix.html#autotoc_md31", null ]
] ]
] ],
[ "Building and running examples", "dsppp_building.html", [
[ "To build", "dsppp_building.html#autotoc_md31", null ],
[ "To run", "dsppp_building.html#autotoc_md32", null ]
[ "To build", "dsppp_building.html#autotoc_md32", null ],
[ "To run", "dsppp_building.html#autotoc_md33", null ]
] ],
[ "Guidelines", "dsppp_guidelines.html", null ]
];
20 changes: 10 additions & 10 deletions main/dsppp_matrix.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@
<div class="fragment"><div class="line">Matrix&lt;float32_t,ROWS,COLS&gt; result = a * a + b;</div>
</div><!-- fragment --><p>The operators <code>+</code> and <code>*</code> are merged into the loop. <code>*</code> is the element-wise multiply. For the vector / matrix products you should use the operator <code>dot</code>.</p>
<p>Note that fusion of operators will not work with <code>dot(Matrix, Matrix</code>). It is only supported with vectors : <code>dot(Vector,Vector)</code> or <code>dot(Matrix,Vector)</code>.</p>
<h1><a class="anchor" id="autotoc_md21"></a>
<h1><a class="anchor" id="autotoc_md22"></a>
VectorView</h1>
<p>We can create virtual vectors which are view of some slices of the matrix.</p>
<h2><a class="anchor" id="autotoc_md22"></a>
<h2><a class="anchor" id="autotoc_md23"></a>
Row vector</h2>
<p>To set the second row to <code>0.0f</code>, you can do:</p>
<div class="fragment"><div class="line">result.row(1) = 0.0f;</div>
Expand All @@ -171,12 +171,12 @@ <h2><a class="anchor" id="autotoc_md22"></a>
<div class="line">VectorView&lt;P,S&gt; row(<span class="keyword">const</span> index_t i,<span class="keyword">const</span> index_t start=0,<span class="keyword">const</span> index_t stop=C)</div>
</div><!-- fragment --><p><code>stop</code> is the index of the first element <b>after</b> the end of the view.</p>
<p><code>i</code> is the row index</p>
<h2><a class="anchor" id="autotoc_md23"></a>
<h2><a class="anchor" id="autotoc_md24"></a>
Column vector</h2>
<p>There is a similar API for columns.</p>
<p>Let's set the odd elements of columns 3 to <code>5.0f</code>:</p>
<div class="fragment"><div class="line">result.col&lt;2&gt;(2,1) = 5.0f;</div>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md24"></a>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md25"></a>
MatrixView</h1>
<p>It is also possible to create a virtual matrix : a view onto a subset of the matrix.</p>
<p>Let's add the bottom right corner of the matrix to itself:</p>
Expand All @@ -189,7 +189,7 @@ <h2><a class="anchor" id="autotoc_md23"></a>
</div><!-- fragment --><p>You specify the row start and row end, then column start and column end.</p>
<p>Note that the end is the first index <b>after</b> the end of your rows or columns.</p>
<p>No stride is supported for matrix view in this version of the library.</p>
<h1><a class="anchor" id="autotoc_md25"></a>
<h1><a class="anchor" id="autotoc_md26"></a>
Matrix operations</h1>
<p>In addition to the vector operations <code>+</code>,<code>-</code> and <code>*</code>, matrixes are supporting more operations:</p>
<ul>
Expand All @@ -199,23 +199,23 @@ <h1><a class="anchor" id="autotoc_md25"></a>
<li><code>tranpose</code> to create the transposed matrix</li>
<li><code>outer</code> for the outer product of two vectors</li>
</ul>
<h2><a class="anchor" id="autotoc_md26"></a>
<h2><a class="anchor" id="autotoc_md27"></a>
dot</h2>
<div class="fragment"><div class="line">result = dot(a,b);</div>
</div><!-- fragment --><p>The compiler may use the move semantic to copy the temporary result of the <code>dot</code> function to <code>result</code>.</p>
<p>In this case, no copy would occur and <code>result</code> after the assignment would be a vector allocated by <code>dot</code> so using the <code>TMP_ALLOC</code> .</p>
<h2><a class="anchor" id="autotoc_md27"></a>
<h2><a class="anchor" id="autotoc_md28"></a>
diagonal</h2>
<div class="fragment"><div class="line">result = Matrix&lt;float32_t,ROWS,COLS&gt;::diagonal(c);</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md28"></a>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md29"></a>
identity</h2>
<div class="fragment"><div class="line">result = Matrix&lt;float32_t,ROWS,COLS&gt;::identity();</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md29"></a>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md30"></a>
transpose</h2>
<div class="fragment"><div class="line">result = a.transpose();</div>
</div><!-- fragment --><p>or</p>
<div class="fragment"><div class="line">transposeTo(result,a);</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md30"></a>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md31"></a>
outer product</h2>
<div class="fragment"><div class="line">result = outer(c,c);</div>
</div><!-- fragment --> </div></div><!-- contents -->
Expand Down
4 changes: 2 additions & 2 deletions main/dsppp_memory_static_dynamic.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@
<p>This naming "static" / "dynamic" is referring to the dimension. With "dynamic" vectors the same code can, at runtime, create vectors of different length based on a runtime length.</p>
<p>With "static" vectors : the length is fixed at build time and will never change at runtime.</p>
<p>Note that the library also have "static" / "dynamic" matrixes. So, we are going to use the name "object" to cover both cases in the below explanations.</p>
<h1><a class="anchor" id="autotoc_md17"></a>
<h1><a class="anchor" id="autotoc_md18"></a>
Static objects</h1>
<p>The advantage of static objects is that the dimension is known at build time. The compiler can thus generate an algorithm that is specialized for those dimensions and thus more efficient.</p>
<p>With static objects it is also possible to use different memory allocator with better performances and determinism.</p>
<p>But, with static objects, objects of different dimension are considered as different types. The compiler will generate different implementation so it will have an impact on the code size.</p>
<p>If you need lots of objects of different dimensions, or if the dimensions are not known at build time, then you need to use dynamic object</p>
<h1><a class="anchor" id="autotoc_md18"></a>
<h1><a class="anchor" id="autotoc_md19"></a>
Dynamic objects</h1>
<p>With dynamic objects, the dimension is know at runtime. So object of different dimensions have the same datatype and the compiler is generating only one implementation for all those objects. It cannot generate specialized implementations based on the dimension. It is better for code size, but the implementations will be less efficient.</p>
<p>Also when dimension is not know at build time, some instruction selection made by the C++ library at build time is no more possible. It has an effect on performance since at runtime one must decides what's possible or not. It is mostly impacting matrixes where stride information is needed.</p>
Expand Down
10 changes: 5 additions & 5 deletions main/dsppp_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="md_src_template"></a> </p>
<h1><a class="anchor" id="autotoc_md7"></a>
<h1><a class="anchor" id="autotoc_md8"></a>
What is a template useful for ?</h1>
<p>In CMSIS-DSP, you have functions like:</p>
<ul>
Expand All @@ -148,24 +148,24 @@ <h1><a class="anchor" id="autotoc_md7"></a>
<p>The generic <code>arm_add</code> source code is a template used to generate different implementations. It is like a code generator.</p>
<p>And if the compiler is unable to generate an implementation because the type variable <code>T</code> is replaced by a type with no addition operator, then it would be detected by the compiler.</p>
<p>Note that in C++, you can also use overloading of functions. They'll use the same name (but different arguments) but they won't share the same source code.</p>
<h1><a class="anchor" id="autotoc_md8"></a>
<h1><a class="anchor" id="autotoc_md9"></a>
Templates for datatypes</h1>
<p>C++ templates also apply to structs and classes.</p>
<p>For instance, we could have a template <code>Vector&lt;T&gt;</code> and thus different types <code>Vector&lt;float32_t&gt;</code>, <code>Vector&lt;Q15&gt;</code> ...</p>
<p>There is another aspect of C++ templates that may be surprising : the types can contain numbers.</p>
<p>For instance, one could have a type <code>Vector&lt;float32_t,10&gt;</code> for a vector of <code>float</code> and of length <code>10</code>. The length being known at build time.</p>
<p>The types <code>Vector&lt;float32_t,10&gt;</code> and <code>Vector&lt;float32_t,5&gt;</code> should be considered as different types because they have different lengths. The length is part of the type.</p>
<p>What we said above for code generation applies. For a template algorithm using any kind of vector, the compiler would generate different code for different vector types. The code for a template algorithm using <code>Vector&lt;float32_t,10&gt;</code> would be different from the code for <code>Vector&lt;float32_t,5&gt;</code> because those two types are different.</p>
<h1><a class="anchor" id="autotoc_md9"></a>
<h1><a class="anchor" id="autotoc_md10"></a>
Implicit parameters</h1>
<p>A template can also have implicit parameters.</p>
<p>For instance one could use <code>Vector&lt;float32_t&gt;</code> or <code>Vector&lt;float32_t,10&gt;</code>.</p>
<p>In the first case, the length is an implicit parameter with a default value and it is equivalent to writing <code>Vector&lt;float32_t,DYNAMIC&gt;</code> where <code>DYNAMIC</code> could be a special value (negative for instance) used to tell the compiler that the length of the vector is not known at build time but only at runtime.</p>
<p>Both variants may use totally different implementations. The <code>DYNAMIC</code> variant may contain a <code>length</code> field in the <code>struct</code> definition whereas other variants do not need this field since the length is known at build time.</p>
<h1><a class="anchor" id="autotoc_md10"></a>
<h1><a class="anchor" id="autotoc_md11"></a>
How to use templates ?</h1>
<p>A template is just a C++ header. You only need to include this header to start using the template. There is nothing to build.</p>
<h1><a class="anchor" id="autotoc_md11"></a>
<h1><a class="anchor" id="autotoc_md12"></a>
Example</h1>
<p>Now you can look at an <a class="el" href="dsppp_vector_example.html">example with vector operations</a> showing how to use the library </p>
</div></div><!-- contents -->
Expand Down
4 changes: 2 additions & 2 deletions main/dsppp_vector.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<li><code>Allocator</code> is the memory allocator. By default it is <code>TMP_ALLOC</code> that you can redefine since it is a macro</li>
<li><code>Vector_Base&lt;P&gt;</code> is providing the storage. A vector owns its storage buffer.</li>
</ul>
<h1><a class="anchor" id="autotoc_md19"></a>
<h1><a class="anchor" id="autotoc_md20"></a>
Q15 example</h1>
<p>Example with <code>Q15</code> is very similar:</p>
<p>The vectors are defined:</p>
Expand All @@ -160,7 +160,7 @@ <h1><a class="anchor" id="autotoc_md19"></a>
<div class="fragment"><div class="line">Vector&lt;Q15,NB&gt; dQ15 = aQ15 + bQ15 * cQ15;</div>
</div><!-- fragment --><p>The result is displayed:</p>
<div class="fragment"><div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;Result = &quot;</span> &lt;&lt; dQ15 ;</div>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md20"></a>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md21"></a>
VectorView</h1>
<p>A vector view is a virtual vector : a view of a vector.</p>
<p>One can define a <code>VectorView</code> with:</p>
Expand Down
Loading

0 comments on commit 17346f1

Please sign in to comment.