Skip to content

Commit

Permalink
Minor fixes in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnh committed Oct 31, 2023
1 parent 9760b9b commit 3f622bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
17 changes: 9 additions & 8 deletions docs/build_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,15 @@ def build_index_page(groups):
],
"Memory read/write": [
"cast_to",
("load", "load(const T*, const I&)"),
("load", "load(const T*, const I&, const M&)"),
("loadn", "loadn(const T*, size_t)"),
("loadn", "loadn(const T*, size_t, size_t)"),
("store", "store(const V&, T *ptr, const I&)"),
("store", "store(const V&, T *ptr, const I&, const M&)"),
("storen", "storen(const V&, T*, size_t)"),
("storen", "storen(const V&, T*, size_t, size_t)"),
("read", "read(const T*, const I&, const M&)"),
("write", "write(T*, const I&, const V&, const M&)"),

("read", "read(const T*)"),
("write", "write(T*, const V&)"),

("read_aligned", "read_aligned(const T*)"),
("write_aligned", "write_aligned(T*, const V&)"),

("aligned_ptr", "aligned_ptr", "struct"),
],
"Utilities": [
Expand Down
18 changes: 9 additions & 9 deletions docs/guides/promotion.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Type Promotion
==============

For operations that involve two input arguments (or more), ``kernel_float`` will first convert the inputs into a common type before applying the operation.
For example, when adding ``vec<int, N>`` to a ``vec<float, N>``, both arguments must first be converted into a ``vec<float, N>``.
For operations that involve two (or more) input arguments, ``kernel_float`` will first convert the inputs into a common type before applying the operation.
For example, when adding ``vec<int, N>`` to ``vec<float, N>``, both arguments must first be converted into a ``vec<float, N>``.

This procedure is called "type promotion" and is implemented as follows.
First, all arguments are converted into a vector by calling ``into_vec``.
Next, all arguments must have length ``N`` or length ``1`` and vectors of length ``1`` are resized to become length ``N``.
Finally, the vector element types are promoted into a common type.
Initially, every argument is transformed into a vector using the ``into_vec`` function
Next, all arguments must have length ``N`` or length ``1``, where vectors of length ``1`` are repeated to become length ``N``.
Finally, the vector element types are promoted into a shared type.

The rules for element type promotion in ``kernel_float`` are slightly different than in regular C++.
In short, for two element types ``T`` and ``U``, the promotion rules can be summarized as follows:
In a nutshell, for two element types, the promotion rules can be summarized as follows:

* If one of the types is ``bool``, the result is the other type.
* If one type is a floating-point type and the other is a signed or unsigned integer, the result is the floating-point type.
* If both types are floating-point types, the result is the largest of the two types. An exception here is combining ``half`` and ``bfloat16``, which results in ``float``.
* If both types are integer types of the same signedness, the result is the largest of the two types.
* If one type is a floating-point and the other is an integer (signed or unsigned), the outcome is the floating-point type.
* If both are floating-point types, the largest of the two is chosen. An exception is combining ``half`` and ``bfloat16``, which results in ``float``.
* If both types are integer types of the same signedness, the largest of the two is chosen.
* Combining a signed integer and unsigned integer type is not allowed.

Overview
Expand Down

0 comments on commit 3f622bc

Please sign in to comment.