Parallel C ++ 11 - What toolchains can I use?

I am using <thread> <atomic> <mutex> etc. in my code, which includes several non-blocking algorithms. I am targeting (eventually) the linux environment. I am developing using the beta version of Visual Studio 2011, which, although terribly terrible in other C ++ 11 features, seems to be the only toolchain that implements parallel functions.

See C ++ 11 support here:

Now, if others just don’t have a library containing the parallel features of C ++ 11, I can easily use just :: thread , however, both clang and gcc answer β€œno” to the C ++ 11 memory model, which apparently , supports at least visual C ++. I'm not quite sure what the effect of this will be - perhaps free code optimization without side effects, among other erroneous things.

If at the moment I completely exclude optimized assemblies and compile only debug assemblies without enabling optimization, is it wise to use the Clang or GCC toolchain?

+8
c ++ multithreading synchronization c ++ 11 lock-free
source share
2 answers

GCC 4.7 Status

The C ++ memory model is ongoing and is planned to be completed in the next release of GCC. GCC 4.7 is now released, so this is what you can expect from it.

  • Full atomic implementation for supported instructions without blocking. All atomic operations were implemented using the new __atomic built-in functions, and most goals reflect the memory model parameter in the code that is generated. Optimization will not move the shared memory of operations on atomic operations, so various relationship events are respected.
  • When instructions for unlocking are not available (either through hardware or OS support), atomic operations remain as function calls that will be resolved by the library. Due to time constraints and APIs that are not complete, there is no libatomic shipped with GCC 4.7. This is easily determined by the meeting of unsatisfied external characters starting with _atomic *.
  • If the program needs help in the library, one sample implementation of the C file is available, which will be compiled and linked to the client program to resolve these external function calls using a locked implementation. Download libatomic sample
  • C ++ templates fully support objects of arbitrary size, although the previously mentioned libatomic.c file may be required to satisfy some user-defined classes. If the class maps to the same size as the supported non-locking integral type, then locking functions will also be used.
  • Battlefields do not match the memory model. This means that they can enter loads or store race data due to the whole word access when reading or writing.
  • Optimizations have not been fully tested for compliance, although some work has been completed. Some optimizations may introduce new race data that did not exist before. The number of known cases is small, and compliance testing is not trivial. If someone encounters a case where optimization introduces a new data race, please open bugzilla for this so that it can be solved.

Support in LLVM is as follows: http://llvm.org/releases/3.0/docs/Atomics.html

It is hard to say to what extent this is actually used in clang. <atomic> seems to work mostly for some types. I get compiler statements for other types, saying that the atomic type was unexpected, which gives some certainty about what types it works with.

+4
source share

I have successfully used gcc-4.7 on 64-bit Linux and Windows. std::thread etc. works fine on linux even with gcc-4.6.
There are some minor issues on gcc-4.7 (mingw64) windows, memory leaks with std::condition_variable AFAIR destructors.

+1
source share

All Articles