Welcome, Guest. Please Login.
Gravity Simulator
11/23/17 at 19:38:01
News: Registration for new users has been disabled to discourage spam. If you would like to join the forum please send me an email with your desired screen name to tony at gravitysimulator dot com.
Home Help Search Login


Pages: 1
Send Topic Print
[Tony] CPU usage again (Read 4070 times)
EDG
Ultimate Member
*****


oh, crumbs!!!

Posts: 611
Gender: male
[Tony] CPU usage again
10/05/08 at 20:07:53
 
I just had a look at the task manager while I was running my 2840 sim, and saw that one CPU on my dual core computer (AMD Athlon64 x2 3800+ 2.01GHz) was being fully used and the other one wasn't being used at all.  
 
I mentioned this about a year ago, but this seems really crazy to me especially in this day and age where most (if not all) new PCs are at least a dual core (if not quad). Being able to use both/all of the CPUs at the same time could really speed up the running time of the simulations and enable us to produce longer and more complicated runs (especially if we leave it running overnight). Is there really no way that multicore functionality can be added here?
 
Otherwise, at this rate if I get a quadcore it'd be useless for gravsim - I could get a really fast 2.66GHz quadcore Q9450 but presumably it'd run as if it was a single 2.66GHz CPU, so it wouldn't be THAT much faster than the 2GHz CPU I've got already (unless the cache size makes a difference - my current CPU has 512K L2 cache per core, and the Q9450 has 3MB per core). And even if the cache size did make a difference I'd still have 3 CPU Cores just sitting there doing nothing.
Back to top
 

cpu.jpg

(formerly known as Mal)
View Profile WWW   IP Logged
Tony
YaBB Administrator
*****




Posts: 1051
Gender: male
Re: [Tony] CPU usage again
Reply #1 - 10/06/08 at 01:12:07
 
Unfortunately, I don't own a dual-core, so there's little hope of me programming to cater to one as I have no way of testing.  Gravity Simulator only uses 50% of my single-core's CPU cycles, and I've asked around if this can be bumped up.  I've been told no.  But then I ran it on a friend's laptop and it used 98%.  So that's the tricky part about owning only two computers, yet hoping the program is maximized for all computers.
 
I imagine that the advantage of running on a dualcore would be around 2x.  But the last few times I've made improvements to Gravity Simulator, I've gotten about 10x increased performance, way out performing a hardware improvement.  In the future, I'd be more inclined to search for speed in more code optimization, with hardware being a last resort (otherwise I'd have bought a faster computer already).
 
Additionally, from what I know about optimizing programs for dual-core, I don't think Gravity Simulator's engine is a good candidate.  You need to find blocks of code which can execute independently from each other, synchronizing only as often as necessary.  But the Gravity Simulator engine needs to take it one step at a time, as it's currently written.  If I had a dual-core to play around with, I might find ways around this.  One day...
Back to top
 
 
Email View Profile WWW   IP Logged
EDG
Ultimate Member
*****


oh, crumbs!!!

Posts: 611
Gender: male
Re: [Tony] CPU usage again
Reply #2 - 10/06/08 at 08:29:51
 
