Skip to content

Commit

Permalink
Update 04_Math-Functions.md
Browse files Browse the repository at this point in the history
Added examples
  • Loading branch information
AlfredBr authored Apr 10, 2024
1 parent 5b250cb commit 0964947
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Docs/03_Advanced/04_Math-Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@ unprecise) math functions.
Unlike previous versions, the fast-math mode applies to all math instructions. Even to default math operations
like `x / y`.

```C#
Context context = Context.Create(builder => builder.Math(MathMode.Fast));
```

### Forced 32-bit Math

Your kernels might rely on third-party functions that are not under your control.
These functions typically depend on the default .Net `Math` class, and thus, work on 64-bit floating-point operations.
You can force the use of 32-bit floating-point operations in all cases using the `Math(MathMode.Fast32BitOnly)` method
of `Context.Builder`.
Caution: all doubles will be considered as floats to circumvent issues with third-party code.

```c#
Context context = Context.Create(builder => builder.Math(MathMode.Fast32BitOnly));
```

Caution: All doubles will be considered as floats to circumvent issues with third-party code.
However, this also affects the address computations of array-view elements.
Avoid the use of this flag unless you know exactly what you are doing.

0 comments on commit 0964947

Please sign in to comment.