# HP Forums

You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
I am going to guess Matlab with the Parallel processing toolbox:
https://www.mathworks.com/products/paral...uting.html
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.
"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)
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. 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.
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.
APL anyone?
(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.
(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
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.
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...
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
(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...marksgame/
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :