Single point math in .NET?

The functions of the .NET Framework Math mainly work with a double point with double precision, there are no overloads with one precision (float). When working with single-precision data in a high-performance scenario, this leads to unnecessary casting, as well as to the calculation of functions with greater accuracy than required, therefore, performance depends to some extent.

Is there a way to avoid some extra processor overhead? For example. Is there an open source math library with floating point overloads that directly calls basic FPU instructions? (I understand that this will require support in the CLR). And in fact, I'm not sure that modern processors even have instructions with the same accuracy.

This question was partially inspired by this question about sigmoid function optimization:

Mathematical Optimization in C #

+6
math mathematical-optimization
source share
2 answers

As far as I know, the .NET Framework does not include an API with direct access to mathematical functions. Mono libraries include working support for built-in functions, but I'm not sure about their state.

[Edit: this section gives a comment on why you do not see overloads for float parameters.] One problem is that the CLI evaluation stack (for ECMA-335) does not distinguish between float and double types. A valid implementation can treat everything as a double for mathematical operations, but I believe that the CLR (Microsoft CLI implementation) performs optimization for arithmetic with one precision where it can.

I think it is somewhat annoying that the problem of intrinsics (in particular, the SIMD extension) has not yet been resolved [in the released product]. My outsider hunch is support for built-in functions that will require significant changes to the virtual machine, which pose unacceptable risks at this stage of the .NET Framework release cycle. The garbage collector (and I think that exception handling mechanisms) are closely related to the register allocator, and intrinsics support adds a radical new variable to this area.

+3
source share

Yes, we are creating a high-performance math library with direct calculation, which initially uses floating point calculations with one precision, if that's all you need. And you are right, if they are implemented correctly, they can be much faster than using double precision.

Check out this math library from CenterSpace software.

Floor

+1
source share

All Articles