<p>This benchmark demonstrates an OpenCL implementation of an Asian Option pricing algorithm
implemented on Altera FPGAs.</p><p>An Asian Option is a financial instrument whose price is path dependent. In this benchmark,
we consider the arithmetic Asian option. This option depends on the average of a number of
sampled point from the start time to the time of maturity. Upon maturity, the average price
is compared to the strike price for the computation of put or call.</p>
</section>
<section>
<aid="Software_Hardware_Requirements"><h2>Software & Hardware Requirements</h2></a>
<p/>
<tableclass="reqs">
<thead>
<tr>
<throwspan="3">Requirement</th>
<throwspan="3">Version</th>
<thcolspan="2">OpenCL Kernel</th><thcolspan="4">Host Program</th></tr><tr><throwspan="2">Hardware<br/>Compile</th><throwspan="2">Emulation<br/>Compile</th><thcolspan="2">Hardware</th><thcolspan="2">Emulation</th></tr><tr><th>Compile</th><th>Run</th><th>Compile</th><th>Run</th></tr></thead><tbody><tr><td>Quartus Prime Design Software <small>(Quartus II)</small></td><td>16.1 or later</td><tdclass="req">✓</td><tdclass="req">✓</td><td></td><td></td><td></td><td></td></tr><tr><td>Intel(R) FPGA SDK for OpenCL(TM)</td><td>16.1 or later</td><tdclass="req">✓</td><tdclass="req">✓</td><tdclass="req"rowspan="2">✓<divclass="either">(either)</div></td><tdclass="req"rowspan="2">✓<divclass="either">(either)</div></td><tdclass="req"rowspan="2">✓<divclass="either">(either)</div></td><tdclass="req"rowspan="2">✓<divclass="either">(either)</div></td></tr><tr><td>Intel(R) FPGA Runtime Environment for OpenCL(TM)</td><td>16.1 or later</td><td></td><td></td></tr><tr><td>Board Support Package</td><td>16.1-compatible</td><tdclass="req">✓</td><tdclass="req">✓</td><tdclass="req">✓</td><tdclass="req">✓</td><tdclass="req">✓</td><tdclass="req">✓</td></tr><tr><td>Board Hardware</td><td>-</td><td></td><td></td><td></td><tdclass="req">✓</td><td></td><td></td></tr><tr><td>gcc</td><td>4.4.7 or later</td><td></td><td></td><tdclass="req">✓</td><tdclass="req">✓</td><tdclass="req">✓</td><tdclass="req">✓</td></tr><tr><td>GNU Make</td><td>3.8.1 or later</td><td></td><td></td><tdclass="req">✓</td><td></td><tdclass="req">✓</td><td></td></tr></tbody>
This option when set to 1 will use the OpenCL 2.0 shared virtual memory (SVM) API.
</td>
</tr>
</tbody>
</table>
<p>On Linux, custom values for preprocessor defines can be specified by setting
the value of <mono>CPPFLAGS</mono> when invoking the Makefile.</p>
</section>
<section>
<aid="Running_the_Host_Program"><h2>Running the Host Program</h2></a>
<p>Before running the host program, you should have compiled the OpenCL kernel and the host program. Refer to the above sections if you have not completed those steps.</p>
<p>To run the host program on hardware, execute:</p>
<divclass="command">bin/host</div>
<p>The host program supports execution on multiple OpenCL FPGA devices. Example
output of running this application in a system with two boards is shown here:</p><preclass="console-output">
<divclass="heading"><span>Output</span></div></pre><p>The throughput is printed as the number of simulations per second. A simulation
refers to the key computation in the Monte Carlo algorithm that simulates the movement
of the stock price, as defined in <spanclass="mono">device/asian_option.cl</span>:</p><preclass="code-block prettyprint">
// Simulate the path movement using geometric brownian motion
S *= drift * exp(vol * gauss_rnd);
arithmetic_average += S;
<divclass="heading nocode"><span>Code</span></div></pre><p>Each FPGA is dedicated to computing the Asian Option value for a particular
set of parameters. The host is setup to vary the strike price when multiple OpenCL
FPGA devices are present to demonstrate scalable parallel offload of many option
price calculations.</p><section>
<h3>Running with the Emulator</h3>
<p>Prior to running the emulation flow, ensure that you have compiled the kernel for emulation.
Refer to the above sections if you have not done so. Also, please set up your environment for
emulation. Please see the <ahref="http://www.altera.com/literature/hb/opencl-sdk/aocl_programming_guide.pdf">Intel(R) FPGA SDK for OpenCL(TM) Programming Guide</a> for more information.</p>
<p>For this example design, the suggested emulation command is:</p>
<tdclass="changes"><ul><li>New readme documentation.</li><li>Provide suggested emulation-specific arguments.</li><li>Device file is now <spanclass="mono">asian_option.cl</span>.</li><li>Remove <spanclass="mono">__attribute((task))__</span> from kernels (no longer necessary).</li></ul></td>
</tr>
<tr>
<tdclass="version">2.0</td>
<tdclass="sdk-version">14.0</td>
<tdclass="date">July 2014</td>
<tdclass="changes"><ul><li>Enforced channel ordering for multi-threaded kernels in 14.0 enabled
the removal of the barrier in black_scholes kernel.</li><li>Added optional host argument to override number of
simulations to run.</li></ul></td>
</tr>
<tr>
<tdclass="version">1.1</td>
<tdclass="sdk-version">13.1</td>
<tdclass="date">January 2014</td>
<tdclass="changes"><ul><li>On Linux, fix possible compilation issues (missing include files).</li></ul></td>
</tr>
<tr>
<tdclass="version">1.0</td>
<tdclass="sdk-version">13.1</td>
<tdclass="date">December 2013</td>
<tdclass="changes"><ul><li>First release of example.</li></ul></td>
</tr>
</tbody>
</table>
</section>
<section>
<aid="Legal"><h2>Legal</h2></a>
<preclass="license">Copyright (C) 2013-2016 Altera Corporation, San Jose, California, USA. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to
whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
This agreement shall be governed in all respects by the laws of the State of California and
by the laws of the United States of America.
</pre><section><h3>Trademarks</h3><divclass="trademark"><p>OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission by Khronos.</p><p>Product is based on a published Khronos Specification, and has passed the Khronos Conformance Testing Process. Current conformance status can be found at <ahref="www.khronos.org/conformance">www.khronos.org/conformance</a>.</p></div></section>