 
 	unsigned maxbytes = devProp.totalGlobalMem;
 	//because we need 3 arrays (h_x, h_y, h_inside)
-	unsigned max_samples = maxbytes / sizeof(int);
+	unsigned max_samples = maxbytes / (sizeof(int) + sizeof(curandState));
 	// Does GPU support sample size?
-	int n = 2e8;
+	int n = 2e6;
 	if (n > max_samples) {
 		n = max_samples;
 	}

		blocks.x = divup(blocks.x, blocks.y);
	}

	// Allocate memory for RNG states
	curandState *h_rngStates = 0;
	curandState *d_rngStates = 0;
	checkCuda(
			cudaHostAlloc(&d_rngStates,
					blocks.x * threads.x * sizeof(curandState),
					cudaHostAllocWriteCombined | cudaHostAllocMapped));

	checkCuda(cudaHostGetDevicePointer(&d_rngStates, h_rngStates, 0));

	// Allocate hits array


	printf("Init RNG\n");
	unsigned int seed = (unsigned) time(0);
	initRNG<<<blocks, threads>>>(d_rngStates, n, seed);

	printf("Run computation on GPU\n");
	device_method<<<blocks, threads>>>(d_hits, n, d_rngStates);
