/******************************************************************* * Computer Algebra System SINGULAR * * tmult.cc: p_Mult_nn with pthreads - experimental * *******************************************************************/ #ifdef HAVE_CONFIG_H #include "singularconfig.h" #endif /* HAVE_CONFIG_H */ #include #include #include #include #include #ifdef SI_THREADS #include #include #include #define NUM_THREADS 8 #define THREAD_MIN_LENGTH 10*NUM_THREADS struct p_Mult_nn_thread_data { int thread_id; poly p; number n; ring r; }; void* p_Mult_nn_doMult(void *threadarg) { struct p_Mult_nn_thread_data *my_data; my_data = (struct p_Mult_nn_thread_data *) threadarg; //long taskid = my_data->thread_id; poly p = my_data->p; number n = my_data->n; ring r = my_data->r; while (1) { //if (p==NULL) return NULL; if (p==NULL) pthread_exit(NULL); nlInpMult(pGetCoeff(p), n,r); for (int i=0;i2) && (pLengthOrMore(q,THREAD_MIN_LENGTH)>=THREAD_MIN_LENGTH)) { pthread_t threads[NUM_THREADS]; struct p_Mult_nn_thread_data thread_data_array[NUM_THREADS]; pthread_attr_t attr; /* Initialize and set thread detached attribute */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); int rc; int t; for(t=0; t=0; t--) { void *status; rc = pthread_join(threads[t], &status); if (rc) { printf("ERROR; return code from pthread_join() is %d\n", rc); exit(-1); } } return q; } else { return p_Mult_nn__FieldQ_LengthGeneral_OrdGeneral(p,n,r); } } #endif