pdeclib pilib modules for Pine, Rock, Pinebook, Sopine
#1
Lightbulb 
In March of 2014 I wrote a transcendental functions module for python ( in pure python ) which leverages the relatively new Decimal module; especially fast in Python3 on x86 machines.  

As it turns out these routines are also especially fast in Python3 on the Rock64 and the Pinebook;  although, I have used them to benchmark on the PineA64 also;  fast in its own right. 

The Decimal module is written and optimized in C.  My module(s) live on pypi and are being made available here for others who may want to experiment with big-nums maths or who may specifically want to run my PI benchmarks themselves. The pdeclib pilib module(s) will run on python2 or python3 unchanged;  they may be run in the REPL in "calculator" mode or they may be easily scripted.  The module(s) provide transcendental functions to arbitrary precision as well provide several PI routines which converge relatively quickly -- particularly fast is   piagm2().  These routines are also useful for those who want to study maths codes for convergent series. 

The pdeclib package may be obtained here:

The package contains pdeclib.py (the main transcendental functions module) and pilib.py (several useful historical PI routines).  I hope they are useful, but recognize that they may not be complete, nor free from bugs;  however, they are intended to be used and studied, and they have been available on-line for several years.

To use the modules simply place the two files in a working directory (or in your PythonPath) and then run the python REPL of choice in that directory , or path.  Then import the modules in the normal way:

>>>  from pilib import *

The module pilib will import pdeclib;  although pdeclib may be imported alone.  The default number of digits used is 42.  This may be changed with the function:

>>>  dscale(1010)

The above will set the number of big-num Decimal places to 1,010.  To compute PI run:

>>>  piagm2()

Read through the source (header and readme files) for caveat(s) and to find the syntax of the various functions provided by the package. There are no blobs, and the source is 100% pure python code;  what you see is what you get.

The following script is a Python3 example script for running the PI benchmark on any of the Pine boards and a gnu+linux image.  Its a simple script which starts the Python interpreter, imports the requisite modules, and executes the piagm2()  AGM PI routine, to 1010 places.  This result will be accurate to +|-  in the last two places.  The signature digits for the 1000th place are  164201989.  Also, at position 762 you will find six nines ... 999999.

PI-calc.sh

Code:
#!/usr/bin/python3
from pilib import *
dscale(1010)
print(piagm2())


To run the codes above use the 'time' command with the script and the modules in your working directory:

time  ./PI-calc.sh

Don't forget to make the script executable with :  chmod  0754  PI-calc.sh

The above command will give you 1000+ correct digits of PI in a few hundred milliseconds, and will also tell you how much 'real' ,  'system' , and 'user'  time was used.  You might find it interesting to compare the computations on our four platform boards for  1K, 5K, and 10K  digits of PI !

These little SoC(s) particularly running aarch64 ArmV8 64bits are very fast;  so, knock your SoC(s) off !

Note:  It is interesting to run four or more terminals [ each running piagm2() ]  to load the processor (all cores) for watching the temps in /sys/class/thermal/  or for experimenting with SMP.  

Note:  Other things affect the speed of these calcs,  like gcc version  and kernel version;  experiment with different gnu+linux builds;  try these codes and compare with different images.   Hav'fun.

Note:  Some believe this kind of bench-marking to be silly;  to the contrary,  this is a tool that provides valuable insight into the comparative operation of the SoC(s) for maths, as well for 32bit vs 64bit, as well for cache vs RAM.  Its just one tool and only gives a partial picture, yet is a fun way to explore your SoC(s), and learn some maths and python at the same time !

Note:  here is sample run from rock64 xenial minimal image 0.3.7:

Code:
rock64@rock64:~/Python$ time ./PI-calc.sh
3.141592653589793238462643383279502884197169399375105820974944592307816406286208
99862803482534211706798214808651328230664709384460955058223172535940812848111745
02841027019385211055596446229489549303819644288109756659334461284756482337867831
65271201909145648566923460348610454326648213393607260249141273724587006606315588
17488152092096282925409171536436789259036001133053054882046652138414695194151160
94330572703657595919530921861173819326117931051185480744623799627495673518857527
24891227938183011949129833673362440656643086021394946395224737190702179860943702
77053921717629317675238467481846766940513200056812714526356082778577134275778960
91736371787214684409012249534301465495853710507922796892589235420199561121290219
60864034418159813629774771309960518707211349999998372978049951059731732816096318
59502445945534690830264252230825334468503526193118817101000313783875288658753320
83814206171776691473035982534904287554687311595628638823537875937519577818577805
321712268066130019278766111959092164201989380952572

real    0m0.263s
user    0m0.231s
sys     0m0.029s

Note:  the signature digits for the 5,000th digit are : 132604721

Note:  the signature digits for the 10,000th digit are : 256375678

Rolleyes
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )


Messages In This Thread
pdeclib pilib modules for Pine, Rock, Pinebook, Sopine - by MarkHaysHarris777 - 08-04-2017, 10:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PINE A64 SBC: Clone of a functional 32GB SD card doesn't boot burningkrome 3 1,612 05-19-2023, 07:43 AM
Last Post: crocspot
  PINE A64 Ubuntu 18 or 20 IMG with touchscreen? burningkrome 0 606 04-29-2023, 05:13 AM
Last Post: burningkrome
  Pine A64 does only boot with Android 5.1 Dude 6 3,934 07-03-2022, 02:18 PM
Last Post: Dude
  Pine A64+ vs LCD do not boot DDS 3 5,976 02-23-2021, 05:33 PM
Last Post: thedu
  Autodetect if Pine unit is a Pine A64+ or PineA64-LTS pkfpeters 1 3,341 02-09-2021, 12:17 AM
Last Post: tllim
  Pine 64 | 2GB x2 & Acrylic Cases x2 for Sale | Canada - GTA ViperVi 1 4,503 01-18-2021, 03:45 PM
Last Post: squidius
  sd format?for pine 64 angegardien 3 7,769 12-06-2020, 03:53 PM
Last Post: junkyj753
  Node Red on the Pine DonFL 0 2,774 12-16-2019, 04:21 PM
Last Post: DonFL
Photo Pine A64+ from Kick starter running Pi-Hole netHolio 0 3,247 12-02-2019, 09:36 PM
Last Post: netHolio
  UK power supply (Pinebook Pro 64) skobi 0 2,309 11-17-2019, 04:55 AM
Last Post: skobi

Forum Jump:


Users browsing this thread: 1 Guest(s)