Beispiel #1
0
void clockExtension(int argc, char* argv[])
{
  int i,n;
  ProtocolDesc pd;

  protocolUseStdio(&pd);
  if(argc<3)
  { fprintf(stderr,"Too few parameters\n");
    return;
  }

  if(argv[1][0]=='R')
  {
    struct HonestOTExtRecver* r;
    char *buf;
    bool *sel;
    int i,n;
    clock_t lap;
    double wlap;
    setCurrentParty(&pd,2);
    sscanf(argv[2],"%d",&n);
    buf = malloc(11*n); sel = malloc(n);
    for(i=0;i<n;++i) sel[i]=i%2;
    lap = clock();
    wlap = wallClock();
    r = honestOTExtRecverNew(&pd,1);
    honestOTExtRecv1Of2(r,buf,sel,n,11);
    honestOTExtRecverRelease(r);
    fprintf(stderr,"R CPU time is %lf, wall time is %lf\n",
        (clock()-lap)/(double)(CLOCKS_PER_SEC),wallClock()-wlap);
    char ref[11];
    for(i=0;i<n;++i)
    { snprintf(ref,11,"%d %d",sel[i],i);
      if(strncmp(ref,buf+i*11,11)) fprintf(stderr,"Didn't work. Got '%s'\n",buf+i*11);
    }
    free(buf); free(sel);
  }else
  { struct HonestOTExtSender* s;
    char *buf0,*buf1;
    int i,n=10,bs;
    clock_t lap;
    double wlap;
    setCurrentParty(&pd,1);
    sscanf(argv[2],"%d",&n);
    buf0 = malloc(11*n); buf1 = malloc(11*n);
    for(i=0;i<n;++i) 
    { sprintf(buf0+i*11,"0 %d",i);
      sprintf(buf1+i*11,"1 %d",i);
    }
    lap = clock();
    wlap = wallClock();
    s = honestOTExtSenderNew(&pd,2);
    honestOTExtSend1Of2(s,buf0,buf1,n,11);
    honestOTExtSenderRelease(s);
    fprintf(stderr,"S CPU time is %lf, wall time is %lf\n",
        (clock()-lap)/(double)(CLOCKS_PER_SEC),wallClock()-wlap);
    free(buf0); free(buf1);
  }
}
Beispiel #2
0
int main(int argc, char *argv[]) {    
    ProtocolDesc pd;
    protocolIO io;
    int i, index = 0;

    if(argc < 3) {
        fprintf(stderr, "Not enough args\n");
        return 1;
    }

    int party = (argv[1][0] == '1' ? 1 : 2);
    protocolUseStdio(&pd);
    
    if (party == 1) {
        loadList(&io);
    }
    else {
        io.n = strtol(argv[2], NULL, 10);
    }
    
    setCurrentParty(&pd, party);

    double lap = wallClock();
    execYaoProtocol(&pd, linSearch, &io);

    fprintf(stderr,"Party: %d\n", party);
    fprintf(stderr,"Total time: %lf s\n", wallClock() - lap);
    
    if (io.res) {
        fprintf(stderr,"Item found.\n\n");
    }
    else {
        fprintf(stderr,"Item not found.\n\n");
    }

    cleanupProtocol(&pd);
    
    if (party == 1) {
        free(io.nList);
    }
    
    return 0;
}
int main(int argc, char *argv[])
{
  char   input_file[ONE_LINE],
         *func = {" main(int argc, char *argv[]) :  "};
  FILE   *file_ptr;
  SHELL  model;
  TID   wallTime, cpuTime;


  MPI_Init(&argc, &argv);      
  MPI_Comm_size(MPI_COMM_WORLD,&NumProcs);
  MPI_Comm_rank(MPI_COMM_WORLD, &Rank);

  time_step(10,1);  // time controll for total shell model calc 

  // Read file names and open file containing basic input data

  if(argc >= 2) { // as program parameters
    strcpy(input_file, argv[1]); // save in_data input_file
  }
  else  { // or as separate typed in filename
    printf("\n Type in file name for basic shell model data = ");
    scanf("%s",input_file);
  } // end of data-file-name input

  // Time control for the total shell model calculation

  wallClock(1,0); // initialization 
  cpuClock(1,0);
  wallClock(1,1); // start time
  cpuClock(1,0);

  input_process(input_file, &model); // module shell-model-input.c

   /********************  test output  ********/

  if(Rank == MASTER) {
    FILE    *file_ptr;

    if((file_ptr = fopen(model.title,"a"))== NULL) {
      printf("\n\nRank(%d): Error in function main()():",Rank);
      printf("\nWrong file = %s for the output data\n", model.title);
      MPI_Abort(MPI_COMM_WORLD,Rank);
    }
    fprintf(file_ptr,"\n\n     NumProcs = %d\n\n\n",NumProcs);
    fflush(file_ptr);
    fclose(file_ptr);
  } // end MASTER
  /****************   end test outpt ********/


  strcpy(TEST_FILE_NAME, model.title);    // parameter for test output 


  // all files identifies with rank number

  if(  (!strcmp(model.type_calc,"random-start"))
     ||(!strcmp(model.type_calc,"dimension"))) {

       /*
       ** A Lanczos iteration shell model calculation
       ** based on random initial state.
       */

    id_LancIterateCalc(&model);

  }
  else {
    printf("\n\n The calculation process: %s not implemented\n\n",
                                                model.type_calc);
   MPI_Abort(MPI_COMM_WORLD,Rank);
  }

  // Stop and read total process time 

  wallClock(1,2); // stop tile
  cpuClock(1,2);
  wallTime = wallClock(1,3);  // read time
  cpuTime  = cpuClock(1,3);

  if(Rank == MASTER) {
    if((file_ptr = fopen(model.title,"a"))== NULL) {
      printf("\n\nError in function lanc-main.c():");
      printf("\nWrong file = %s for the output data\n", model.title);
     MPI_Abort(MPI_COMM_WORLD,Rank);
    }
    fprintf(file_ptr, "\n\nTotal shell model process wall time used");  
    fprintf(file_ptr, " %llu hour %llu min %llu sec",
	  wallTime.hour, wallTime.min, wallTime.sec);
    fprintf(file_ptr, "\nTotal shell model process cpu time used");  
    fprintf(file_ptr, " %llu hour %llu min %llu sec\n",
	  cpuTime.hour, cpuTime.min, cpuTime.sec);
    fclose(file_ptr);
  }  // end MASTER

  //   MPI_Finalize();

  MPI_Finalize();




  return 0; // sucsessfull termination

} // End: function main()
Beispiel #4
0
void DSPDFViewer::sendAllClockSignals() const
{
  emit wallClockUpdate(wallClock());
  emit slideClockUpdate(slideClock());
  emit presentationClockUpdate(presentationClock());
}