Well whatever your next computer will be, it'll definitely be a dual core at least. I don't even think you can get single core CPUs anymore (I don't see them on our supplier lists at work anyway). I'm surprised you only have a single core though.
Back to top
 
 

(formerly known as Mal)
View Profile WWW   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: [Tony] CPU usage again
Reply #3 - 10/06/08 at 08:49:47
 
Well I own a dual core also , but GravSim and also other programs I write only use 1 processor . I think this is a safe way to use a CPU ,allowing the second CPU performing other tasks .
Back to top
 
 
Email View Profile   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: [Tony] Performance
Reply #4 - 10/20/08 at 15:05:11
 
I've been thinking about speeding up GravSim .  
In some cases I think a serious reduction of computing time must be possible with little adaption . Unfortunately the case is limited .  
 
Suppose we have a system of N bodies , all gravitationally interacting .  
The number of flops is proportional to N*(N-1) , as the acceleration of N bodies is calculated due to N-1 other bodies .  
 
Suppose now one adds n small bodies to the system , such as asteroids .  
The program has to perform now (N+n)*(N+n-1) flops .  
 
But : as the bodies don't interact with each other their mutual interactions don't have to be calculated . The n bodies perform a path dictated by the N major bodies .  
So : the number of flops to perform the new system is : N*(N-1) + n*N  
 
If n>>N  the ratio of the flops needed is N/n .  
 
Fi : if we have 10 planets and 100 asteroids the system can run 100/10 =10 times faster ,  
for 1000 asteroids even 100 times faster ...!  
 
To perform this I think each body needs a flag which indicates if it is gravitationally influencing or not .  
Tony , whats your opinion?  
 
Back to top
 
 
Email View Profile   IP Logged
EDG
Ultimate Member
*****


oh, crumbs!!!

Posts: 611
Gender: male
Re: [Tony] CPU usage again
Reply #5 - 10/20/08 at 18:17:25
 
I tried a few speed tests on the computers at work - this is how many years got simulated in 45 minutes (with no orbit rendering) on these systems running a sim of two belts of 250 massless point asteroids with one jovian at 0.1 ecc between them at 16k timestep.
 
XPH32, Dualcore E2180 CPU 1MB Cache, 1GB 667MHz DDR2 RAM: 66 years and 11 months.
XPH32, Core2Quad Q6850 CPU 8MB Cache, 2GB 800MHz DDR2 RAM: 94 years and 10 months.
XPH32, Core2Quad Q9450 CPU 12MB Cache, 4GB 800MHz DDR2 RAM: 102 years and 5 months.
XPH32, AMD 3800+ dualcore CPU 512KB Cache, 2GB 533MHz DDR2 RAM (my current system): I think it was about 50 years, will have to do it again.
 
If these are anything to go by, even the fastest quadcore won't run sims that much faster than an older machine - you may be able to halve the time at most, but that's about it.
Back to top
 
« Last Edit: 10/21/08 at 00:28:57 by EDG »  

(formerly known as Mal)
View Profile WWW   IP Logged
EDG
Ultimate Member
*****


oh, crumbs!!!

Posts: 611
Gender: male
Re: [Tony] CPU usage again
Reply #6 - 10/24/08 at 08:53:39
 
Here's the sim I was using if anyone wants to run a comparison on their own machines. Just run it for 45 minutes with no orbit rendering, and then report how many years it's processed at the end. It might be interesting to see how fast people can run their sims.
Back to top
 

(formerly known as Mal)
View Profile WWW   IP Logged
EDG
Ultimate Member
*****


oh, crumbs!!!

Posts: 611
Gender: male
Re: [Tony] Performance
Reply #7 - 10/24/08 at 08:56:56
 
Quote from frankuitaalst on 10/20/08 at 15:05:11:
To perform this I think each body needs a flag which indicates if it is gravitationally influencing or not .

 
If you set the mass of the objects to be 0, then wouldn't that mean that they don't gravitationally influence anything? My 500 massless asteroids should just have calculations done on their orbits (due to the jovian), if the program is going through calculations caused by them then it's wasting processing time (because either way their influence should be 0, right?).
Back to top
 
 

(formerly known as Mal)
View Profile WWW   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: [Tony] CPU usage again
Reply #8 - 10/24/08 at 10:28:56
 
Yes , I think so . While the massless bodies don't have any influence they could be omitted in the calculations as sources of gravity . These bodies path is only influenced by the bodies having (enough ) mass.  
Back to top
 
 
Email View Profile   IP Logged
Tony
YaBB Administrator
*****




Posts: 1051
Gender: male
Re: [Tony] CPU usage again
Reply #9 - 10/24/08 at 11:29:16
 
The massless particles' influences are not computed.  
 
The source code is here:  http://www.orbitsimulator.com/cgi-bin/yabb/YaBB.pl?num=1160874415/6#6
The following line makes it skip most of the math if a particle is massless.
 
if (tM > 0) {
Back to top
 
 
Email View Profile WWW   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: [Tony] CPU usage again
Reply #10 - 10/24/08 at 11:49:42
 
Good to know !  
In most simulations I use a small mass ( 1kg ) to calculate them .
I'll definitively put them to zero mass !  
 
EDIT : the increase in speed when setting the low mases to zero is indeed fabulous .  
Thanks Tony .
Back to top
 
 
Email View Profile   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: [Tony] CPU usage again
Reply #11 - 10/26/08 at 00:35:03
 
Quote from Tony on 10/24/08 at 11:29:16:
The massless particles' influences are not computed.

The source code is here:  http://www.orbitsimulator.com/cgi-bin/yabb/YaBB.pl?num=1160874415/6#6
The following line makes it skip most of the math if a particle is massless.

if (tM > 0) {

Yes , the program takes account for the massless particles from if(tM>0) , but in the code just above there are two FOR  loops k to N and j to N which I think can be further reduced .  Don't you think so Tony ?  
Back to top
 
 
Email View Profile   IP Logged
Tony
YaBB Administrator
*****




Posts: 1051
Gender: male
Re: [Tony] CPU usage again
Reply #12 - 10/26/08 at 11:09:50
 
The massless particles still need to be accelerated by the particles with mass, so I can't completely ignore them.
 
I could  probably get a slight speed increase by dividing the objects into two arrays:  mass and massless.  That way I wouldn't have to execute the if statement.  But I don't think the savings would be that great.
Back to top
 
 
Email View Profile WWW   IP Logged
frankuitaalst
Ultimate Member
*****


Great site

Posts: 1507
Gender: male
Re: [Tony] CPU usage again
Reply #13 - 10/26/08 at 11:15:55
 
Quote from Tony on 10/26/08 at 11:09:50:
The massless particles still need to be accelerated by the particles with mass, so I can't completely ignore them.

I could  probably get a slight speed increase by dividing the objects into two arrays:  mass and massless.  That way I wouldn't have to execute the if statement.  But I don't think the savings would be that great.

Exactly. For the first array N*(N-1)/2 computations have to be done . For the massless ones : n*N , together N*((N-1)/2+n) , which can be compared with the (N+n)*(N+n-1)/2.  
If n>>N this can speed up a lot imo .  
Problem may be to keep the massless apart from the objects having mass, but I think this shouldn't be a big problem ?  
Back to top
 
 
Email View Profile   IP Logged
Pages: 1
Send Topic Print