示例#1
0
static void
print_verbose_search_info(struct engine_result res)
{
    struct search_result sres = res.sresult;
    if (sres.cutoff_count > 0)
        print_percent((sres.first_move_cutoff_count * 1000)
                      / sres.cutoff_count);
    else
        print_percent(0);
    putchar('\t');
    print_percent(res.ht_usage);
    putchar('\t');
}
示例#2
0
static void
print_stat(struct btstat *st)
{
	print_percent(st->content_got,st->content_size);
	print_size(st->downloaded);
	print_rate(st->rate_down);
	print_size(st->uploaded);
	print_rate(st->rate_up);
	print_ratio(st->tot_up,st->content_size);
	printf("%4u ",st->peers);
	printf("\n");
}
示例#3
0
/* Function to apply to all instruction that need printing */
int process_insn(x86_inst_t * insn, void * ctx) {
  trace_interface_t * trace = (trace_interface_t *) ctx;
  /* Print analysis progress */
  if ((insn->insn_ctr % PROGRESS_GAP) == 0) {
    int percent = (trace_get_curr_filepos(trace) * 101) /
                    trace->trace_byte_size;
    print_percent(stderr, percent);
  }

  /* Print instruction */
  print_insn(out_stream, insn, intel_format, verbose, print_counter);

  return 0;
}
示例#4
0
unsigned int	print_it(t_tmp_arg *tmp, t_params *params, char c,
			 unsigned int chars_to_save)
{
  unsigned int	wt;

  wt = 0;
  (c == 'd') ? (wt = print_int(tmp, params, 0, 0)) : (0);
  (c == 'i') ? (wt = print_int(tmp, params, 0, 0)) : (0);
  (c == 'u') ? (wt = print_uint(tmp, params, 0, 0)) : (0);
  (c == 'x') ? (wt = print_little_hexa(tmp, params, 0, 0)) : (0);
  (c == 'X') ? (wt = print_large_hexa(tmp, params, 0, 0)) : (0);
  (c == 'n') ? (wt = save_chars(tmp, chars_to_save)) : (0);
  (c == 'o') ? (wt = print_octal(tmp, params, 0, 0)) : (0);
  (c == 'c') ? (wt = print_char(tmp, params, 0, 0)) : (0);
  (c == 's') ? (wt = print_str(tmp, params, 0, 0)) : (0);
  (c == '%') ? (wt = print_percent()) : (0);
  (c == 'S') ? (wt = print_all_str(tmp, params, 0, 0)) : (0);
  (c == 'p') ? (wt = print_ptr(tmp, params, 0, 0)) : (0);
  (c == 'b') ? (wt = print_binary(tmp, params, 0, 0)) : (0);
  return (wt);
}
示例#5
0
int main(int argc, char ** argv)
{
  int opt = -1;
  int long_index =0;
  char *endptr = NULL;
  size_t len;

  static struct option long_options[] =
  {
    {"count",       no_argument,   0, 'c'},
    {"createindex", no_argument,   0, 'd'},
    {"first",   required_argument, 0, 'f'},
    {"header",  no_argument,       0, 'h'},
    {"intel",   no_argument,       0, 'i'},
    {"last",    required_argument, 0, 'l'},
    {"out",     required_argument, 0, 'o'},
    {"trace",   required_argument, 0, 't'},
    {"verbose", no_argument,       0, 'v'},
    {0, 0, 0, 0}
  };

  while ((opt = getopt_long_only(argc, argv, "", 
                   long_options, &long_index )) != -1) 
  {
    switch (opt) {
      case 'c':
        print_counter = 1;
        break;
      case 'd':
        create_index = 1;
        break;
      case 'f':
        first = strtoull(optarg, &endptr, 0);
        len = strlen(optarg);
        if (endptr != optarg + len) {
          fprintf(stderr, "error : invalid -first <int64> argument.\n");
          return -1;
        }
        break;
      case 'h':
        print_header = 1;
        break;
      case 'i':
        intel_format = 1;
        break;
      case 'l':
        last = strtoull(optarg, &endptr, 0);
        len = strlen(optarg);
        if (endptr != optarg + len) {
          fprintf(stderr, "error : invalid -last <int64> argument.\n");
          return -1;
        }
        break;
      case 'o':
        sprintf(output_file, "%s", optarg);
        break;
      case 't':
        sprintf(trace_file, "%s", optarg);
        break;
      case 'v':
        verbose = 1;
        break;
      default: 
        print_usage(); 
        return -1;
    }
  }

  if(trace_file[0] == 0) {
    print_usage();
    return -1;
  }
  if(output_file[0] != 0 && (out_stream = fopen(output_file, "w")) == NULL) {
    fprintf(stderr, "error : output file not accessible.\n");
    return -1;
  }
  if(out_stream == NULL) {
    out_stream = stdout;
  }

  setbuf(out_stream, outbuf);

  /* If create index requested, loop over instructions and exit */
  if (create_index) {
    return trace_create_index(trace_file);
  }

  /* Open trace */
  trace_interface_t * trace_iface = trace_open(trace_file);
  if (trace_iface == NULL) {
    return -1;
  }

  /* If requested, print header and exit */
  if (print_header) {
    print_trace_header(stdout, trace_iface, verbose);
    goto cleanup;
  }

  /* Loop over instructions */
  trace_fold(trace_iface, first, last, 0, process_insn, trace_iface);

  /* Update progress */
  print_percent(stderr, 100);

cleanup:
  /* Close files */
  trace_close(trace_iface);
  fclose(out_stream);

  return 0;
}
示例#6
0
int main()
{    //INITIALIZE INPUTS
  time_t seconds;
  seconds = time(NULL);
  long seed = (long)seconds;

  RandomClass r;
  r.initialize(seed);

  string SIMU_TYPE;
  int NPARTICLES, MAXIMUM_COLL;
  double TEQ;
  ifstream file;
  file.open("input.txt");
  if (file.fail()){
    cout << "NO INPUT FILE" << endl;
  }
  else
    {
      file >> SIMU_TYPE;  //case sensitive
      file >> NPARTICLES;
      file >> MAXIMUM_COLL;
      file >> TEQ;
    }

  // READ GEOMETRY FILES
  reflective_bdrs ref("reflective.txt");
  ref.show();
  prescribed_bdrs presc("prescribed.txt");
  presc.show();
  periodic_bdrs per("periodic.txt");
  per.show();

  // READ MATERIAL PROPERTIES
  materials Si("dataSi.txt", TEQ);
  Si.show_all();

  // DECLARE AND READ THE HEAT FLUX AND TEMPERATURE DETECTORS
  detector_array_H H_detect("H_detectors.txt", "times.txt");
  detector_array_T T_detect("T_detectors.txt", "times.txt");

  // PRINT GEOMETRY IN FILE
  particle part(MAXIMUM_COLL);

  // READ SOURCE FILES
  sources src(&Si, &presc, "volumetric.txt", "body_force.txt", "initial.txt", NPARTICLES);
  src.display_type();
  cout << src.Np << endl;
  cout << src.Nv << endl;
  cout << src.Nb << endl;
  cout << src.Ni << endl;
  src.display_vol();
  src.display_bod();
  src.display_init();

  matlab_write_geometry(&ref, &presc, &per, &src, &T_detect, &H_detect, "geometry.m");

  if (strcmp(SIMU_TYPE.c_str(),"BOTH")==0 || strcmp(SIMU_TYPE.c_str(),"BACKWARD")==0 || strcmp(SIMU_TYPE.c_str(),"ADJOINT")==0)
    {

      // READ SOURCE FILES
      sources src_adj(&Si, "T_detectors.txt", "H_detectors.txt", NPARTICLES);

      adjoint_detectors adj_det(&presc, "volumetric.txt", "body_force.txt", "initial.txt", "times.txt", &src_adj);
      src.display_type();

      H_detect.show();
      cout << endl;
      T_detect.show();

      cout << endl << "STARTING ADJOINT SIMULATION" << endl;

      // LOOP OVER PARTICLES
      cout << src_adj.Nv << endl;
      while (src_adj.not_empty) {
	if (src_adj.remaining_particles[src_adj.src_parser]==1){
	  cout << src_adj.src_parser + 1 << " out of " << src_adj.Ntot << " adjoint sources " << endl;
	}


	src_adj.emit_adjoint(&part,&r);

	while (part.alive){
	  part.initiate_move(&r);

	  part.move(&ref, &presc, &per);

	  //H_detect.measure(&part);
	  //T_detect.measure(&part, &Si);
	  adj_det.measure(&part, &src_adj);
	  part.finish_move(&Si,&r, &ref, &presc, &per);

	}

      }
      // DISPLAY RESULTS IN TERMINAL AND RECORD THEM
      adj_det.show_results();
      adj_det.write("adj_T_results.txt","adj_H_results.txt");
      //cout << adj_det.Nt <<endl;
      //cout << "displaying pointers" << endl;
      //cout << adj_det.steady_H << " " << adj_det.steady_T+11 << " " << src_adj.cumul_energies+100 <<endl;
    }

  double TEST = 0;
  if (strcmp(SIMU_TYPE.c_str(),"BOTH")==0 || strcmp(SIMU_TYPE.c_str(),"FORWARD")==0 || strcmp(SIMU_TYPE.c_str(),"REGULAR")==0 || strcmp(SIMU_TYPE.c_str(),"DIRECT")==0)
    {

      H_detect.show();
      cout << endl;
      T_detect.show();
      cout << endl << "STARTING FORWARD SIMULATION" << endl;
      // LOOP OVER PARTICLES
      for (int i=0; i<src.Npart; i++){
        print_percent(i, src.Npart);

	src.emit(&part,&r);
	if (0<part.pt0.x && part.pt0.x<1e-7 && 0<part.pt0.y && part.pt0.y<1e-7)
	  TEST = TEST + part.weight/Si.C/1e-14;
	//     cout << part.t << " " << src.t_max << endl;
	while (part.alive){
	  part.initiate_move(&r);

	  part.move(&ref, &presc, &per);

	  H_detect.measure(&part);
	  T_detect.measure(&part, &Si);

	  part.finish_move(&Si,&r, &ref, &presc, &per);

	}

      }
      // RECORD RESULTS
      H_detect.write("results_H.txt");
      T_detect.write("results_T.txt");
      // DISPLAYING RESULTS
      H_detect.show_results();
      T_detect.show_results();
    }
  return 0;


}
示例#7
0
static char * sprint_percent(__u32 per, char *buf)
{
	print_percent(buf, SPRINT_BSIZE-1, per);
	return buf;
}