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 / I really would to use all my little sweet cores! :)

Author
Message
Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 16th May 2013 13:17 Edited at: 16th May 2013 13:19
Hi, I was thinking about the impossibility of take advantage of multi core cpu.
So I am thinking about a strange thing:

1) I make my first EXE that consist in the main project code.
This EXE will write some variable values in a txt file
2) I make a second EXE that will read these values, will make a lot of calculations and will write a second txt file too.
3) First EXE will read the values of second txt files to make all his operations.
4) I don't know about, but perhaps exist some software (or maybe windows itself) that can order what core must to execute my EXE files. So I order my first core to handle my first EXE and I order my second core to handle second EXE...
I shoult to use memblock instead txt files too! not?


this is just scifii or I can really do that??
And, if I could to do that so do you think I can get some advantage in performance?

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th May 2013 13:48
You could do that, but I think you'd loose any advantages by the overhead of writing to disk anyway, even if it is a SSD.

You can use shared memory however, in that way both your programs can access the same memory. IanM's plugin collection provides some lock functionality to keep just one program mutating the memory at once. I'm unsure if they are completely exclusive locks or if you can still read on the process that doesn't have the write lock.


"Why do programmers get Halloween and Christmas mixed up?"
Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 16th May 2013 13:50
Do you mean the use of memblock commands so?
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 16th May 2013 14:44
If I remember correctly shared memory in Windows actually uses the page file so is as slow as writing to hard disk. This might not be true, needs some confirmation.

In the past for inter process communication I have used sockets, so you can use some TCP networking plugin to do this (multisync or DarkNet). I think this would be the simplest way to do things as you don't have to explicitly synchronize the processes with a lock or mutex.

Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 16th May 2013 14:59
Sorry eh but I can do simply :

1) first EXE use memblock command to "store" a value
2) second EXE use memblock command to read the value stored!

Not?
Sergey K
20
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 16th May 2013 15:17
by creatying new files and deleting them over again you ruining your HDD. dont do that

i suggest TCP networking as already some people commented..

Advanced Updater for your games!
Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 16th May 2013 17:13
Not sergey K I don't want to create and delete a file!

My first idea was to Write in a file txt and to read it!.
Second idea was to write and read memblock (memblock can be write and read from each the EXEs)

And about to use TCP to pass values from an EXE to another.. emm I think it's just over my knowledges..
Dar13
15
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 16th May 2013 17:17
When you write to a file, you create/overwrite a file. That's how the command works.

Your second idea would only work if you set up a memory pool between the two executables like what Rudolpho. Those are not the memblock commands, I believe you can do it through the Matrix1Utilities though.

WTLD has been put on indefinite hold.
A new project is under initial development now.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 16th May 2013 17:19
Do not use files to swap data between running applications.

I'll be yet another person to advise you to use TCP sockets.

But more importantly, stop trying to get DBPro to utilise multiple cores and focus on optimising what you have already! You'll spend far too much time implementing a feature to use multiple cores, when you could be working on your game. By the time it's finished, PC technology will have moved on rendering any advantage you thought you were getting useless.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 16th May 2013 17:35
Mobiius you are right but unfortunately I reach my maximum code optimization knowledge and I ensure you that I tried ALL (all from my knowledge) I get from 7 to 9 fps more than before the optimization but currently I reach the maximum.. (so and so 2 months optimizing all the optimizable..)
If I finish to search other way to get more fps is really cause I am over of ammo here..
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 16th May 2013 20:13
Utilising more cores won't magically make your game run any faster. Simplifying things will. If your game is slowing to a crawl, you need to think about getting your game engine to process less data per game loop. (Halving the amount of work completed per loop = double the FPS*)

Perhaps you could look at splitting processing to every other loop?
Using less physics objects?
Depending on what your actually doing, do you really need physics objects at all?

There are lots of ways you could optimise your code if you think about it logically.

*depends on what work your doing every loop.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 16th May 2013 21:15 Edited at: 16th May 2013 21:23
Some methods of sharing data between programs

Assuming this is a medium to small sized game; not an Activision/Blizzard Entertainment AAA title.

Networking
The DarkNET plugin comes with examples of how to share data with TCP; you just need to use these examples to aid your effort to share between applications.

If your understanding of TCP is bad; why is it bad? Possibly because you've not yet learnt it. The DarkNET product is a great way to learn, let alone succeed.

Files

If your need requires sharing a few bytes of data every half an hour or so or if the data is a database then there is nothing wrong with using files[/i]; loads of programs including FPSC Editor; software created by the Valve Corporation and Microsoft use file sharing when performing a shared operation that need not upset any firewall or get into port forwarding on rear situations with fussy firewalls and routers. Usually for dealing with one off tasks every 10 minutes or so.

