/*!
 n個の[xMin,xMax],[yMin,yMax]の点をランダムに生成して返す
*/
vector<Point> genRandomPoint(const int n, const int xMin, const int xMax, const int yMin, const int yMax){
	vector<Point> points;
	for(int i=0; i<n; i++){
		boost::int64_t x = getRandomVal(xMin, xMax), y = getRandomVal(yMin, yMax);
		points.push_back(Point(x,y));
	}
	return points;
}
Beispiel #2
0
void getFlops(void *threadId) {

	volatile long i;
	volatile float x, y;

	long thId = (long)threadId;
	float bound = 1e6;
	
	double emptyTime, addTime;

	clock_t start = clock();

	for(i = 0; i < INT_MAX; i++ ){}

	clock_t fin = clock() - start;

	emptyTime = fin / CLOCKS_PER_SEC;

	x = getRandomVal(bound); 
	y = getRandomVal(bound); 
	
	start = clock();

	for(i = 0; i < INT_MAX; i++ ){
		x += y;
	}

	fin = clock() - start;

	addTime = fin / CLOCKS_PER_SEC; 
	addTime -= emptyTime;

	std::cout << "Time of the add loop (FLOPS): " << addTime << " s in thread #"<< thId << "\n\n";

	float flops = INT_MAX / addTime;
	std::cout << "GFLOPS in thread #"<< thId << ": " << flops/1e9 << "\n\n";
}