I have an application that uses Windows threads on a high level for parallelization. MKL is called on each thread.
In certain critical sections of the program threads are executed serially (think mutex). In these critical sections MKL functions are also called.
If my machine has N processors, I create N Windows threads so that at a very high level I achieve the parallelization I want. At this point I would like to set MKL_NUM_THREADS to 1 as I have no more processor power left.
However, at the critical sections I would like to set MKL_NUM_THREADS to N.
My question: is there a way to continuosly change the value of this environment variable? I'm concerned about when a MKL function will actually check the value of the environment variable. If I use "putenv" this may not be good enough.