Qt multi-core capability



  • Qt multi-core capability ( not the same as multi-threading):
    Is multi-core capability available on Qt?



  • Not sure what the difference between multi-core and multi-threading is, but have you seen QtConcurrent.



  • Is there a difference at the abstraction level Qt operates?

    If your operating system supports more than one core or "core" (as in hyperthreading) your toolkit will, including low level operations (threads, mutexes, ...) and high level operations (futures, map/reduce, ...).

    If you mean multi-core as in multiprocessing like MPI then no, there is no such support.



  • What I mean by multi-core is ability to code such that we can run real parallel processing.

    Say you have an application, and it has 4 tasks which should be executed in parallel ( not sequential ), then does Qt has provision to allow those blocks of code to run, simultaneous, on each of the available CPU core on a 4 core CPU, for example?

    Alternative solution is to use parallel C++/C tools from Intel, libstdc++ parallel mode (GCC) etc.....



  • I don't see why Qt should enable / restrict multi-core threading, as it is not responsible for thread scheduling. So the answer is most likely yes.

    There are parts of the threading / concurrent framework which scale with the number of the available cores, like QThreadPool. And there a parts that have been specifically added to support convenient multithreaded programming, like thread local storage through QThreadStorage. Most of the classes and core principles (like implicit sharing) are reentrant or threadsafe.

    However there is a single restriction: GUI elements are only accessible in the main thread.

    Take a look at the QtCore and QtConcurrent frameworks - they will satisfy most to all of your needs. If you need extended multithreading capabilities like sticking threads to specific cores you might need some platform specific code.



  • I use parallel processing quite intensively in my Qt-based applications. I find that they always use all my cores to their full capacity when numbercrunching. And that is all done using QThread and the higher level threading classes in Concurrent. So the answer is: yes, Qt has multicore capabilities.



  • the Qt documentation mentions the following about concurrent programming:

    bq. The QtConcurrent namespace provides high-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives such as mutexes, read-write locks, wait conditions, or semaphores. Programs written with QtConcurrent automatically adjust the number of threads used according to the number of processor cores available. This means that applications written today will continue to scale when deployed on multi-core systems in the future.

    In other words, yes it will assign one core for each of the threads if there is a core available for the thread. It also means that you dont have to bother managing these at a lower level and in the future, your app will be able to use more cores as the number of cores will increase without modifying your code.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.