|
| 1 | +Using `kernel_float::prelude` |
| 2 | +=== |
| 3 | + |
| 4 | +When working with Kernel Float, you'll find that you need to prefix every function and type with the `kernel_float::...` prefix. |
| 5 | +This can be a bit cumbersome. |
| 6 | +It's strongly discouraged not to dump the entire `kernel_float` namespace into the global namespace (with `using namespace kernel_float`) since |
| 7 | +many symbols in Kernel Float may clash with global symbols, causing conflicts and issues. |
| 8 | + |
| 9 | +To work around this, the library provides a handy `kernel_float::prelude` namespace. This namespace contains a variety of useful type and function aliases that won't conflict with global symbols. |
| 10 | + |
| 11 | +To make use of it, use the following code: |
| 12 | + |
| 13 | + |
| 14 | +```C++ |
| 15 | +#include "kernel_float.h" |
| 16 | +using namespace kernel_float::prelude; |
| 17 | + |
| 18 | +// You can now use aliases like `kf`, `kvec`, `kint`, etc. |
| 19 | +``` |
| 20 | + |
| 21 | +The prelude defines many aliases, include the following: |
| 22 | + |
| 23 | +| Prelude name | Full name | |
| 24 | +|---|---| |
| 25 | +| `kf` | `kernel_float` | |
| 26 | +| `kvec<T, N>` | `kernel_float::vec<T, N>` | |
| 27 | +| `into_kvec(v)` | `kernel_float::into_vec(v)` | |
| 28 | +| `make_kvec(a, b, ...)` | `kernel_float::make_vec(a, b, ...)` | |
| 29 | +| `kvec2<T>`, `kvec3<T>`, ... | `kernel_float::vec<T, 2>`, `kernel_float::vec<T, 3>`, ... | |
| 30 | +| `kint<N>` | `kernel_float::vec<int, N>` | |
| 31 | +| `kint2`, `kint3`, ... | `kernel_float::vec<int, 2>`, `kernel_float::vec<int, 3>`, ... | |
| 32 | +| `klong<N>` | `kernel_float::vec<long, N>` | |
| 33 | +| `klong2`, `klong3`, ... | `kernel_float::vec<long, 2>`, `kernel_float::vec<long, 3>`, ... | |
| 34 | +| `kbfloat16x<N>` | `kernel_float::vec<bfloat16, N>` | |
| 35 | +| `kbfloat16x2`, `kbfloat16x3`, ... | `kernel_float::vec<bfloat16, 2>`, `kernel_float::vec<bfloat16, 3>`, ... | |
| 36 | +| `khalf<N>` | `kernel_half::vec<half, N>` | |
| 37 | +| `khalf2`, `khalf3`, ... | `kernel_half::vec<half, 2>`, `kernel_half::vec<half, 3>`, ... | |
| 38 | +| `kfloat<N>` | `kernel_float::vec<float, N>` | |
| 39 | +| `kfloat2`, `kfloat3`, ... | `kernel_float::vec<float, 2>`, `kernel_float::vec<float, 3>`, ... | |
| 40 | +| `kdouble<N>` | `kernel_float::vec<double, N>` | |
| 41 | +| `kdouble2`, `kdouble3`, ... | `kernel_float::vec<double, 2>`, `kernel_float::vec<double, 3>`, ... | |
| 42 | +| ... | ... | |
0 commit comments