<h2>Introduction</h2>
With Intel CPUs making up nearly <a href="https://www.cpubenchmark.net/market_share.html">80% of the CPU market</a> and <a href="http://jonpeddie.com/press-releases/details/gpu-market-upintel-and-nvidia-graphics-winners-in-q4-amd-down/">66% of computers using integrated graphics</a> one can easily argue that integrated graphics devices represent one of the greatest markets for GPU-accelerated computing. Here at ArrayFire, we have long recognized the potential of these devices and offer built-in support for Intel CPUs, GPUs, and AMD APUs in the OpenCL backend of our <a href="http://www.arrayfire.com">ArrayFire</a> GPU computing library. Yet one common theme for debate in the office has been how the hardware performs on different operating systems with different drivers across hardware revisions.

To answer these questions (and, perhaps, to win some intra-office geek cred) I decided to write a series of blog posts about Intel's GPU OpenCL performance. In this first installment I will compare the performance of OpenCL on Intel GPUs on Linux (via. the Beigenet driver) and Windows (via. Intel's driver).
<h2>The problem: Monte Carlo Pi estimation</h2>
To evaluate the performance of Intel's hardware I took a textbook problem of computing Pi by Monte Carlo methods and converted it to the GPU, and then applied the typical optimizations that one would do for GPU programming (more on these in a moment).
<ol>
	<li>Generate a series of random (x,y) pairs from within the <a href="http://en.wikipedia.org/wiki/Unit_square">unit square</a></li>
	<li>Determine which of these samples reside within the <a href="http://en.wikipedia.org/wiki/Unit_circle">unit circle</a></li>
	<li>Compute the ratio of the samples that reside within the square to those which reside within the circle and then multiply by four (to account for this being only one quadrant of a circle).</li>
</ol>
There is a great visualization of this process and a demonstration of how the <a href="http://commons.wikimedia.org/wiki/File:Pi_30K.gif">number of samples impacts the Pi estimate on wikipedia</a>.

If you were to implement this in C/C++, your code might look like this:
<pre class="lang:default decode:true" title="Sample CPU code for Monte Carlo Pi estimation">...

int count = 0;
float x, y;
vector&lt;float&gt; randomNums(2*samples);

// init random numbers within the unit square.
// Pack as (x,y) pairs
for(int i = 0; i &lt; 2*samples; i++)	{
	randomNums[i] = float(rand()) / RAND_MAX;
}

// count how many samples reside in the circle
for(int i = 0; i &lt; samples; i++)
{
	x = randomNums[2*i];
	y = randomNums[2*i + 1];

	if(x*x + y*y &lt; 1.0)
		count++;
}

// calculate the estimate and print the result
float pi_estimate = 4 * float(count) / samples;

...</pre>
<h2>Benchmark methods</h2>
We implemented four different versions of the Pi problem with small changes in the implementation which test various aspects of the hardware and software. These five implementations are:
<ol>
	<li>Single core CPU - A direct implementation of the code listing above</li>
	<li>A naive port of the CPU code to the GPU with no optimizations. Region testing is performed on the GPU and the  result is summed on the CPU</li>
	<li>An effort to reduce the workload of the CPU by partially summing the region testing results on the GPU</li>
	<li>A classic GPU optimization using coalesced memory load/stores</li>
	<li>And a final integrated-device specific optimization that uses <a href="http://sandbox.arrayfire.com/zero-copy-on-integrated-gpus/">zero-copy memory buffers</a></li>
</ol>
For these tests we used a few-year old ASUS N56V laptop we had in the office which features an Intel i7-3610QM CPU with a HD Graphics 4000 GT2 GPU. This particular GPU has 16 execution units which can host up to 128 concurrent threads. We installed Window 7 (Intel OpenCL driver 10.18.10.3958) and Ubuntu 14.10 (Beignet 1.1, git acfc2a2). In future blog posts we will cover 4th and 5th generation hardware (including Iris pro).
<h2>Results</h2>
<iframe width="694" height="371" seamless frameborder="0" scrolling="no" src="https://docs.google.com/spreadsheets/d/1vMeMPs4d78wsbURINCKmAFDFBwIFzpAl438Q-geoeNs/pubchart?oid=2103791532&amp;format=interactive"></iframe>

asdf
<h2>Next steps</h2>
&nbsp;

&nbsp;

Results:
* Beignet is slightly slower on a i7-3610QM processor than Intel CPU
* Beginet is 16-21x faster than a single-core CPU implementation for this problem
speedbird: Ubuntu Linux 14.10, Beignet, i7-3610QM, Intel(R) HD Graphics IvyBridge M GT2 (HD Graphics 4000)