File Mapping
Microsoft created an information sharing process called file mapping.

Everybody who uses DBPRO has used file mapping sub-consciously every time they compile a DBPRO program.... This is how compile progress is shared between DBPCompiler.exe and your IDE... Everyone who uses FPSC has used file mapping sub-concuously when they build the arena/game; the progress is shared similarly.

Quote: "File mapping is the association of a file's contents with a portion of the virtual address space of a process. The system creates a file mapping object (also known as a section object) to maintain this association. A file view is the portion of virtual address space that a process uses to access the file's contents. File mapping allows the process to use both random input and output (I/O) and sequential I/O. It also allows the process to work efficiently with a large data file, such as a database, without having to map the whole file into memory. "
article

DBPRO has file mapping commands as a standard
Quote: "WRITE FILEMAP STRING : WRITE FILEMAP STRING Filemap Name, String
WRITE FILEMAP VALUE : WRITE FILEMAP VALUE Filemap Name, Value
READ FILEMAP STRING : Return String=READ FILEMAP STRING(String Value)
READ FILEMAP VALUE : Return DWORD=READ FILEMAP VALUE(Filemap Name)
"







This is pretty good for easy database sharing, as stated in the definition; it maps small chunks of data into RAM as and when such data is needed; so this is good for sharing of large file processing; but is also handy for one off operations in small EXEs if you do not want to make network port connections and have the user prompted to allow network accesses just to do something small.

Windows Messages

Again; everybody who uses any Windows program which communicates with another window, such as Microsoft Office, Windows Presentation Foundation (Vista, 7 & 8 interface features), ActiveX and to a degree Dark GDK. NET has used Windows messages frequently.

Pretty much every keystroke made to write this post is a command sent via a windows message. You can also use windows messages to send information to any user control or window.

At the moment, the easiest method is to use Styx or a windows GUI plugin such as BBB GUI using window text or properties. But the fastest way is not as easy; you need to use the custom window message handle using API's:
Quote: "Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.

To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function."


SendMessage API reference

Mutex (Shared memory banks)

Michael said
Quote: "shared memory in Windows actually uses the page file so is as slow as writing to hard disk. This might not be true, needs some confirmation."


When I use this the hard drive light does not come on; hopefully it is not true. However, here is a thread about using Mutexes and shared memory banks.

This closely resembles your idea:
Quote: "Second idea was to write and read memblock (memblock can be write and read from each the EXEs)"


However you need Matrix1, and you would use Memory Banks. I've used this to get my character editor to talk to my engine.

I really would to use all my little sweet cores!

Do consider what Mobius stated, but also consider this.

Having two EXEs will not guarantee two seperate cores; you have no control over this it seems. Consider using other types of optimization in combination with having two exes. I'd suggest using one EXE for the game, and the other for updates, installation, advanced GUI and loading screens.

Most video games in the industry do not need multi-cores to run smooth; but sometimes it is good to still be able to use a program whilst something intense such as loading a huge object is being performed; your idea can work, but only if you do your research. You will need to sleep the CPU in each EXE once and a while to share some of the CPU usage between them.

Another way to organize you program overhead is to make good use of the GPU by using shaders. But even more so; research is required to stipulate what kind of calculation is suitable for a GPU shader script, and what is better suited in hard code.

Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 16th May 2013 22:12 Edited at: 16th May 2013 22:14
Wow.. Chris Tate really thank you for your very complete answer!! 90% of what you wrote is far over my my skills but remain pretty enchanting how many methods exist do share informations between 2 exe files.

