Setting the control word is process-specific.Nowhk wrote: what if CPU is running two process together and one require denormals and the other not?
https://en.wikipedia.org/wiki/Process_control_block
Setting the control word is process-specific.Nowhk wrote: what if CPU is running two process together and one require denormals and the other not?
Yes, it's possible, but Ive never seen that with VS C++ compiler.Chris-S wrote:Code like this might be optimized away.matt42 wrote:Maybe CPU flushing is the best. To manually kill denormals we could do something likeCode: Select all
value += 1e-18; value -= 1e-18;
But what if the host (or another plug-in) changes the state? I would guess you would have to set/restore the state at each process call...mystran wrote:You want to take the existing state in constructor and store it somewhere and then you restore whatever state existed before the object was constructed. Then if the host already disabled them, or if you nest those objects, or whatever, things will always stay correct.
Since VST is loaded as DLL, probably the process "itself" is the one created by the DAW, and its unique for other VSTs/DLLs.camsr wrote:Setting the control word is process-specific.
That could get worse, have a look at http://softpixel.com/~cwright/programming/simd/mmx.php, MMX State Management. The conclusion is that every piece of code should be written accordingly, setting its own required state.What if one of them (for example) require denormal numbers?
If a plugin requires denormal numbers to work correctly its developer absolutely deserves the flood of angry support tickets that will arise when another plugin or the DAW activates FTZ.Nowhk wrote: Theoretically, if DAW doesn't disable this by default, and I load my plugin that disable denormal numbers, it's possible that those numbers will be disabled also for the other VSTs that I'm running in that moment. What if one of them (for example) require denormal numbers?
Limit case... but it's computer science... nothing should be ignored
Not a whole plugin, maybe just a function in a included library (which can be any kind of stuff, such as graphic library, for example). The discussion here is that my plugin could disable "somethings" required to other plugins, that's all!hugoderwolf wrote:If a plugin requires denormal numbers to work correctly its developer absolutely deserves the flood of angry support tickets that will arise when another plugin or the DAW activates FTZ.
This means (as Tale stated I think) that at every "process" call I should set the required flag, and later restore it, at the end of the calling.stratum wrote:The conclusion is that every piece of code should be written accordingly, setting its own required state.
If denormals is a problem for a specific processor then definitely yes.This means (as Tale stated I think) that at every "process" call I should set the required flag, and later restore it, at the end of the calling.
Is this cheaper than denormal the number at each iteration?
And that's exactly what the compiler does for you! Whenever the program flows into an entry point of a dll or returns from it, lots of householding instructions like this are carried out.Nowhk wrote:This means (as Tale stated I think) that at every "process" call I should set the required flag, and later restore it, at the end of the calling.
I'm not sure that would be happening when some function returns an address of a function from a dll and then later some other code calls it. In fact that may be the case for the VST api, I do not recall the details, though. To me it looks like such details belong to the applicaiton binary interface (ABI) for a particular platform and compilers should better generate compliant code.And that's exactly what the compiler does for you! Whenever the program flows into an entry point of a dll or returns from it, lots of householding instructions like this are carried out.
Hi NowhkNowhk wrote:Yes. But if I have broadband noise at -60db (which is quite imperceptible), once I add to a sine, the difference between the "real" sine wave and the one with noise is noticeable? I don't think so. Maybe for a compressor that will "act" some 0.001 before... or what do you mean?JCJR wrote:Low level noise doesn't just happen when sample numbers are tiny. For instance if you happen to have steady broadband noise at -60 db peak then in silent parts of the track you would have random numbers in the samples ranging from about -0.001 up to about +0.001.
If a loud -6 dB peak sine wave kicks in, that random noise peaking between -0.001 and +0.001 gets added to the peak of the sine wave and it gets added to the mid-values of the sine wave. The noise is super-imposed over the entire waveform.
Can you be sure of this?Miles1981 wrote:mystran's trick is for the process() call of he plugin, so there is no talk about the interaction with other plugins or the host. They will see the state of the FPU as it was before.
The OS handles this - without which multithreading wouldn't be possible. There is a large set of registers (and some other state) that needs to be stored and restored during thread context switches (it is called a context switch for a reason..)What if in the middle of the iteration of the samples, the control pass to another thread (which is on the same cpu core) and start to process the ProcessDoubleReplacing of another plug B? Plug B will execute with the flag setted by plug A. I'm in the same "Process" within the DAW (so control word are shared across plugins), since VSTs are DLL (but honestly this depends by the host DAW; some will use the same process task, some could fork it on every DLL, and so on).
When the OS switches between threads, it saves all the registers of one thread and restores the registers of another thread. The SSE control word is just a register and it gets saved and restored as part of a thread switch just like any other register. The registers are part of thread (not process) and there is absolutely nothing "special" about this register compared to any other registers as far as thread-switching is concerned, it's just another register. If the thread gets moved to another core, then the registers (including the control word) move with the thread, so you really don't need to worry about it.Nowhk wrote: What if in the middle of the iteration of the samples, the control pass to another thread (which is on the same cpu core) and start to process the ProcessDoubleReplacing of another plug B?
© KVR Audio, Inc. 2000-2024
Submit: News, Plugins, Hosts & Apps | Advertise @ KVR | Developer Account | About KVR / Contact Us | Privacy Statement