>
> > 2. There is some plan to develop it?
> >
> Yes, and no. So far, no one has submitted the patches that would make this
> possible (i.e. extend the GCC win32 threading implemenation and lat
> libstdc++ use that). An alternative path would be to create a separate
> implementation of the relevant functionality in libstdc++, written directly
> on top of the Win32 API.
> Fortunately for you though, I recently (well, a couple months ago) learned
> about an implementation of the second option available here:
> https://github.com/meganz/mingw-std-threads
> The author so kindly relicensed the files under the MinGW-w64 runtime
> license, which is essentially public domain or Zlib license where public
> domain doesn't exist.
> I'm curious as to how good that implementation would perform for you!
> Ruben
Thanks Ruben for taking time to answer me.
I have workaround this issue defining my own mutex based on CRITICAL
SECTIONS, here is the implementation:
https://github.com/official-stockfish/Stockfish/blob/master/src/thread_win32.h
I have redefined Mutex instead of std::mutex and defined also my own
condition variable but, with a small loss of speed, would be possible to
use std::condition_variable_any instead. There is no need to replace
std::thread.
With the above implementation I have fully fixed the speed loss.
It all boils down to the mutex implementation that is (by far) sub-optimal,
as I have found googling around:
/// STL thread library used by mingw and gcc when cross compiling for
Windows
/// relies on libwinpthread. Currently libwinpthread implements mutexes
directly
/// on top of Windows semaphores. Semaphores, being kernel objects, require
kernel
/// mode transition in order to lock or unlock, which is very slow compared
to
/// interlocked operations.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public