Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Multi core cpu and/or multithreading supported?

Author
Message
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 10th Nov 2012 01:03
Hi,
Is DarkBasic Professional supporting Multi Core CPU or Multithreading?

Thanks
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 10th Nov 2012 01:54
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 10th Nov 2012 10:09 Edited at: 10th Nov 2012 10:10
At the moment, no it doesn't. Unfortunately, when DBPro was written multi-core wasn't a commercial option so DBPro was never written to be "thread safe". Altering this is a fairly substantial change / rewrite of certain parts and hence hasn't been attempted yet. However, as part of the FPS Creator Reloaded project that TGC are currently running a Kick Starter campaign for, there will also be substantial upgrades to DBPro, one of which mentioned was the introduction of multi-threading support. So if, like me, you'd like to see that and all the other improvements which have been talked about then please consider backing the project.


Previously TEH_CODERER.
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 10th Nov 2012 14:31
Ah interesting.
What do you think about "how much time" we need to wait to see the multi threading support in DBpro?
Will be a near thing or a far thing?
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 10th Nov 2012 15:13
Quote: "Will be a near thing or a far thing? "

it will be a no thing

Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 10th Nov 2012 15:19
I'm afraid I can't give a very accurate answer for that as I'm not involved. Lee Bamber mentioned that in order to make the upgrades to FPSC he would be doing a lot of work to DBPro. This would lead me to assume that they would be done fairly early on because the updates to FPSC won't be possible until they're implemented in DBPro. I know that there is already some work being done, but if the Kick Starter doesn't reach its target I'm not sure if we'll get to see any of the updates, including the multi-threading.


Previously TEH_CODERER.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 10th Nov 2012 15:49
What??? This has I'm confused now? In what way can't you multithread in DBPRO?

You can use the Styx plugin which has an interval feature which allows you to do things such as load objects or process images while your game continues to run. You need to use alternative sync commands and much effort is required on your part.

You can try Digital Fury's multithreading plugin.

You can also split your game into two executables which can share the load; two processes run on different threads.

You can use plugins which support multithreading (Dark Net, Dark Physics etc)

In what way could you not produce multi-tasking software with the above methods?

Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 10th Nov 2012 16:37 Edited at: 10th Nov 2012 16:39
You've just listed a bunch of plugins. So the fact remains that DBPro doesn't support multi-threading yet. You can get various plugins or workarounds that will allow you to multi-thread certain tasks but even then, with DBPro not being thread safe, you're somewhat limited with how much you can do, at least without potential issues. If DBPro was thread safe, it would be easy to do things like streaming worlds, only loading in objects as and when you need them without locking the game up whilst you do so.

[Edit] Removed a redundant 'the'. [/Edit]


Previously TEH_CODERER.
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 10th Nov 2012 17:02 Edited at: 10th Nov 2012 17:06
Ahhh Chris Tate, you giving me little chanches!

Please, can you explain me better what typology of work these plugins can do?
And over, your words:
Quote: "You can also split your game into two executables which can share the load; two processes run on different threads.
"


example:
I am using a cube as an area enclosing my airplane.
I fill that cube with a lot of little cubes (so and so 2000) that are as the atmosphere where my airplane flying in.

Ok, over the fact I am using and compiling over 3000 objects live, one of the thing slowing my code is that I always need to "FOR cycle" these 3000 cubes live to obtain status and to change their coordinates and states.

This is a bad blow to my code speed so would be great If I can find a way to make that calculation outside my main compiling code!
and your words maybe open a big chance to get it!

Over that:
Quote: "You can use plugins which support multithreading (Dark Net, Dark Physics etc)"

I am using Dark Dynamix, is this supporting multithreading too? and what are the commands about?
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 10th Nov 2012 17:22
Dark Dynamix is multi-threaded automatically. The 'dyn simulate' command will run the physics simulation in another thread. Once this has been called you can do other bits in DBPro such as the main update/render using 'sync' and the 2 processes will run at the same time, taking advantage of multi-cored CPUs. The 'dyn fetch results' is then called to pause any further processing until the physics thread has finished processing so that neither thread gets ahead of the other.


Previously TEH_CODERER.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 10th Nov 2012 18:01 Edited at: 10th Nov 2012 18:16
In confirmation of the above post, DD can multi-thread.

Quote: "You've just listed a bunch of plugins. So the fact remains that DBPro doesn't support multi-threading yet."


OK, I suppose I see things differently.

To me, DBPRO is a plugin based development tool, the same way FL Studio is a plugin based sound production tool; the same way Photoshop is a plugin based photo manipulation tool, the same way Visual C# / Basic are currently .NET framework tools.

If I create a normal map in Photoshop, I would say that I used Photoshop to produce the result; even though I used one of its plugins, the same way if I release multithreaded software in DBPRO, I would say I made it in DBPRO. I personally see DBPRO plugins as part of DBPRO; some of which are free; the same way I would tell a client that I made their logo in Adobe Illustrator, even though I used one of its plugins.

Quote: "If DBPro was thread safe, it would be easy to do things like streaming worlds, only loading in objects as and when you need them without locking the game up whilst you do so."


