[Info-vax] Kednos PL/I

Arne Vajhøj arne at vajhoej.dk
Wed Sep 13 22:03:31 EDT 2023


On 9/13/2023 9:06 PM, gah4 wrote:
> On Wednesday, September 13, 2023 at 5:53:20 PM UTC-7, Arne Vajhøj wrote:
> 
> (snip, I wrote)
>>> It has been usual for a long time, for hardware to have multiply and divide with
>>> double length product and dividend. Many algorithms depend on that, though few
>>> HLLs have a way to do it. (Other than call an assembly language routine.)
>   
>>> It seems that 64 bit processors don't all do it.
> 
>> Big integers in software is pretty standard today. You can get
>> 128 or 245 or 512 or 1024 bit integers or whatever if you want to.
>> In software. And on todays hardware it will be pretty fast anyway.
>   
> I suppose so.
> It is reasonable to expect HLLs to support what the hardware supports.
> 
> I remember in the TeX documentation for the program, TeX has (had)
> Pascal programs to compute the product and quotient of 32 bit values
> with 16 bits after the binary point.  Very easy if you have the double length
> instructions, not at all easy in Pascal.
> 
> He suggests assembly versions of those two operations.
> 
> But computers were slower then.
> 
> If you are using them to implement multiple precision arithmetic, you
> want to use the largest ones supported by the hardware.  But yes,
> often enough they are fast enough.

Here is some C code using GMP library:

#include <stdio.h>
#include <string.h>
#include <time.h>

#include <gmp.h>

#define N1 1000000000
#define N2 10

int main(int argc, char *argv[])
{
     /* setup */
     mpz_t a, b, c;
     mpz_init_set_str(a, "123456789123456789123456789", 10);
     mpz_init_set_str(b, "987654321987654321987654321", 10);
     mpz_init(c);
     /* check functionality */
     mpz_mul(c, a, b);
     mpz_out_str(stdout, 10, c);
     printf("\n");
     mpz_div(c, c, b);
     mpz_out_str(stdout, 10, c);
     printf("\n");
     /* check performance */
     time_t t1 = time(NULL);
     for(int j = 0; j < N2; j++)
     {
         for(int i = 0; i < N1; i++)
         {
             mpz_mul(c, a, b);
         }
     }
     time_t t2 = time(NULL);
     printf("%.0f bigmuls per second\n", N1 * 1.0 * N2 / (t2 - t1));
     /* cleanup */
     mpz_clear(a);
     mpz_clear(b);
     mpz_clear(c);
     return 0;
}

It does around 100 million bigmuls per second here.

Arne



More information about the Info-vax mailing list