Skip to content

Commit 2c6fdd4

Browse files
committed
Add changes for 9760b9b
1 parent acd495e commit 2c6fdd4

28 files changed

+1127
-221
lines changed

_sources/api.rst.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ API Reference
88
api/binary_operators.rst
99
api/reductions.rst
1010
api/mathematical.rst
11+
api/fast_math.rst
1112
api/conditional.rst
1213
api/memory_read_write.rst
14+
api/utilities.rst
1315

_sources/api/fast_math.rst.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
..
2+
============================================================
3+
This file has been auto-generated. DO NOT MODIFY ITS CONTENT
4+
============================================================
5+
6+
Fast math
7+
=========
8+
fast_exp
9+
--------
10+
.. doxygenfunction:: kernel_float::fast_exp
11+
12+
fast_log
13+
--------
14+
.. doxygenfunction:: kernel_float::fast_log
15+
16+
fast_cos
17+
--------
18+
.. doxygenfunction:: kernel_float::fast_cos
19+
20+
fast_sin
21+
--------
22+
.. doxygenfunction:: kernel_float::fast_sin
23+
24+
fast_tan
25+
--------
26+
.. doxygenfunction:: kernel_float::fast_tan
27+
28+
fast_div
29+
--------
30+
.. doxygenfunction:: kernel_float::fast_div
31+

_sources/api/generation.rst.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ Generation
77
==========
88
range
99
-----
10-
.. doxygenfunction:: kernel_float::range
10+
.. doxygenfunction:: kernel_float::range()
11+
12+
range
13+
-----
14+
.. doxygenfunction:: kernel_float::range(F fun)
1115

1216
range_like
1317
----------

_sources/api/memory_read_write.rst.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ load
1919

2020
loadn
2121
-----
22-
.. doxygenfunction:: kernel_float::loadn(const T*, ptrdiff_t)
22+
.. doxygenfunction:: kernel_float::loadn(const T*, size_t)
2323

2424
loadn
2525
-----
26-
.. doxygenfunction:: kernel_float::loadn(const T*, ptrdiff_t, ptrdiff_t)
26+
.. doxygenfunction:: kernel_float::loadn(const T*, size_t, size_t)
2727

2828
store
2929
-----
@@ -35,11 +35,11 @@ store
3535

3636
storen
3737
------
38-
.. doxygenfunction:: kernel_float::storen(const V&, T*, ptrdiff_t)
38+
.. doxygenfunction:: kernel_float::storen(const V&, T*, size_t)
3939

4040
storen
4141
------
42-
.. doxygenfunction:: kernel_float::storen(const V&, T*, ptrdiff_t, ptrdiff_t)
42+
.. doxygenfunction:: kernel_float::storen(const V&, T*, size_t, size_t)
4343

4444
aligned_ptr
4545
-----------

_sources/api/utilities.rst.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
..
2+
============================================================
3+
This file has been auto-generated. DO NOT MODIFY ITS CONTENT
4+
============================================================
5+
6+
Utilities
7+
=========
8+
constant
9+
--------
10+
.. doxygenstruct:: kernel_float::constant
11+
12+
tiling
13+
------
14+
.. doxygenstruct:: kernel_float::tiling
15+
16+
KERNEL_FLOAT_TILING_FOR
17+
-----------------------
18+
.. doxygendefine:: KERNEL_FLOAT_TILING_FOR
19+

_sources/guides.rst.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Guides
66
guides/introduction.rst
77
guides/promotion.rst
88
guides/prelude.rst
9+
guides/constant.rst

