Original Post
Hello!
Just a short preamble before I actually begin - precision and repeatability of computations is *very* important to me, that is why I even noticed the issue to be described in a sec.
Well, calling the Device constructor does *something* to the calling thread. I cannot say what it is (hence the question), but it changes the way this thread multiplies doubles. Resultantly, the thread seems to cast them to floats and back to doubles. Here comes the example:
And as of now, the thread will do the same lousy thing whenever it stumbles upon double multiplication.
However
Just a short preamble before I actually begin - precision and repeatability of computations is *very* important to me, that is why I even noticed the issue to be described in a sec.
Well, calling the Device constructor does *something* to the calling thread. I cannot say what it is (hence the question), but it changes the way this thread multiplies doubles. Resultantly, the thread seems to cast them to floats and back to doubles. Here comes the example:
//init.
//...
//double multiplication test
double a = 0.86602539649920685;
double b = 1.0000000000000000;
double c = a * b; // c = 0.86602539649920685
//device creation
_device = new Device(d3d, iAdapter, devType, this.Handle, flags, _presentParams);
//double multiplication test
double d = 0.86602539649920685;
double e = 1.0000000000000000;
double f = d * e; // f = 0.86602538824081421 [!!!]
double g = (double)((float)d * (float)e); // g = 0.86602538824081421 [!!!]
And as of now, the thread will do the same lousy thing whenever it stumbles upon double multiplication.
However
- calling the very same multiplication in a separate thread (once the main thread has gone through device creation) -> okay
- forcing the device creation to a separate thread (just for testing) -> the main thread remains okayand that is why I guess it must be a certain thread 'setting' or whatever.
The question: what is the reason for this and can I sanely undo what device creation seems to be doing?
Thanks