I have some very optimized code (signal processing) running perfectly in C# using Mono, cross platform. However, certain circumstances causes exponentially decaying numbers which by nature are destined to become denormal at some point.
Since this effectively reduces the performance of the application by orders of magnitude, I would like to get rid of them. However, checking for denormals everywhere they can occur incurs similar performance problems.
I know both the x87 FPU and the SSE FPU supports DAZ operations (denormals-are-zero/flush denormals to zero) which would solve all problems, however these control words are not accessible through C# it would seem.
I would need something that works crossplatform, and for both the x87 fpu and daz. What are my options? Can i p/invoke to control the fpu words? I know the runtime doesn't expect the change of the control word, however I'll reset the word back after the small timeframe i need it.
e: I wouldn't say this is a duplicate; it needs more research. The answer in the other says it isn't possible, and in the next line says it can be done though p/invoking. Obviously it will be reset on exceptions, but since i intend on setting it each time i need the feature (which you should always do, anyway) it would seem to be possible. Has anyone succeeded doing in this? I also can't seem to find a _control_fp in some module on OSX, does p/invoking work the same there?