|
|
however, there is no threading support!! |
I #included the <thread> file properly, but the compiler gives me an error saying that thread was not declared in this scope. |
I decided to do some investigating on why this is happening and I opened the <thread> header file. The file exists and all the code including the code for the "thread" class was there, but for some strange reason there was no syntax highlighting at all, so it looked basically like a text document with C++ code in it, and the same thing happened to the <atomic> header file as well. |
Hello. I recently updated my compiler to MinGW W64 version 5.1.0. I added -std=c++1y to the compiler configurations (I am using Code::Blocks). |
gcc -v
command shows? (in command line navigate to the directory where binaries are and call main gcc executable with key -v)So if it uses Win32 threading model, will I be able to use threads from the Windows API? |
I couldn't find a version that uses winpthreads and compiler version 5.1.0 |
Operating system threads are rather heavy-weight; it takes time and system resources to create a thread. If you have an algorithm that naturally decomposes into a large number of independent computations, a.k.a. tasks, you’ll probably get your best performance not by creating a separate thread for each task, but by adjusting the number of threads depending on the amount of parallelism available on your particular system, e.g., the number of cores and their current loads. http://bartoszmilewski.com/2011/10/10/async-tasks-in-c11-not-quite-there-yet/ |
|
|
clang++ --version | grep clang && clang++ -std=c++14 -stdlib=libc++ -O3 -Wall -Wextra -pedantic-errors -pthread main.cpp &&./a.out echo ------------ && g++ --version | grep GCC && g++ -std=c++14 -g -O0 -Wall -Wextra -pedantic-errors -pthread main.cpp &&./a.out clang version 3.6.0 (tags/RELEASE_360/final 235480) hardware concurrency: 1 #unique thread ids: 6 ------------ g++ (GCC) 5.1.0 hardware concurrency: 1 #unique thread ids: 135 |
msc++: 1800 hardware concurrency: 1 #unique thread ids: 3 |
hardware concurrency: 4 #unique thread ids: varying from 8 to 16 |
hardware concurrency: 4 #unique thread ids: 135 |