Changeset 7090a8b in git
- Timestamp:
- Nov 23, 2020, 6:58:37 PM (3 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- 83b61dab63ac2e1b7ae8b70d52db7a3a950835f3
- Parents:
- 04313571ff955be742c598a08ffdfcf1f2157a8f
- Location:
- kernel/GBEngine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/GBEngine/kChinese.cc
r0431357 r7090a8b 14 14 15 15 #include "kernel/oswrapper/vspace.h" 16 #include "kernel/ideals.h" 16 17 #include <sys/types.h> 17 18 #include <sys/wait.h> … … 192 193 { 193 194 int cnt=0;int rw=0; int cl=0; 194 int i,j;195 195 // find max. size of xx[.]: 196 for( j=rl-1;j>=0;j--)197 { 198 i =IDELEMS(xx[j])*xx[j]->nrows;196 for(int j=rl-1;j>=0;j--) 197 { 198 int i=IDELEMS(xx[j])*xx[j]->nrows; 199 199 if (i>cnt) cnt=i; 200 200 if (xx[j]->nrows >rw) rw=xx[j]->nrows; // for lifting matrices … … 218 218 // Create a queue of int 219 219 VRef<Queue<int> > queue = vnew<Queue<int> >(); 220 for(i =cnt-1;i>=0; i--)221 { 222 queue->enqueue(i); // the tasks: con truct poly p[i]220 for(int i=cnt-1;i>=0; i--) 221 { 222 queue->enqueue(i); // the tasks: construct poly p[i] 223 223 } 224 224 for(int i=cpus;i>=0;i--) … … 228 228 // Create a queue of polys 229 229 VRef<Queue<VRef<VString> > > rqueue = vnew<Queue<VRef<VString> > >(); 230 for (i =0;i<cpus;i++)230 for (int i=0;i<cpus;i++) 231 231 { 232 232 int pid = fork_process(); … … 248 248 } 249 249 250 for( j=rl-1;j>=0;j--)250 for(int j=rl-1;j>=0;j--) 251 251 { 252 252 if(ind>=IDELEMS(xx[j])*xx[j]->nrows) // out of range of this ideal … … 258 258 long l=size_poly(res,r); 259 259 //printf("size: %ld kB\n",(l+1023)/1024); 260 VRef<VString> msg = vstring(l+1); 261 char *s=(char*)msg->str(); 262 send_poly(s,ind,res,r); 263 rqueue->enqueue(msg); 264 if (TEST_OPT_PROT) printf("."); 265 } 266 } 267 else // parent --------------------------------------------------- 268 { 269 if (TEST_OPT_PROT) printf("%d childs created\n",cpus); 270 VRef<VString> msg; 271 while(cnt>0) 272 { 273 msg=rqueue->dequeue(); 274 char *s=(char*)msg->str(); 275 int ind; 276 poly p=NULL; 277 get_poly(s,ind,&p,r); 278 //printf("got res[%d]\n",ind); 279 result->m[ind]=p; 280 msg.free(); 281 cnt--; 282 } 283 // removes queues 284 queue.free(); 285 rqueue.free(); 286 vmem_deinit(); 287 } 288 return result; 289 } 290 291 ideal id_Farey_0(ideal x, number N, const ring r) 292 { 293 int cnt=IDELEMS(x)*x->nrows; 294 int cpus=(int)(long)feOptValue(FE_OPT_CPUS); 295 if (2*cpus>=cnt) /* at least 2 polys for each process, 296 or switch to seriell version */ 297 return id_Farey(x,N,r); 298 ideal result=idInit(cnt,x->rank); 299 result->nrows=x->nrows; // for lifting matrices 300 result->ncols=x->ncols; // for lifting matrices 301 302 int parent_pid=getpid(); 303 using namespace vspace; 304 vmem_init(); 305 // Create a queue of int 306 VRef<Queue<int> > queue = vnew<Queue<int> >(); 307 for(int i=cnt-1;i>=0; i--) 308 { 309 queue->enqueue(i); // the tasks: construct poly p[i] 310 } 311 for(int i=cpus;i>=0;i--) 312 { 313 queue->enqueue(-1); // stop sign, one for each child 314 } 315 // Create a queue of polys 316 VRef<Queue<VRef<VString> > > rqueue = vnew<Queue<VRef<VString> > >(); 317 for (int i=0;i<cpus;i++) 318 { 319 int pid = fork_process(); 320 if (pid==0) break; //child 321 } 322 if (parent_pid!=getpid()) // child ------------------------------------------ 323 { 324 loop 325 { 326 int ind=queue->dequeue(); 327 if (ind== -1) 328 { 329 exit(0); 330 } 331 332 poly res=p_Farey(x->m[ind],N,r); 333 long l=size_poly(res,r); 260 334 VRef<VString> msg = vstring(l+1); 261 335 char *s=(char*)msg->str(); -
kernel/GBEngine/kChinese.h
r0431357 r7090a8b 17 17 poly p_ChineseRemainder(poly *xx, mpz_ptr *x,mpz_ptr *q, int rl, mpz_ptr *C ,const ring R); 18 18 ideal id_ChineseRemainder_0(ideal *xx, number *q, int rl, const ring r); 19 ideal id_Farey_0(ideal xx, number N, const ring r); 19 20 #endif
Note: See TracChangeset
for help on using the changeset viewer.