Monthly Archives: April 2019

Binomial Tree methods for European options using GPU

Binomial methods are versatile in pricing options for it is suitable for American, European, and Asian options. With an European call option with maturity t, strike price k, spot price S, volatility σ, risk-free rate r:


For put option, the last effective term shall be in the max function shall be:

Stock’s increment, decrements, and probability to move up are given by the below respectively:


One of the CUDA samples from Nvidia is to implement the binomial model on GPU.



BeMicro SDK with Quartus 18.1 Lite

With a new laptop there are tons of software to install for getting back my development environment in the old machine. One of these is the Quartus Prime from Intel for toying with an old BeMicroSDK. Quartus is the IDE for Altera FPGA. BeMciroSDK is a development kit from Altera well before the fabless company acquired by Intel in 2015.  It sports an EP4CE22 Cyclone IV with 22K LE.

The latest version of Quartus Pro is 19.1, but it no longer supports the Cyclone IV family and have to settle for the Standard  or Lite edition. The software download is available here.

The installation is smooth on Windows 10 Pro. After the installation, I plugged in the FPGA stick into the USB port, and no lights turn on. Started the Prime Programmer to check and it does not detect any device. Then I opened the device manager and saw that USB Blaster is not installed.

Simply click Update driver button and browse to the installation of Quartus to complete the driver installation (Online driver searching does not find anything useful).quartus18-1

Finally the FPGA programming is successful on the new laptop.quartus18-3

Unexpected error from Oracle DBMS_XMLGEN package

Oracle databases provides an XML package to convert query results into XML in DBMS_XMLGEN. This is a very flexible extension in the way it executes within any SQL statements and can be used in conjunction with normal query to achieve results that is not easy to accomplish with ordinary query. For example, the following query retrieves count of rows for all tables with a column named “strike_price” in a database:

select table_name
, to_number(extractvalue(xmltype(
dbms_xmlgen.getxml('select count(*) c from '||table_name))
,'/ROWSET/ROW/C')) cnt
from user_tables t
exists (select 'x' from user_tab_cols tc
where tc.table_name=t.table_name
and lower(column_name)='strike_price')

However, after an additional where clause to limit non-zero result, Oracle returned an error:

ORA-19202: Error occurred in XML processing
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_XMLGEN", line 176
ORA-06512: at line 1
19202. 00000 - "Error occurred in XML processing%s"
*Cause: An error occurred when processing the XML function
*Action: Check the given error message and fix the appropriate problem

It turns out with Oracle database version 18 onward, the same query runs fine. The package that returned error is from a previous version of Oracle.


Test driving Nvidia RTX 2060 with TensorFlow and VS2017

Finally my new laptop that sports the new GeForce Nvidia RTX 2060 arrived. It is time to check out the muscle of this little beast with the toolset I’m familiar with.

On the hardware, the laptop is a i7-8750 and 16G RAM with a Turing architecture based GeForce RTX 2060.


The laptop came with full drivers installed. Nevertheless I downloaded the latest drivers and CUDA for the most up-to-date experience. The software include Nvidia GeForce drivers, Visual Studio Express 2017, CUDA Toolkit, and TensorFlow.


Be careful when trying all these bleeding edge technologies, not only because TensorFlow 2.0 is currently in Alpha, compatibility issues may haunt like with previous 1.x TensorFlow on CUDA 10.1. I have to fallback to 10.0 to have TF happy with it (although one can always choose the compile from source approach).


And here are my favorite nbody and Mandelbrot simulation, and also the Black Scholes sample in CUDA. The diagnostic tool in VS gives a nice real time profiling interface with graphs.


Finally for this test drive – TensorFlow with GPU. The installation is smooth until I tried to verify TF on GPU. After several failed attempts I realized it could be that CUDA 10.1 may not be compatible with the TF version installed. There are couples of suggested solutions out there, including downgrading to CUDA 9, but since my GPU is the Turing series this is not an option. Actually TF supports CUDA 10 since v.13. So I finally decided to fall back CUDA to 10.0 from 10.1 and it worked!rtx7