Exemplo n.º 1
0
void engine<VertexType, EdgeType>::run(){
  int iterationCount = 0;
  Bag<Scheduler::update_task>* b = scheduler->get_task_bag();
  while (b->numElements() > 0 /*&& iterationCount < 40*/) {
    iterationCount++;
    parallel_process(b); 
    b = scheduler->get_task_bag(); 
  }
}
Exemplo n.º 2
0
 void engine<VertexType, EdgeType>::parallel_process(Bag<Scheduler::update_task>* bag) {
   Pennant<Scheduler::update_task>* p = NULL;
   if (bag->getFill() > 0) {
     bag->split(&p);
     cilk_spawn parallel_process(bag);
     parallel_process_pennant(p, BLK_SIZE);
   } else {
     process_update_tasks(bag->getFilling(), bag->getFillingSize());
   }
   cilk_sync;
   if (p != NULL) {
     delete p;
   }
 }
Exemplo n.º 3
0
int main(int argc,char *argv[])
{
	char *token;
      if (argc<2 ||argc>3){
      	  printf("|-----------------------------------------------------------------------|\n");
      	  printf("	Error: Insufficient Parameters.                             \n");
	  printf("	Maximum Workers are %d. Number of workers should be even!\n", PROCESSORS);
      	  printf("	Commands to run!                             \n");
      	  printf("	Command Format: OjbectFileName -Sequential(S)/Parallel(P) -Workers!\n");
      	  printf("	Example: sequential SHA: ' ./sha -S   '!                             \n");
      	  printf("	Example: parallel SHA  : ' ./sha -P -2 '!\n");
      	  printf("|---------------------------------------------------------------------- |\n");
      	  exit(0);
      }else {
      	    
      	    token=argv[1];
      	    if (*token=='-') {
      	    	   token++;
      	    	  if (strcmp(token,"S")==0){
      	    	  	    readFilesData();
			      	    	   sequential_process();
			      	    }else if (strcmp(token, "P")==0){
			      	    	     token= argv[2];
			      	    	     token++;
			      	    	     if (isdigit(*token)!=0){
			      	    	         no_workers= atoi(token);
						 /*if (no_workers%2 != 0 || no_workers >PROCESSORS)
			      	    	    		     printf("ERROR: Number of worker should be even and no more than 8\n");
			      	    	    		 else {*/
			      	    	    		 	   readFilesData();
			      	                   parallel_process();	
			      	               //}
			      	          }else{
			      	          	printf("ERROR: Invalid number of workers\n");
			      	          }
			      	  	}else {
			      	  		  printf("ERROR: Unknown Parameters!\n");
			      	  	}//end-if	  	
      	  }else {
      	  	 printf("ERROR: Unknown Parameters!\n");
      	  }
      	  	
      }
    return(0);
}