Multithreading, Algorithms and Cores
I am now becoming interested in the inter-relations of multithreading, processors'cores and efficient algorithms.
Some people advise me that multithreading is not a good option in all cases because it may cause performance hits somewhere along the end-users'facilities. And at the same time they highly praise the good algorithms for quick access to RAM or to reduce latency during complex calculations.The task scheduler included as a programmed chip inside our multicore computers offers great benefits when the tasks are dispatched almost equally among the cores and get done pretty faster than before, compared to a single core, single threaded application. And here are two of what I wonder,
1. I believe that multithreaded applications run better on a multicore computer because the CPU manages and runs them parallel with each other and thus their tasks are completed sooner. But this doesn't seem to be a undeniable fact to me, especially in case of a complex multi-tasked application. For example, I have a application with N threads to perform heavy tasks, all of which interweaved each other's operations, therefore I need to schedule them to run with mutexes, critical sections, events etc. What is that specific case's performance gain I might reclaim in comparison to sequential operations of the same application that runs on a single core computer ?
2. In case of an efficient algorithm, the algorithm offers intellectual ways to sending and retrieving data to and from some sort of storage. But this makes me think that sort of "send"ing and "retriev"ing data also implies the connection bus speed available for data access. This kind of connection again I think may be implemented as an abrupt value realization, e.g "Oh I see your point of $$$" done by the compiler over the syntax trees. The compiler will look it up, optimize it away in some way and emit commands at machine level for further processing to be performed later by the CPU. So I conclude myself that efficient algorithms are only tiny add-ins in a whole larger "multithreaded" picture and it thus definitely doesn't offer actual benefits to speed up the application itself.