_sources/guides/constant.md.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Using `kernel_float::constant`
2+
===
3+
4+
When working with mixed precision types, you will find that working with constants presents a bit of a challenge.
5+
6+
For example, a simple expression such as `3.14 * x` where `x` is of type `vec<float, 2>` will NOT be performed
7+
in `float` precision as you might expect, but instead in `double` precision.
8+
This happens since the left-hand side of this expression
9+
(a constant) is a `double` and thus `kernel_float` will also cast the right-hand side to `double`.
10+
11+
To solve this problem, `kernel_float` offers a type called `constant<T>` that can be used to represent
12+
constants. Any binary operations between a value of type `U` and a `constant<T>` will result in both
13+
operands being cast to type `U` and the operation is performed in the precision of type `U`. This makes
14+
`constant<T>` useful for representing constants in your code.
15+
16+
For example, consider the following code:
17+
18+
```
19+
#include "kernel_float.h"
20+
namespace kf = kernel_float;
21+
22+
int main() {
23+
using Type = float;
24+
const int N = 8;
25+
static constexpr auto PI = kf::make_constant(3.14);
26+
27+
kf::vec<int, N> i = kf::range<int, N>();
28+
kf::vec<Type, N> x = kf::cast<Type>(i) * PI;
29+
kf::vec<Type, N> y = x * kf::sin(x);
30+
Type result = kf::sum(y);
31+
printf("result=%f", double(result));
32+
33+
return EXIT_SUCCESS;
34+
}
35+
```
36+
37+
This code example uses the ``make_constant`` utility function to create `constant<T>`.

api.html

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<link rel="index" title="Index" href="genindex.html" />
2121
<link rel="search" title="Search" href="search.html" />
2222
<link rel="next" title="Types" href="api/types.html" />
23-
<link rel="prev" title="Using kernel_float::prelude" href="guides/prelude.html" />
23+
<link rel="prev" title="Using kernel_float::constant" href="guides/constant.html" />
2424
</head>
2525

2626
<body class="wy-body-for-nav">
@@ -54,8 +54,10 @@
5454
<li class="toctree-l2"><a class="reference internal" href="api/binary_operators.html">Binary Operators</a></li>
5555
<li class="toctree-l2"><a class="reference internal" href="api/reductions.html">Reductions</a></li>
5656
<li class="toctree-l2"><a class="reference internal" href="api/mathematical.html">Mathematical</a></li>
57+
<li class="toctree-l2"><a class="reference internal" href="api/fast_math.html">Fast math</a></li>
5758
<li class="toctree-l2"><a class="reference internal" href="api/conditional.html">Conditional</a></li>
5859
<li class="toctree-l2"><a class="reference internal" href="api/memory_read_write.html">Memory read/write</a></li>
60+
<li class="toctree-l2"><a class="reference internal" href="api/utilities.html">Utilities</a></li>
5961
</ul>
6062
</li>
6163
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
@@ -112,6 +114,7 @@ <h1>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
112114
</li>
113115
<li class="toctree-l1"><a class="reference internal" href="api/generation.html">Generation</a><ul>
114116
<li class="toctree-l2"><a class="reference internal" href="api/generation.html#range">range</a></li>
117+
<li class="toctree-l2"><a class="reference internal" href="api/generation.html#id1">range</a></li>
115118
<li class="toctree-l2"><a class="reference internal" href="api/generation.html#range-like">range_like</a></li>
116119
<li class="toctree-l2"><a class="reference internal" href="api/generation.html#each-index">each_index</a></li>
117120
<li class="toctree-l2"><a class="reference internal" href="api/generation.html#fill">fill</a></li>
@@ -208,6 +211,15 @@ <h1>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
208211
<li class="toctree-l2"><a class="reference internal" href="api/mathematical.html#isnan">isnan</a></li>
209212
</ul>
210213
</li>
214+
<li class="toctree-l1"><a class="reference internal" href="api/fast_math.html">Fast math</a><ul>
215+
<li class="toctree-l2"><a class="reference internal" href="api/fast_math.html#fast-exp">fast_exp</a></li>
216+
<li class="toctree-l2"><a class="reference internal" href="api/fast_math.html#fast-log">fast_log</a></li>
217+
<li class="toctree-l2"><a class="reference internal" href="api/fast_math.html#fast-cos">fast_cos</a></li>
218+
<li class="toctree-l2"><a class="reference internal" href="api/fast_math.html#fast-sin">fast_sin</a></li>
219+
<li class="toctree-l2"><a class="reference internal" href="api/fast_math.html#fast-tan">fast_tan</a></li>
220+
<li class="toctree-l2"><a class="reference internal" href="api/fast_math.html#fast-div">fast_div</a></li>
221+
</ul>
222+
</li>
211223
<li class="toctree-l1"><a class="reference internal" href="api/conditional.html">Conditional</a><ul>
212224
<li class="toctree-l2"><a class="reference internal" href="api/conditional.html#where">where</a></li>
213225
<li class="toctree-l2"><a class="reference internal" href="api/conditional.html#id1">where</a></li>
@@ -227,6 +239,12 @@ <h1>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
227239
<li class="toctree-l2"><a class="reference internal" href="api/memory_read_write.html#aligned-ptr">aligned_ptr</a></li>
228240
</ul>
229241
</li>
242+
<li class="toctree-l1"><a class="reference internal" href="api/utilities.html">Utilities</a><ul>
243+
<li class="toctree-l2"><a class="reference internal" href="api/utilities.html#constant">constant</a></li>
244+
<li class="toctree-l2"><a class="reference internal" href="api/utilities.html#tiling">tiling</a></li>
245+
<li class="toctree-l2"><a class="reference internal" href="api/utilities.html#kernel-float-tiling-for">KERNEL_FLOAT_TILING_FOR</a></li>
246+
</ul>
247+
</li>
230248
</ul>
231249
</div>
232250
</section>
@@ -235,7 +253,7 @@ <h1>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
235253
</div>
236254
</div>
237255
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
238-
<a href="guides/prelude.html" class="btn btn-neutral float-left" title="Using kernel_float::prelude" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
256+
<a href="guides/constant.html" class="btn btn-neutral float-left" title="Using kernel_float::constant" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
239257
<a href="api/types.html" class="btn btn-neutral float-right" title="Types" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
240258
</div>
241259

