multi threading

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

multi threading

Postby robertmo » 2018-7-11 @ 07:28

would it be possible to make it this way?

while one core is trying to count the result for either 1 or 0

two other cores could at the same time follow the code:
second core with the result of 1
and the third core with the result of 0

By the time the first core gets the result we will have the result for next operation.

8 cores cpu would be 3x faster than 1 core cpu this way.
User avatar
robertmo
l33t
 
Posts: 4383
Joined: 2003-6-18 @ 10:35

Re: multi threading

Postby root42 » 2018-7-11 @ 07:42

A similar thing happens on CPUs with speculative execution. The main problem is that not all code is simply calculating a result. You basically have these kinds of operations: arithmetic functions, reading of data, writing of data. The first two can be easily parallelized. However the writing of data has side effects and may influence computations further down the line. That is why speculative execution will eventually fail, given a long enough lookahead. Same problem would apply to your multi-core speculative execution model.
My ramblings on YouTube
Me playing games on my 286 and on my Sega MD2 on Twitch
80286@12 MHz, 2 MiB RAM, Tseng ET4000 1 MiB, schlae AdLib, XT CF Lite, OSSC 1.6
User avatar
root42
Member
 
Posts: 261
Joined: 2018-1-27 @ 13:23

Re: multi threading

Postby robertmo » 2018-7-11 @ 07:48

I think it would be enough to write into two separate temporary areas and write to a solid area only when we got the final result.
User avatar
robertmo
l33t
 
Posts: 4383
Joined: 2003-6-18 @ 10:35

Re: multi threading

Postby root42 » 2018-7-11 @ 07:56

Then you lose performance. Suddenly you will be bandwidth limited, because you will be writing multiple times the amound of data you would normally write.
The pipelines in a normal CPU will delay writing results, and can probably keep as much state as the pipeline is deep. But if you try to emulate this on a core level, you will have to write to real memory, which is much slower and much more costly.
My ramblings on YouTube
Me playing games on my 286 and on my Sega MD2 on Twitch
80286@12 MHz, 2 MiB RAM, Tseng ET4000 1 MiB, schlae AdLib, XT CF Lite, OSSC 1.6
User avatar
root42
Member
 
Posts: 261
Joined: 2018-1-27 @ 13:23

Re: multi threading

Postby robertmo » 2018-7-11 @ 08:09

I think that would be true with modern software.

But DOSBox uses very little amount of data (old small 16-bit games).
User avatar
robertmo
l33t
 
Posts: 4383
Joined: 2003-6-18 @ 10:35

Re: multi threading

Postby krcroft » 2018-7-11 @ 08:15

Great writeup here on latency, including the concept you mention in the fully optimized scenario.

https://byuu.org/articles/latency/
krcroft
Newbie
 
Posts: 38
Joined: 2017-4-29 @ 15:07

Re: multi threading

Postby aqrit » 2018-7-11 @ 22:42

no.
1. most instructions depend on the output of prior instruction.
2. the real cpu is already speculating, where possible.
3. 300+ cycles needed for synchronization between threads, every time.
aqrit
Member
 
Posts: 194
Joined: 2009-6-22 @ 19:53


Return to DOSBox Development

Who is online

Users browsing this forum: No registered users and 4 guests