Beispiel #1
0
int main ( int argc, char *argv[] )
{
   int myid,numprocs,n,nbsols,mysolnum;
   MPI_Status status; 

   adainit();
   MPI_Init(&argc,&argv);
   MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
   MPI_Comm_rank(MPI_COMM_WORLD,&myid);

   dimension_broadcast(myid,&n);
   monomials_broadcast(myid,n);
   copy_broadcast(myid); 
   start_system_broadcast(myid,n,&nbsols);

   MPI_Bcast(&nbsols,1,MPI_INT,0,MPI_COMM_WORLD);
   solutions_distribute(myid,nbsols,n,numprocs,&mysolnum);

  // if(myid == 1) print_homotopy();  

   MPI_Finalize();
   adafinal();

   return 0;
}
Beispiel #2
0
int monodromy_breakup ( int myid, int n, int dim, int deg, int nbloops,
                        int numprocs, double *trackwtime )
{
   int mysolnum,i,done,fail;

   if(v>0) printf("Node %d knows n = %d, #loops = %d.\n",myid,n,nbloops);

   monomials_broadcast(myid,n);
   MPI_Bcast(&deg,1,MPI_INT,0,MPI_COMM_WORLD);
   if(v>0) printf("Node %d went through bcast of degree %d.\n",myid,deg);
   solutions_distribute(myid,deg,n,numprocs,&mysolnum);
   
   MPI_Bcast(&dim,1,MPI_INT,0,MPI_COMM_WORLD);
   fail = initialize_standard_sampler(dim);

   if(myid == 0)
   {
      fail = validate_solutions();                   /* sanity check */
      fail = initialize_standard_monodromy(nbloops,deg,dim);
      /* initialize traces */
      if(v>1) print_solutions(myid);
      fail = store_standard_solutions();
   }

   for(i=1; i<=2; i++)
   {
     if((v>0)&&(myid == 0)) printf("slice %d for linear trace...\n",i);
     trace_slice_broadcast(myid,i);
     gamma_broadcast(myid,n);
     f_track_paths(myid,deg,n,numprocs,mysolnum,trackwtime);
     if(myid == 0)
     {
        fail = store_standard_solutions();
        fail = restore_standard_solutions();
     }
     solutions_distribute(myid,deg,n,numprocs,&mysolnum);
     if(myid == 0) f_swap_slices(myid);
   }

   slices_broadcast(myid,dim,n);

   for(i=0; i<nbloops; i++)
   {
      if((v>0)&&(myid == 0)) printf("Starting loop #\%d...\n",i);
      gamma_broadcast(myid,n);
      f_track_paths(myid,deg,n,numprocs,mysolnum,trackwtime);
      if(myid != 0) f_swap_slices(myid);
      if(myid == 0)
      {
         if(v>1) print_solutions(myid);
         solcon_clear_standard_solutions();
      }
      gamma_broadcast(myid,n);
      f_track_paths(myid,deg,n,numprocs,mysolnum,trackwtime);
      if(myid == 0)
      {
         if(v>1) print_solutions(myid);
         fail = store_standard_solutions();
         fail = standard_monodromy_permutation(deg,&done);
         solcon_clear_standard_solutions();
      }

      MPI_Bcast(&done,1,MPI_INT,0,MPI_COMM_WORLD);
      MPI_Barrier(MPI_COMM_WORLD);   /* every node must know if done */

      if(done == 1)
      {
         if (v>0) printf("Node %d leaves the loop at step %d.\n", myid,i+1);
         if(myid == 0) printf("Executed %d monodromy loops.\n", i+1);
         return 0;
      }
      else
      {
         if(myid != 0) f_swap_slices(myid);
         slices_broadcast(myid,dim,n);               /* new slices */
         if(myid == 0) fail = restore_standard_solutions();
         MPI_Bcast(&deg,1,MPI_INT,0,MPI_COMM_WORLD);  
         solutions_distribute(myid,deg,n,numprocs,&mysolnum);
      }
   }
   if(myid == 0) printf("Executed %d monodromy loops.\n", i+1);
   return 1;
}
Beispiel #3
0
int standard_run ( int myid, int nbrp, int nbc, char* outfile, int verbose )
{
   int fail,dim,nbsols,mysolnum,len,*nbpaths;
   double startwtime,endwtime,wtime,*time;

   startwtime = MPI_Wtime();
   if(myid == 0)
   {
      time = (double*)calloc(nbrp,sizeof(double));
      nbpaths = (int*)calloc(nbrp,sizeof(int));
      fail = read_target_system_without_solutions();
      fail = copy_target_system_to_container();
      fail = syscon_number_of_standard_polynomials(&dim);
      fail = write_standard_target_system(); // writes to file
   }
   standard_dimensions_broadcast(myid,&dim,&dim);

   if(verbose > 0) printf("Process %d has dimension %d.\n",myid,dim);

   monomials_broadcast(myid,dim); // broadcast target system

   if(myid != 0) fail = copy_container_to_target_system();

   if(verbose > 0)
      if(myid == 1) fail = write_standard_target_system();

   if(myid == 0)
   {
      fail = read_standard_start_system();
      fail = copy_start_system_to_container();
      fail = write_standard_start_system(); // writes to file
      fail = write_start_solutions(); // writes solutions to file
      fail = copy_start_solutions_to_container();
      fail = solcon_number_of_standard_solutions(&nbsols);
      if(verbose>0) printf("Read %d start solutions.\n",nbsols);
   }
   else
      fail = syscon_initialize_number_of_standard_polynomials(dim);

   monomials_broadcast(myid,dim); // broadcast start system

   if(myid != 0) fail = copy_container_to_start_system();

   if(verbose > 0)
      if(myid == 1) fail = write_standard_start_system();

   parameters_broadcast(myid,nbrp,verbose);

   if(myid == 0) verbose = prompt_for_verbose();
   MPI_Barrier(MPI_COMM_WORLD);

   MPI_Bcast(&verbose,1,MPI_INT,0,MPI_COMM_WORLD);

   MPI_Bcast(&nbsols,1,MPI_INT,0,MPI_COMM_WORLD);
   solutions_distribute(myid,nbsols,dim,nbrp,&mysolnum);

   fail = solcon_number_of_standard_solutions(&len);
   if(verbose > 0) printf("Node %d has %d solutions.\n",myid,len);

   if(myid > 0)
   {
      fail = copy_container_to_start_solutions();
      fail = standard_track_paths(myid,nbrp,nbc,outfile,verbose);
   }
   MPI_Barrier(MPI_COMM_WORLD);
   solutions_collect(myid,nbsols,dim,nbrp,mysolnum);

   if(myid == 0)
   {
      fail = copy_container_to_target_solutions();
      fail = write_target_solutions();
   }
   endwtime = MPI_Wtime();
   wtime = endwtime-startwtime;
   MPI_Gather(&wtime,1,MPI_DOUBLE,time,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
   MPI_Gather(&mysolnum,1,MPI_INT,nbpaths,1,MPI_INT,0,MPI_COMM_WORLD);

   if(myid == 0)
   {
      nbpaths[0] = nbsols;
      write_time_and_paths_to_defined_output_file(nbrp,time,nbpaths);
      free(time); free(nbpaths);
   }
   return 0;
}