12 #include <kernel/numbers.h>
20 #define THREAD_MIN_LENGTH 10*NUM_THREADS
22 struct p_Mult_nn_thread_data
31 void* p_Mult_nn_doMult(
void *threadarg)
33 struct p_Mult_nn_thread_data *my_data;
34 my_data = (
struct p_Mult_nn_thread_data *) threadarg;
37 number
n = my_data->n;
44 for (
int i=0;
i<NUM_THREADS;
i++)
54 static inline int pLengthOrMore(
poly p,
int m)
57 for(l=0;(p!=
NULL) && (l<=m); l++)
pIter(p);
61 extern "C" poly p_Mult_nn__FieldQ_LengthGeneral_OrdGeneral(
poly,
const number,
const ring);
63 poly p_Mult_nn_pthread(
poly p,
const number n,
const ring r)
67 if ((
nlSize(n)>2) && (pLengthOrMore(q,THREAD_MIN_LENGTH)>=THREAD_MIN_LENGTH))
69 pthread_t threads[NUM_THREADS];
70 struct p_Mult_nn_thread_data thread_data_array[NUM_THREADS];
73 pthread_attr_init(&attr);
74 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
78 for(t=0; t<NUM_THREADS; t++)
81 thread_data_array[t].thread_id = t;
82 thread_data_array[t].p =
p;
83 thread_data_array[t].n =
n;
84 thread_data_array[t].r =
r;
86 rc = pthread_create(&threads[t], &attr, p_Mult_nn_doMult,
87 (
void *) &thread_data_array[t]);
90 printf(
"ERROR; return code from pthread_create() is %d\n", rc);
97 pthread_attr_destroy(&attr);
98 for(t=NUM_THREADS-1; t>=0; t--)
102 rc = pthread_join(threads[t], &status);
105 printf(
"ERROR; return code from pthread_join() is %d\n", rc);
114 return p_Mult_nn__FieldQ_LengthGeneral_OrdGeneral(p,n,r);
Compatiblity layer for legacy polynomial operations (over currRing)
int nlSize(number a, const coeffs)
const CanonicalForm CFMap CFMap int &both_non_zero int n
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
LINLINE void nlInpMult(number &a, number b, const coeffs r)