예제 #1
0
t_fillist		*check_and_set(char *buf, t_fillist *all, t_fillist *lst)
{
	if (check_one(buf))
	{
		lst = new_fillist_elem(lst, buf);
		if (check_two(all, lst))
			return (lst);
	}
	error();
	return (NULL);
}
예제 #2
0
char* check_option(char **in,int n,int which,int type)
{
  char test,*ret=NULL,wasfound=0,ok=1;
  int i;
  
  for (i=1;i<n;i++) {
    if (in[i] != NULL) {
      test= (in[i][0] == '-') && (in[i][1] == which);
      if (test) {
	wasfound=1;
	if (type != 'n') {
	  if (strlen(in[i]) > 2) {
	    switch(type) {
	    case 'u': check_unsigned(in[i]+2,which);break;
	    case 'd': check_integer(in[i]+2,which);break;
	    case 'f': check_float(in[i]+2,which);break;
	    case '2': check_two(in[i]+2,which);break;
	    case '3': check_three(in[i]+2,which);break;
	    }
	    if (ret != NULL)
	      free(ret);
	    check_alloc(ret=(char*)calloc(strlen(in[i]+2)+1,(size_t)1));
	    strcpy(ret,in[i]+2);
	    in[i]=NULL;
	  }
	  else {
	    in[i]=NULL;
	    i++;
	    if (i < n) {
	      if (in[i] != NULL) {
		switch(type) {
		case 'u': check_unsigned(in[i],which);break;
		case 'd': check_integer(in[i],which);break;
		case 'f': check_float(in[i],which);break;
		case '2': check_two(in[i],which);break;
   	        case '3': check_three(in[i]+2,which);break;
		case 'o': ok=check_optional(in[i],which);break;
		}
		if (ok) {
		  if (ret != NULL)
		    free(ret);
		  check_alloc(ret=(char*)calloc(strlen(in[i])+1,(size_t)1));
		  strcpy(ret,in[i]);
		  in[i]=NULL;
		}
		else {
		  i--;
		  if (ret != NULL)
		    free(ret);
		  ret=NULL;
		}
	      }
	    }
	    else {
	      if (ret != NULL) {
		free(ret);
		ret=NULL;
	      }
	    }
	  }
	}
	else {
	  in[i]=NULL;
	}
      }
    }
  }
  
  if (((type == 'o') || (type == 'n')) && (ret == NULL) && wasfound)
    return "";

  if (wasfound && (ret == NULL)) {
    fprintf(stderr,"The option -%c needs some value. Exiting!\n",which);
    exit(CHECK_OPTION_C_NO_VALUE);
  }
  return ret;
}
예제 #3
0
TEST(fs_config, odm_files_alias) {
    check_two(__for_testing_only__android_files, "files", "odm/");
}
예제 #4
0
TEST(fs_config, odm_dirs_alias) {
    check_two(__for_testing_only__android_dirs, "dirs", "odm/");
}
예제 #5
0
TEST(fs_config, vendor_files_alias) {
    check_two(__for_testing_only__android_files, "files", "vendor/");
}
예제 #6
0
TEST(fs_config, vendor_dirs_alias) {
    check_two(__for_testing_only__android_dirs, "dirs", "vendor/");
}
예제 #7
0
void driver()  // Called for each thread
{
  const int num_to_check = 100;
  // Calculated values
  int64_t max_location = num_particles * sparsity;
  int64_t half_radius = int64_t((double(radius)/2) * double(sparsity));

  // Allocation 
  xlocation_array = new int64_t[num_particles];
  weight_array = new int64_t[num_particles];
  radius_array = new int64_t[num_particles];
  answer_array = new int64_t[num_particles];
  sort_array = new particle_t[num_particles];
  
  check_particle_array = new int64_t[num_to_check];
  check_answer_array = new int64_t[num_to_check];
  
  double sort_elapsed_time = 0.0;
  double compute_elapsed_time = 0.0;
  for (int trial = 1; trial <= num_trials; trial++) {

    // fill_rand(num_particles, xlocation_array, max_location);
    
    for (int64_t i = 0; i<num_particles; i++) {
      xlocation_array[i] = ppp::bigrand(max_location, 3);
      weight_array[i] = ppp::bigrand(max_weight);
      radius_array[i] = half_radius + ppp::bigrand(half_radius);
      answer_array[i] = 0;
    }
    
    /////////////////////////

    // Put in AOS (array of structures form)
    for (int64_t i = 0; i<num_particles; i++) {
      sort_array[i].xlocation = xlocation_array[i];
      sort_array[i].weight = weight_array[i];
      sort_array[i].radius = radius_array[i];
    }

    // Sort
    double sort_start_time = ppp::get_seconds();
    ppp::parallel_sort(sort_array, 0, num_particles);
    double sort_end_time = ppp::get_seconds();
    double sort_seconds = sort_end_time - sort_start_time;

    // Check the sort
    int64_t prior = 0;
    for (int64_t i = 0; i<num_particles; i++) {
      assert(prior <= sort_array[i].xlocation); // Check the sort
      prior = sort_array[i].xlocation;
    }

    // Put in SOA (structure of arrays form)
    for (int64_t i = 0; i<num_particles; i++) {
      xlocation_array[i] = sort_array[i].xlocation;
      weight_array[i] = sort_array[i].weight;
      radius_array[i] = sort_array[i].radius;
    }

    // Pre-calculate values for randomized spot checking
    for (int64_t i = 0; i<num_to_check; i++) {
      int64_t particle_to_check = ppp::bigrand(num_particles);
      check_particle_array[i] = particle_to_check;
      check_answer_array[i] = check_two(particle_to_check, num_particles, xlocation_array, weight_array, radius_array);
    }

    double compute_start_time = ppp::get_seconds();

    ComputationTwo f(num_particles, xlocation_array, weight_array, radius_array, answer_array);
    ppp::parallel_for(0, num_particles, &f, grainsize);

    //    compute_two(num_particles, xlocation_array, weight_array, radius_array, answer_array);

    double compute_end_time = ppp::get_seconds();
    double compute_seconds = compute_end_time - compute_start_time;

    /////////////////////////
        
    // Check the pre-calculated answers for randomized spot checking
    for (int64_t i = 0; i<num_to_check; i++) {
      int64_t particle_to_check = check_particle_array[i];
      int64_t expected_answer = check_answer_array[i];
      int64_t calculated_answer = answer_array[particle_to_check];
      if (expected_answer != calculated_answer) {
        std::cout << "ERROR: particle " << particle_to_check << " had value `" << calculated_answer
                  << "` not the expected value `" << expected_answer << "`\n";
      }
    }
    
    std::cout << "trial: " << trial << ", ";
    std::cout << "user: "******", ";
    std::cout << "host: " << ppp::gethost() << ", ";
    std::cout << "threads: " << num_threads << ", ";
    std::cout << "particles: " << num_particles << ", ";
    std::cout << "grainsize: " << grainsize << ", ";
    std::cout << "sort_seconds: " << sort_seconds << ", ";
    std::cout << "compute_seconds: " << compute_seconds << "\n";
    
    sort_elapsed_time += sort_seconds;
    compute_elapsed_time += compute_seconds;
  }
  
  std::cout << "average:  ";
  std::cout << "user: "******", ";
  std::cout << "host: " << ppp::gethost() << ", ";
  std::cout << "threads: " << num_threads << ", ";
  std::cout << "particles: " << num_particles << ", ";
  std::cout << "grainsize: " << grainsize << ", ";
  std::cout << "sort_seconds: " << sort_elapsed_time/double(num_trials) << ", ";
  std::cout << "compute_seconds: " << compute_elapsed_time/double(num_trials) << "\n";
}