I personally find it difficult even in 'thread safe' environments such as .NET. It is just not easy to do anyway, because you have to keep resources seperate; two cpus or threads must not be allowed to access the same resource at once; this is the rule in Visual Studio.

The following code is something I was playing around with some time ago; it uses the Styx plugin which demonstrates an object loading process; while running your regular loop. It shows that the code stops the threads from accessing the same information at the same time. Physics and AI have been used in it, to test compatibility:



Quote: "you're somewhat limited with how much you can do"


True there are limits, but Alduce can still multithread if he wants to; I just felt that it would not be good to leave him feeling that he can't do it when he can. It's like me saying you can't run Windows on a Mac, or you can't save DirectX files with Blender.

However Alduce, you don't need to even think about multithreading with what you mention there. You just need iterate progressively, like so:



Or you can use a timer to limit how long a process can run for:



Or you can use a timer to limit when a process can run:



There are plugins out there that make my code above look like spagetti.

You don't need to use multithreading for what you want.

Dark Physics/Dynamix, Lights, Net, AI will operate on seperate threads; with some you need to set them to do so. But you don't need to get so involved.

Use multi-threading or seperate processes (.exe), when the process of progressive iteration of one item takes too long. I am using it to keep my game running whilst the engine streams content from the network, windows modal dialogs or focusable controls and the hard drive; everything else is iterated progressively in the same exe (without giving away too much).

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 10th Nov 2012 20:29 Edited at: 10th Nov 2012 20:30
Andrew and Chris, in first thank you very much for support.

@Chris:
I really want to do some test to understand If I got correctly what you mean. My english is at my limits and I need to know If I understand good what you wrote.

I really like to know there are some ways to optimize the speed of my program, especially because I really need to speed up the frame rate (actually too slow for what I would)

I will make some tests and I will update my results!

For now thank you!
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 10th Nov 2012 21:50
OK

It is best that you post your code here, and we can all take a look at what is wrong. Post your code in [ code ][ /code ] tags.

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 10th Nov 2012 21:55
Quote: "OK

It is best that you post your code here, and we can all take a look at what is wrong. Post your code in [ code ][ /code ] tags."


Ah thanks! but my code is yes "simple" but is already a bit long..
If for you is not a problem I will put it!
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 10th Nov 2012 23:39 Edited at: 10th Nov 2012 23:45
Don't worry if it is long; go ahead. Post it up. I have to go to bed soon, should be back tomorrow.

The main thing is to pin point the bottle neck, as shown here



Time how long parts take; you should not exceed 10 from 'Do' to 'Sync'. (TimeTaken should be less than 10, in general...) Then use the timer to time the parts that take too long

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 11th Nov 2012 11:26 Edited at: 11th Nov 2012 11:37
Thank you!

A question:
if my program takes more than 10 ms to "work" the code from DO to Sync?
You mean that If my program takes more than 10 so you CUT OFF the main program cycle to start the next main program cycle?

If yes so I don't understand well.. 'cause in this way sure you make the main program cycle not exceeding 10ms but you get the code cut so some operations and calculations were not performed!!!





Here the code (without the code called with some gosub command).


There was 2 PIECES OF CODE THAT ARE A BAD HIT TO MY SIMULATION SPEED. THESE CODES ARE REALLY LITTLE BUT MAKING SOME FOR CYCLES. EACH OF THESE FOR CYCLES ARE CYCLING 3000 OBJECTS (THE AIR PARTICLES).
Here the name of these 2 pieces of code:

MOVING AIR PARTICLES
AIR PARTICLES MUST TO STAY IN THE AIR ZONE
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 12th Nov 2012 11:06 Edited at: 12th Nov 2012 11:10
Quote: "If yes so I don't understand well.. 'cause in this way sure you make the main program cycle not exceeding 10ms but you get the code cut so some operations and calculations were not performed!!!"


You postpone the calculations that do not need to be performed more than 5 or so times per second.

Take the illustration of YouTube; when you load a youtube page, the text shows up first, then the interface elements. The user can still use the page even though the video is not ready yet. The video gradually gets streamed into playback; and that's what you need to do with heavy duty tasks; do them progressively.

If you had to wait for the video to load before you could use any buttons; what a long wait that would be indeed. Consequently the browser is still looping through the code which allows the user to interact while the video is loading; whilst progressively loading the video, as it plays.

Now to your code. I can't run it because it uses images; so I will adjust it without testing it.

Are you 100% it's the 3000 object loop, it does not look as bad as I thought it would.

For now; try to change this:


to either a timed process



Or this, a progressive process:



Test which one works best for you.

Remember that Dynamix can multithread; and be hardware accelerated? You haven't really made much use of it; the above uses hard coded CPU calculations, although it does not look as bad as I thought it would.

Try to just create a hollow box in a 3d program, add it as a Dynamix mesh, and hide it. Stopping escaping air particles is something your graphics card can do. This requires less code.

If not that, then try to use Dynamix triggers; put the particles back in a trigger box if they escape; store their old position.

I'll be honest with you; I am new to Dynamix; I used DPhysics for a few years.

Check out the help file. And give this a try; it's a must have.

Have a good day.

Login to post a reply

Server time is: 2026-07-08 03:02:42
Your offset time is: 2026-07-08 03:02:42