SERVING THE QUANTITATIVE FINANCE COMMUNITY

• 1
• 2

Topic Author
Posts: 34
Joined: October 12th, 2005, 5:23 pm

How fast can a computer calculate this?

how long would it take a "normal" PC (1GB RAM and 2.5 GHz) to run 2.5 *10^24 (2,500,000,000,000,000,000,000,000) simple multiplications, each multiplying two 4-digit numbers?thanks for your help.t

farmer
Posts: 13477
Joined: December 16th, 2002, 7:09 am

How fast can a computer calculate this?

I entered this C# program into Visual Studio, compiled it, and ran it on a 2.5 mhz computer using about 98% of processor time:Quote double target = 0; DateTime starttime = DateTime.Now; DateTime endtime = DateTime.Now; for (int i = 1; i <= 1000000000; ++i) { target = 22.34*9976; target = 2234*.9976; target = 1111*2222; target = 2234*9976; target = .1115*9976; target = 2.238*1976; target = 223.4*9976; target = 99.99*9176; target = 9999*9946; target = 2234*227.6; } endtime = DateTime.Now; textBox1.Show(); textBox1.Text = "10 billion 4-digit multiplications\r\n" + "starttime ticks:" + starttime.Ticks.ToString() + "\r\n" + "endtime ticks:" + endtime.Ticks.ToString() + "\r\n" + "difference:" + (endtime.Ticks-starttime.Ticks).ToString() + " nanoseconds";It took about 20 seconds, and I got this output:Quote10 billion 4-digit multiplicationsstarttime ticks:632823396024843750endtime ticks:632823396181562500difference:156718750 nanosecondsI assume you would want to at least use assembly language and design your own custom multiplier if you were doing many times more than that. What's the best you could hope for, four seconds? Let's suppose you got it to 1 second for every 10 billion. You're talking... good night.
Last edited by farmer on May 3rd, 2006, 10:00 pm, edited 1 time in total.

Topic Author
Posts: 34
Joined: October 12th, 2005, 5:23 pm

How fast can a computer calculate this?

thx - very helpful. you can also assume that if you do this further away from the cpu (i.e. matlab etc) that the time is even slower.if you assume 1 second per 10 billion - this problem would take you about 8 million years to compute.

Posts: 11048
Joined: February 1st, 2005, 11:21 pm

How fast can a computer calculate this?

QuoteOriginally posted by: TedSpreadthx - very helpful. you can also assume that if you do this further away from the cpu (i.e. matlab etc) that the time is even slower.if you assume 1 second per 10 billion - this problem would take you about 8 million years to compute.There are faster computers around than your laptop.

Topic Author
Posts: 34
Joined: October 12th, 2005, 5:23 pm

How fast can a computer calculate this?

take 1,000 times faster than a laptop, then take 1,000 of those computers (big bens or whatever else) - you still need 8 years to solve it. you probably figured out that this is a simplified version of the actual problem (which i am sure you would be able to solve). i am not really in the business of multipying random 4-digit numbers.i had a fraction run on a 1,500 cpu's server farm and have been running into capacity issues.even if you do this on Teragrid you'll have a problem.
Last edited by TedSpread on May 3rd, 2006, 10:00 pm, edited 1 time in total.

DominicConnor
Posts: 11684
Joined: July 14th, 2002, 3:00 am

How fast can a computer calculate this?

Actually, it's longer than any of the estimates above, and is in fact impossible to do accurately , regardless of time allowed.Given that you only have 1GB of RAM, the numbers have to be read in from disk, so you need at factor of 20-50 here.But you can't read in 10^24 numbers from disk.The undetected uncorrected error rate of a disk varies from 10^-11 to 10 ^ -13Short version is that you read in that much data you get terabytes of garbage, and no way of knowing which bits are garbled.Even with a lot more RAM cosmic ray impacts, timing issues etc mean that the output data is noise.The same rough numbers appy whether you have one computer for long time, or many for a shorter period.However, I rather suspect that if TedSpread gave us more detail on the problem there would be a trick that would dramatically ease the problem.There are of course not many 4 digit numbers, and thus there may well be a trick to use the 1GB of RAM to trad space for time.There has always been a most complex c

SchroedingersCat
Posts: 3
Joined: April 27th, 2006, 12:12 pm

How fast can a computer calculate this?

There are slightly fewer than 10^8 permutations of 2 4 digit numbers, so the first response showing 10^9 calculations in 20 seconds would have calculated all possible permutations. Depending on the actual application calculating all combinations once may be enough...or creating an optimized "times table" in memory should allow for optimizing the answer time.

alexmc
Posts: 1
Joined: May 3rd, 2006, 11:22 am

How fast can a computer calculate this?

Unfortunately that test doesnt prove anything. I dont know about the C# compiler but I would expect it to have *some* kind of optimisation. There is no reason to expect that it didnt just remember those multiplications each time it went round the loop. You would probably need the multiplications to be different each time for a proper test. (However dont just use a random function because that will take a lot longer than the multiplication.

RedeR
Posts: 75
Joined: March 4th, 2002, 3:00 pm

