Esempio n. 1
0
// given two vectors, compare their elements
void compareResults(thrust::device_vector<int> a, thrust::device_vector<int> b, int numOfParticles, string txt)
{
	thrust::device_vector<int> c(numOfParticles);
	thrust::fill(c.begin(), c.end(), 0);

	thrust::for_each(CountingIterator(0), CountingIterator(0)+numOfParticles,
			compare(thrust::raw_pointer_cast(&*a.begin()), thrust::raw_pointer_cast(&*b.begin()), thrust::raw_pointer_cast(&*c.begin())));
	int count = thrust::reduce(c.begin(), c.begin() + numOfParticles);

	std::string output = (count==0) ? txt+" - Result is the same" : txt+" - Result is NOT the same";
  std::cout << output << std::endl;
	if(count != 0) std::cout << "count " << count << std::endl << std::endl;
}
Esempio n. 2
0
 // overloaded () operator invoked by odeint
 public: void operator()(
   const thrust::device_vector<real_t>&, 
   thrust::device_vector<real_t> &dxy_dt, 
   const real_t
 )
 {
   thrust::transform(
     iter, iter + stat.n_part, 
     dxy_dt.begin() + stat.n_part, 
     term_vel(stat, envi)
   );
 }