Reputation: 272
Just something that passed by my head today. Would it be possible to, for example, team 4 cores to emulate a single core cpu with four times the Ghz of those 4 cores?
I mean, let's suppose I have a 3Ghz quad-core CPU. In this emulation, the emulated CPU would be a single core CPU, but with solid 12Ghz of power.
I'm 99% sure this is not possible, but I'm curious, what would be the obstacles that prevent one to achieve such thing?
Thanks.
Upvotes: 2
Views: 1632
Reputation: 2214
The main obstacle is the same as it is with auto-parallelizing compilers: it is hard to transform a program written for serial execution into a parallel program doing the same thing. Humans spend a lot of time doing that, and machines do not help much either.
Consider a flow of machine instructions as a serial program. Each instruction accesses resources (registers, memory) and sometimes changes them. Future instructions "assume" that those preceding them has finished changing shared data. An instruction cannot be executed until all its inputs are available. However, if a future instruction does not depend on any piece of data currently being processed, it may be started earlier.
Modern out-of-order CPUs scan serial instruction flows looking for data-independent instructions and schedule them onto multiple execution resources inside the processor. It is possible because a) there is some extractable parallelism and b) everything is done tightly inside the processor and decisions can be made fast.
First, such sort of parallelism is inherently limited. If you write a synthetic program in which every following instruction will depend on the preceding one (as an example, so called "pointer chasing" sequences), there will be no parallelism to extract no matter how many parallel execution units are available inside a CPU. It will obviously not help if you add more CPUs.
Second, remember that a decision about what to run in parallel has to be done on-the-run, while the guest code is already running. If you think too long about which blocks are safe to run independently, the time wasted thinking will outweigh possible time savings of actually running stuff. Inside the single CPU, there is a chance because everything is so close to each other. Multiple CPUs or even CPU cores are considerable farther away from each other, they communicate through slow memory, and thus making a runtime programmatic decision on how to parallelize current task at hand would be too slow.
Compare the described "runtime" situation with an "offline" case when a software compiler was tasked to take a serial program and generate a parallel code from. It would have all the time in the world to do that, relatively speaking. And know what, after 30+ years of research they still suck at that.
Upvotes: 1