예제 #1
0
static eTermType
ExpressionTypeProbability(const VectorFilter *filter)
{
	if (PartialExpander::direct_expand_check(eInvoke))
		return eFunction;

	assert(filter);

	int i = rnd_upto(filter->get_max_prob(), filter);
	ERROR_GUARD(MAX_TERM_TYPES);
	return (eTermType)(filter->lookup(i));
}
예제 #2
0
void CLProgramGenerator::InitRuntimeParameters() {
  globalDim = new std::vector<unsigned int>(no_dims, 1);
  localDim = new std::vector<unsigned int>(no_dims, 1);
  std::vector<unsigned int>& globalDim = *CLSmith::globalDim;
  std::vector<unsigned int>& localDim = *CLSmith::localDim;
  std::vector<unsigned int> chosen_div;
  std::vector<unsigned int> divisors;
  for (unsigned int i = 0; i < no_dims; i++) {
    globalDim[i] = rnd_upto(std::min(max_thr_per_dim, max_threads / noThreads)) + 1;
    noThreads *= globalDim[i];
  }
  unsigned int curr_thr_p_grp;
  do {
    curr_thr_p_grp = 1;
    for (unsigned int i = 0; i < no_dims; i++) {
      get_divisors(globalDim[i], &divisors);
      localDim[i] = divisors[rnd_upto(divisors.size())];
      curr_thr_p_grp *= localDim[i];
    }
  } while (curr_thr_p_grp > max_threads_per_group);
  for (unsigned int i = 0; i < no_dims; i++)
    noGroups *= globalDim[i] / localDim[i];
}