How fast can a computer calculate this?

Talking about optimizations. I tabulated your C# as C++ :-----------------------------------------------------------------------------------#include <iostream>void test(){ unsigned start = clock(); double target = 0 ; for (int i = 1; i <= 1000000000; ++i) { target = 22.34*9976; target = 2234*.9976; target = 1111*2222; target = 2234*9976; target = .1115*9976; target = 2.238*1976; target = 223.4*9976; target = 99.99*9176; target = 9999*9946; target = 2234*227.6; } unsigned end = clock(); std::cout << " elapsed " << (end-start)/1000. << " secs " << std::endl;}int main(){ test(); return 0;}-----------------------------------------------------------------------------------and compiled it with gcc (mingw) on windows xp:g++ -O -Wall dummy.cpp && a.exe elapsed 0 secs Since it does absolutely nothing at all, gcc recognizes properly it is useless and takes no time to execute.

farmer
Posts: 13477
Joined: December 16th, 2002, 7:09 am

How fast can a computer calculate this?

For all I know the time variables were actually references to the same thing, and the time difference is the difference between when it strobed them into the two parts of the final equation. But I do know it spent 20 seconds doing something, and it was about 10 times as long as when doing 1/10th as much.QuoteSince it does absolutely nothing at all, gcc recognizes properly it is useless and takes no time to execute.Geez, I just downloaded that compiler you used, recompiled my whole trading system, and promptly got a blank screen. It recognized properly that my whole life is useless. The only line it will actually compile is some variation ofQuotestd::cout << "just shoot yourself, loser";

RedeR
Posts: 75
Joined: March 4th, 2002, 3:00 pm

How fast can a computer calculate this?

Just for your convenience, I put the same code into MS C++. And, at least in release (optimized) code, he is as clever as gcc, and takes 0secs.However, one way to bypass the optimization is to declare target as volatile.I have also to rewrite lines like target = 22.34*9976; as target = 22.34; target*=9976; for else these would be simple assigns (he compiler computes 22.34*9976 and writes an assign to target).Then 1 000 000 000 (1E9) mults take 700secs in MS debug, 18.8secs in release. 120secs with gcc -O3 (ouch). I have to specify gcc -O3 -msse2 then it takes 17.3secs.You should take GCC seriously. Not only has it been much more C++ compliant than MSC for a long time (allowing to play with great libraries such as Boost), but it is also much more faster. I get a factor of 2 or even more in certain intensive computations. Another very useful thing with gcc is that you can use (need to tweak it to use it with mingw/gcc) distcc, that splits the compilation of a big project across your network. You may recompile your whole trading system in about tenths are less than it currently takes.QuoteOriginally posted by: farmerFor all I know the time variables were actually references to the same thing, and the time difference is the difference between when it strobed them into the two parts of the final equation. But I do know it spent 20 seconds doing something, and it was about 10 times as long as when doing 1/10th as much.QuoteSince it does absolutely nothing at all, gcc recognizes properly it is useless and takes no time to execute.Geez, I just downloaded that compiler you used, recompiled my whole trading system, and promptly got a blank screen. It recognized properly that my whole life is useless. The only line it will actually compile is some variation ofQuotestd::cout << "just shoot yourself, loser";

DominicConnor
Posts: 11684
Joined: July 14th, 2002, 3:00 am

How fast can a computer calculate this?

I'd argue about GCC being much more compliant than VC++, and I'd like to see the benchmark you favour that shows VC++ code to be inferior to GCCI agree you should take GCC seriously but it ain't a silver bullet.

linuxuser99
Posts: 835
Joined: March 26th, 2004, 2:51 pm

How fast can a computer calculate this?

>> I'd like to see the benchmark you favour that shows VC++ code to be inferior to GCCNone of the benchmarks I've seen would bear this out. GCC = nice feee very compliant, but not faster. Now the Intel compiler.....

RedeR
Posts: 75
Joined: March 4th, 2002, 3:00 pm

How fast can a computer calculate this?

a) Regarding compliance, VC++ has made huge progresses since 2003 (according to for instance, successful boost libraries compilations). However, I cope with my application compiling on both VC++ and g++.b) My favoured speed test is the computation of 250 deltas on a 5 year semiannual mezzanine tranche of CDO of 250 names, using the recursive method. With the same code, it takes- 58 seconds with visual 2005- 28.5 secs with gcc 4.0- gcc 4.2 sets up a new astonishing best time of just 18secs. However, it tooks an insane time to compile, used huge amounts of ram, and produces an insanely fat exe.QuoteOriginally posted by: DCFCI'd argue about GCC being much more compliant than VC++, and I'd like to see the benchmark you favour that shows VC++ code to be inferior to GCCI agree you should take GCC seriously but it ain't a silver bullet.

DominicConnor
Posts: 11684
Joined: July 14th, 2002, 3:00 am

How fast can a computer calculate this?

That big a gap surprises me.I take it you turned all the optimisations on ?
Last edited by DominicConnor on May 16th, 2006, 10:00 pm, edited 1 time in total.

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...

 JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...

GZIP: On