I see many c & pascal source code to calculate pi(3.1415926535897932384626.....)
And I wander how fast it will be if I code it in asm?

sorry for my poor english. :grin:
Posted on 2003-07-16 04:40:58 by lllaaa

And I wander how fast it will be if I code it in asm?

Depends on the CPU speed ;)

Google has a pointer to the answer: http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=utf-8&q=.asm+masm+calculate+OR+approximate+pi+&btnG=Google+Search

http://www.programmersheaven.com/zone5/cat18/index.htm - look for "AsmPI" on the page :)
Posted on 2003-07-16 06:38:35 by scientica
CPU speed is somewhat irrelevant in this case since this is primarily a comparison of the relative speed between code written in assembler and code written in a HLL language.

If the assembly code is optimized for the system you are using, it will DEFINITELY be faster than code written in any other language.

If you want to calculate PI with only up to 18 significant digits, this can be extremely fast and simple in assembler. That constant is already hard coded in the FPU with that precision. If you want to establish a new record for the number of decimal places of PI, I hope you have a lot of patience.

Raymond
Posted on 2003-07-16 08:38:15 by Raymond

If you want to establish a new record for the number of decimal places of PI, I hope you have a lot of patience.

And a "titz-ripper" fast super computer if you're aiming to become the highest precision record holder, there are dedicated servers around the world with equally dedicated pi-geeks (or is it pi-greeks ;P ), they've been up and running for years, it'll take sometime to catch up.
Posted on 2003-07-16 12:56:57 by scientica
Posted on 2003-07-19 11:48:29 by Poimander
fldpi

...probably not what your looking for tho ;)
Posted on 2003-07-20 20:47:03 by NaN
I don't get it

The only practical application for PI would be about 3 digits past the decimal point.

The number is transindental the same as the natural base ...so whats the point?
Posted on 2003-07-20 23:07:16 by IwasTitan
try searching for Borwein's formula or Gauss-Legendre algorithm or Ramanujan algorithm.

there are others but these are the ones I can remember... I can't guarantee their accuracy to X digits, since I've never implemented any of these in real life. Try searching. :grin:

IIRC, PI's can be use to seed a pseudo-random number generator... and construction/engineering stuff... and a rumor I heard that Cray Research is using the Ramanujan algo to calculate large values of PI to verify correct execution at boot time.

Don't ask me why the stuff above happens... I just read it from somewhere. I can't remember. :grin:
Posted on 2003-07-21 11:52:59 by arkane
A few years ago, an extraction algorithm was discovered that can calculate the Nth digit of Pi (without having to know any of the previous digits). So, I think the whole quest to calculate Pi is kind of pointless, especially now.

And Pi has been proven to be irrational, so no matter how long you calculate, you'll never reach a final value. And as IWasTitan mentioned, it's practical use hardly ever exceeds a few dozen decimal places.

Why not waste your clock cycles on something worthwhile, like finding a cure for cancer or something. ;)
Posted on 2003-07-21 13:52:51 by iblis
Programming fast algorithms in pure assembler is inpracticable. My own implementation of Ramunjan type algorithm of the Chudnovsky Brothers (one of the fastes Algos.) is implemented to about 80% in assembler. More where possible but is pointless. The needed Algorithms are far to complicated to do it all in assembler. My own implementation calculate Pi with 1 Million decimal digits in about 13 seconds on P4 1.5GHz.

By the way: it's Borweins formula to calculate digits of Pi. But there exists today no such formular to calculate the decimal digits with this formular (only binary). The complexity of this algo. is higher if we want all succesive digits as any other algo.

Hagen
Posted on 2003-07-24 08:03:42 by Hagen
Found a program that calculates pi in "pure" assembler".

Raidu
Posted on 2003-08-02 06:59:42 by raidu
iblis: altought that Bailey-Borwein-Plouffe Algorithm is qite interesting, I wouldn't say that it's fast.
Well, there's some more algorithms: Pi Formulas.
Posted on 2003-08-02 18:02:38 by iwabee
It's a digit extraction algorithm, it doesn't need to be fast.
Posted on 2003-08-06 10:39:54 by iblis

iblis: altought that Bailey-Borwein-Plouffe Algorithm is qite interesting, I wouldn't say that it's fast.
Well, there's some more algorithms: Pi Formulas.


Slow ?
Check the ASM implementation here
It's the current record in hexadecimal digits.
Posted on 2003-08-08 12:09:00 by MCoder
multiply it's performance with all needed bits for Pi upto these bounds, then it is slow compared to most other algorithms. It depend on the goal what we want to compute. If we want only one bit on specific position then it is the fastest known one.
Posted on 2003-08-08 17:08:35 by Hagen
Jason P's website has source codes to pi programs, some of them are in assembly:

http://www.boo.net/~jasonp/pipage.html

If you want to try your hands at breaking some size and speed records, Stu's Pi Page has a list of what you'll be up against:

http://pages.istar.ca/~lyster/pi.html

Good luck!
Posted on 2003-08-12 00:06:54 by PiGeek

Slow ?
Check the ASM implementation here
It's the current record in hexadecimal digits.

My mistake. I tried to use base 10 instead of 16 :(, but what can you expect at 2AM...
BTW. what kind of storage device are they using? Goddamn! 1 000 000 000 000 000 bits is nearly 114 TERABYTES!
Posted on 2003-08-13 18:08:06 by iwabee


My mistake. I tried to use base 10 instead of 16 :(, but what can you expect at 2AM...
BTW. what kind of storage device are they using? Goddamn! 1 000 000 000 000 000 bits is nearly 114 TERABYTES!


Iwabee, it seems you missed the point of the BBP algorithm: You can use it to calculate any hex digit of Pi without needing to calculate any of the preceding digits nor do you need to store any of the preceding digits.
Posted on 2003-08-14 00:17:29 by PiGeek
I understood that. It's the other part I don't understand: why to calculate Pi if you are not storing it? Well... the 114TB part can be the answer, BUT IT'S NOT THE POINT! It's like deverlopin a program fo several years only to delete it after it's compiled. C'mon, what's the point?!?!
Posted on 2003-08-14 09:03:02 by iwabee
There is no point.
Posted on 2003-08-14 09:10:48 by iblis