I trapped myself in a really complex project.. my engine must handle hundred of super fast collision at less than a second.. .
I know that my imagination and what I want is always over what I can but I really like to try (even if I am aware of the immense difficulties.

Thx to mobiius and your words I got a sudden idea before to start to seriously take in consideration to use the methods you wrote..

My project has 8 main piece of code (one of these handling collisions and particles repositioning),so all of these piece of codes are running one after other in every single main loop cycle.
So I can try to make that in a single main loop cycle ONLY ONE PIECE OF CODE must be executed.

1st main loop cycle ---> first piece of code
2nd main loop cycle ---> second piece of code
3rd main loop cycle ---> third piece of code
...
8th main loop cycle ---> eighth piece of code

and then again..

9th main loop cycle ---> first piece of code
10th main loop cycle ---> second piece of code
etc etc

Sure I will obtain a not precise as now execution but probably fps will get a boost!
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 16th May 2013 22:55 Edited at: 16th May 2013 22:59
Ahh, I see what you are experiencing.

If I were you, I would really step up with the times and use PhysX (Dark Dynamix). From what I have seen, and according to NVidia, using the PhysX driver to handle your particles and collisions will improve performance on most PCs, especially PhysX hardware accelerated ones. The less you code in DBPRO the better the performance, usually.

Sparks is also good; nicely integrated with DBPRO's conventional procedural programming style. Make use of box based collision zones; far more less CPU intensive than collision alternatives. Again, check the example files for guidance.

Bare in mind that DBPRO isn't optimized out of the box, you have to optimize. With FPSC, lee used segments to process parts of the level that needs processing. With Valve source, they used visibility portals, in simple terms these are areas that hide areas they cannot see when the player is in one. You can improve performance using a combination of multi-limb objects instead of polygon dense single mesh objects so that DBP's frustrum culling can remove limbs out of view from rendering; use lots of limbs.

There is Dark Occlusion which is a plugin I have not invested in, which claims to improve performance as-well. I have not personally seen it as useful for my work, but it sounds promising.

Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 16th May 2013 23:37 Edited at: 16th May 2013 23:39
Yeah chris I am already using DarkDynamix! as my collisions!

All these collisions are in the physic world and I am using not propely the "dark dynamix particles system" but thousand of little darkdynamix cubes.
I not using particles system cause from Matty H words the particles can't influence (push) the shape they are hitting but just they can only slide over other shapes.
I need that these thousand of little cubes can push the shapes they are hitting so nothing "particle system".


So I am using DBPro cubes with their DarkDynamix physic/collision counterpart.

This is damn slow just when the actors speed is high. (probably more speed more collisions in a cycle so more calculations)

The strange thing is I have a GTX590 with 2 cores. 1 of this core can be used ONLY to handle physX but when I choose this option I get no improve in framerate.
I think (from forum words) DarkDynamix can use another core in my CPU (like some other plugins) but seems not taking advantage from a GPU dedicated to physic.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 16th May 2013 23:47
I think you should fake the effect of particles hitting your plane as it's clearly very inefficient at simulating it with physics.

If I were you, I'd use physics particles to simulate the displacement of air and manually add lift to the wings instead.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 17th May 2013 00:17 Edited at: 17th May 2013 00:19
Ehh the thing is complex.
Really right that about performances this method is inefficent but I ensure you it's really realistic!!
I tried to make a flight engine without air particles collisions (good effect and super fast fps) but never I could compare the result when I am using the air friction in the airplane body!!
More of that, when you using flaps, rudder or tail stabilizators so you see a damn near true aircraft surfing inside the air!
just exploiting the physics of darkdynamix!!

The effect, in spite of I am using only 1200 air particles (I really would to use at least 6000.. ehhh..) is great! a lot of aereodynamic effects can be added just starting from these collisions! I am truly attached to this "simulation method" cause I see a lot of always different and very realistic situations (of course also applying flight mathematics for lift, drag etc) to think to change way of development. Sure I am on the wrong programmation language for this project and the project itself its really extreme.. I know that but its working good using 1200 particles!! 24fps of average. The problem born cause I would to ADD a lot of other air particles.. more air particles more precision and more realism!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th May 2013 01:34
Not saying you shouldn't try, but why do you think you need multiple cores so badly? Games more advanced that what DB has done so far have existed long before multi-core CPUs.

"You're all wrong. You're all idiots." ~Fluffy Rabbit
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 17th May 2013 02:47
If you want more speed, stop using hundreds of small dynamic cubes for particles, it is too slow to be feasible. Either find a way to fake or mimick the effect or program an algorithm that simulates the air.

Quote: "Not saying you shouldn't try, but why do you think you need multiple cores so badly? Games more advanced that what DB has done so far have existed long before multi-core CPUs.
"


What he said.
Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 22nd May 2013 00:52 Edited at: 22nd May 2013 00:53
Ok, changed CPU, from AMD Athlon X2 270 3,4ghz to AMD FX-6300 3,5ghz 6cores and I can tell you all that there is a really good performance bost!

With the airplane stopped or slow there are so and so 20/25fps more than before!
and with airplane at full speed (so the wrost scenario for my game)so with a lot of super fast collision I got 10/12 frames per second more!
So before at (example) 500km/h I got 12/13 fps and now in same situation I get 23/24 fps!

Probably this bost is caused by more modern cpu architecture and more cache memory (and maybe less bottle neck for my GTX590) but these fps more are like gold here!
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 22nd May 2013 01:14
I just hope your not planning on having other people play your game. lol

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Alduce
21
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 22nd May 2013 01:32
Quote: "I just hope your not planning on having other people play your game. lol"

I think when my game will be finished so (and this is not a sure thing)... likely there will be 14cores processor at really cheap price...

Login to post a reply

Server time is: 2024-05-01 14:47:37
Your offset time is: 2024-05-01 14:47:37