News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Calculating Pi efficiently ...

Started by jamesl, July 14, 2012, 02:25:37 PM

Previous topic - Next topic

jamesl

Hi All,

It has been quite some time since I last visited and I trust all are well and happy?

I saw this web page http://www.numberworld.org/misc_runs/pi-5t/details.html
on calculating Pi to 5 trillion digits. It appears to have taken a great many days.

I wondered, could Assembler be used to quicken the process, possibly even offloading the
calculations to graphics cards?

Rgs, James.

Mr Hippy

Using assembler versus a compiler will make a difference in the benchmarks. Whether it is noticeable or negligible depends on a few factors. You can use the CPU/GPU (or APU) for calculating. You can also use the supported instruction sets on the hardware to get precision, efficiency and speed. A second factor would be the compiler that is being used. Modern compilers are constantly being updated to use newer code generating methods. You could instead write it by hand. That makes you in control of what is happening, and how you want it done. You can still run performance tests whether you wrote it by hand, or you let a compiler do the dirty work. That way you can find where the bottlenecks are (if any), and work on that section of the code (or assembler output of the compiler.)

I will provide an opinion on this, though. I will say that it would mostly fall on the hardware,  computer and software design; this would be the storage and processing technologies used; the throughput of the hardware, cables and connectors; even the operating system being used (multitasking abilities, memory management capabilities, etc.). [I feel that I may be missing something, any others?]

The are just many factors to this. It all falls on proper designing.

Vortex

My apologies but what is the meaning of calculating 5*10^12 digits of pi? It does not serve any purpose. Studying the expansion of Taylor series is much more logic.

raymond

QuoteIt does not serve any purpose.

You could compare it to climbing Mount Everest. It's simply because there's a challenge.
Whenever you assume something, you risk being wrong half the time.
https://masm32.com/masmcode/rayfil/index.html

MichaelW

From what I recall of the methods typically used for this they are very complex, and so would probably be difficult to implement in assembly.
Well Microsoft, here's another nice mess you've gotten us into.

jamesl

My requirements for calculating Pi are a little simpler than the example posted.
I don't need to calculate in parallel which would make things slower but hopefully simpler to do.

dedndave

i don't think the GPU can be much help, really
but - SSE might be useful

Mr Hippy

https://en.wikipedia.org/wiki/GPGPU

dedndave, a GPU would be excellent for computing. Using both CPU(s) and GPU(s) parallel would be perfect.

Ghandi

A lot of conditionals decide whether or not GPGPU will help, algorithm choice being one of the important ones.

HR,
Ghandi

dedndave

getting data into and out of the GPU can be a bit of a bottle-neck   :P
and - the instruction set is, of course, geared toward graphic operations
at the end of the day, SSE is probably going to be more efficient