Testing latest pari + WASM + node.js... and it works?! Wow.
License: GPL3
ubuntu2004
#include <pari/pari.h> /* Include PARI headers */12#include <omp.h> /* Include OpenMP headers */34#define MAXTHREADS 3 /* Max number of parallel threads */56int7main(void)8{9GEN M,N1,N2, F1,F2,D;10struct pari_thread pth[MAXTHREADS];11int numth = omp_get_max_threads(), i;12/* Initialise the main PARI stack and global objects (gen_0, etc.) */13pari_init(8000000,500000);14if (numth > MAXTHREADS)15{16numth = MAXTHREADS;17omp_set_num_threads(numth);18}19/* Compute in the main PARI stack */20N1 = addis(int2n(256), 1); /* 2^256 + 1 */21N2 = subis(int2n(193), 1); /* 2^193 - 1 */22M = mathilbert(80);23/*Allocate pari thread structures */24for (i = 1; i < numth; i++) pari_thread_alloc(&pth[i],8000000,NULL);25#pragma omp parallel26{27int this_th = omp_get_thread_num();28if (this_th) (void)pari_thread_start(&pth[this_th]);29#pragma omp sections30{31#pragma omp section32{33F1 = factor(N1);34}35#pragma omp section36{37F2 = factor(N2);38}39#pragma omp section40{41D = det(M);42}43} /* omp sections */44if (this_th) pari_thread_close();45} /* omp parallel */46pari_printf("F1=%Ps\nF2=%Ps\nlog(D)=%Ps\n", F1, F2, glog(D,3));47for (i = 1; i < numth; i++) pari_thread_free(&pth[i]);48return 0;49}505152