api/binary_operators.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@
7777
</li>
7878
<li class="toctree-l2"><a class="reference internal" href="reductions.html">Reductions</a></li>
7979
<li class="toctree-l2"><a class="reference internal" href="mathematical.html">Mathematical</a></li>
80+
<li class="toctree-l2"><a class="reference internal" href="fast_math.html">Fast math</a></li>
8081
<li class="toctree-l2"><a class="reference internal" href="conditional.html">Conditional</a></li>
8182
<li class="toctree-l2"><a class="reference internal" href="memory_read_write.html">Memory read/write</a></li>
83+
<li class="toctree-l2"><a class="reference internal" href="utilities.html">Utilities</a></li>
8284
</ul>
8385
</li>
8486
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li>

api/conditional.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<link rel="index" title="Index" href="../genindex.html" />
2121
<link rel="search" title="Search" href="../search.html" />
2222
<link rel="next" title="Memory read/write" href="memory_read_write.html" />
23-
<link rel="prev" title="Mathematical" href="mathematical.html" />
23+
<link rel="prev" title="Fast math" href="fast_math.html" />
2424
</head>
2525

2626
<body class="wy-body-for-nav">
@@ -54,13 +54,15 @@
5454
<li class="toctree-l2"><a class="reference internal" href="binary_operators.html">Binary Operators</a></li>
5555
<li class="toctree-l2"><a class="reference internal" href="reductions.html">Reductions</a></li>
5656
<li class="toctree-l2"><a class="reference internal" href="mathematical.html">Mathematical</a></li>
57+
<li class="toctree-l2"><a class="reference internal" href="fast_math.html">Fast math</a></li>
5758
<li class="toctree-l2 current"><a class="current reference internal" href="#">Conditional</a><ul>
5859
<li class="toctree-l3"><a class="reference internal" href="#where">where</a></li>
5960
<li class="toctree-l3"><a class="reference internal" href="#id1">where</a></li>
6061
<li class="toctree-l3"><a class="reference internal" href="#id2">where</a></li>
6162
</ul>
6263
</li>
6364
<li class="toctree-l2"><a class="reference internal" href="memory_read_write.html">Memory read/write</a></li>
65+
<li class="toctree-l2"><a class="reference internal" href="utilities.html">Utilities</a></li>
6466
</ul>
6567
</li>
6668
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li>
@@ -160,7 +162,7 @@ <h2>where<a class="headerlink" href="#id2" title="Permalink to this heading">
160162
</div>
161163
</div>
162164
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
163-
<a href="mathematical.html" class="btn btn-neutral float-left" title="Mathematical" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
165+
<a href="fast_math.html" class="btn btn-neutral float-left" title="Fast math" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
164166
<a href="memory_read_write.html" class="btn btn-neutral float-right" title="Memory read/write" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
165167
</div>
166168

0 commit comments

Comments
 (0)