HP Forums
Best programming language for handling array calculations in parallel? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not remotely HP Calculators (/forum-9.html)
+--- Thread: Best programming language for handling array calculations in parallel? (/thread-12823.html)



Best programming language for handling array calculations in parallel? - gomefun2 - 04-18-2019 03:00 AM

I have some experience in just about every major programming language.

I built some software in python for fun, but I want to now take the project in a more serious direction.

Basically, the program does calculations on what is essentially a 100x7 array (100 rows x 7 columns). I want to speed up the python code significantly. I was thinking of rewriting it in FORTRAN using GPU acceleration for parallel calculation (like CUDA cores on my NVIDIA GPU).

I have never done parallel programming. Basically, my program does math on this 100x7 array (100 rows x 7 columns) and not much else.

I want the fastest possible way to do calculations, would running FORTRAN with GPU support be the fastest way to do this?

My code is already very fast in python, but I want to speed it up more.


RE: Best programming language for handling array calculations in parallel? - KeithB - 04-18-2019 02:58 PM

I am going to guess Matlab with the Parallel processing toolbox:
https://www.mathworks.com/products/parallel-computing.html


RE: Best programming language for handling array calculations in parallel? - John Keith - 04-18-2019 03:57 PM

There are Python packages for parallel processing including GPU acceleration but I have no experience with them. May be worth a try before you switch languages.

Also some matrix operations are much easier to parallelize than others so the amount of speedup you will get depends strongly on the nature of the calculations.


RE: Best programming language for handling array calculations in parallel? - pier4r - 04-18-2019 07:00 PM

"Basically, my program does math on this 100x7 array (100 rows x 7 columns) and not much else."

what does it do? We may take it as input to push our calculators, you know it may be fun!

(Although a 100x7 matrix on the 50g can already take some time)


RE: Best programming language for handling array calculations in parallel? - John Keith - 04-18-2019 07:36 PM

I'm guessing that if the OP is finding Python on (presumably) a PC to be too slow, a calculator isn't going to cut it. Smile OTOH, since we are talking about non-square matrices it might be beneficial to write custom code to solve the problem(s) rather than using standard linear algebra packages etc.

Further speculation would be pointless without further information.


RE: Best programming language for handling array calculations in parallel? - gomefun2 - 04-20-2019 01:59 AM

Each matrix location will only have basic math applied to it +-*/.

Is there any website that benchmarks parallel performance and compares languages?

In python it takes about 2 to 3 minutes for my program to run, I'd like to speed this up considerably by moving to a language that is focused on matrix math as well is compatible with parallel GPU computation. I do not know much about parallel computing at the moment, from what I have seen it is not much more difficult than regular programming you just have to learn it.

My code base isn't even quite 2000 lines of code yet, so rewriting in a better language would be bothersome but not impossible. It has high-level science and engineering ideas in it, but most of the thinking for those parts of the code has already been done in python and would only need to be converted to whichever language I chose next.

Maybe for fun, I would port this code to the DM42, but it would likely take a very long time to run.


RE: Best programming language for handling array calculations in parallel? - Paul Dale - 04-20-2019 10:39 AM

APL anyone?


RE: Best programming language for handling array calculations in parallel? - Sylvain Cote - 04-20-2019 12:29 PM

(04-20-2019 10:39 AM)Paul Dale Wrote:  APL anyone?
Agreed that APL is ideal for parallelism.
I have not touched APL for more than 30 years, but as far as I know, it is normally implemented in a interpreter and thus slower than compiled code.


RE: Best programming language for handling array calculations in parallel? - mfleming - 04-20-2019 02:48 PM

(04-20-2019 12:29 PM)Sylvain Cote Wrote:  Agreed that APL is ideal for parallelism.
I have not touched APL for more than 30 years, but as far as I know, it is normally implemented in a interpreter and thus slower than compiled code.

Common misconception. See The Interpretive Advantage
https://tv.dyalog.com/Dyalog18/?v=-6no6N3i9Tg

There's a good reason the only data structure APL supports is the array. See Rectangles All The Way Down
https://tv.dyalog.com/Dyalog18/?v=mK2WUDIY4hk


RE: Best programming language for handling array calculations in parallel? - DGM - 04-20-2019 09:32 PM

There is also j, which was invented by the inventor of APL, here is a place to start:
http://jsoftware.com/#/README . Sorry cannot insert a link from a Kindle Fire.

Many of the advantages of APL but with regular keyboard characters.


RE: Best programming language for handling array calculations in parallel? - pascal_meheut - 04-21-2019 05:22 AM

I hardly see the point of using obsolete/hard to maintain (Fortran, APL) or exotic languages if one wants to use GPU.

C/C++ is very commonly used, so is Python on top of the existing C librairies. Of course, a programmer fluent in Fortran has a good reason to choose it but that's all IMHO.

Choosing the most common languages means tutorials, supports, less time wasted understanding the subtleties of the library binding in another environment...


RE: Best programming language for handling array calculations in parallel? - Gilles - 04-23-2019 10:37 AM

More original :

RPL/2 for numerical algorithms or symbolic computations on parallel calulators


RE: Best programming language for handling array calculations in parallel? - Paul Dale - 04-23-2019 12:07 PM

If you are working in C++, the Eigen library used to be very good. Essentially, it is a template library that attempts to optimise operations at compile time. It special cases small matrices and allows a trade off between performance and accuracy.

If I were rewriting the 34S firmware and the flash permitted it, this is what I'd use. Writing fast and accurate matrix code is tricky.


Pauli


RE: Best programming language for handling array calculations in parallel? - pier4r - 04-23-2019 09:52 PM

(04-20-2019 01:59 AM)gomefun2 Wrote:  Each matrix location will only have basic math applied to it +-*/.

Is there any website that benchmarks parallel performance and compares languages?

Not that I know, the closest is: https://benchmarksgame-team.pages.debian.net/benchmarksgame/