2121from reference_black_scholes import ref_python_black_scholes
2222
2323
24- def gen_option_params (n_opts , pl , ph , sl , sh , tl , th , rl , rh , vl , vh , dtype , queue = None ):
24+ def gen_option_params (
25+ n_opts , pl , ph , sl , sh , tl , th , rl , rh , vl , vh , dtype , queue = None
26+ ):
2527 nbytes = n_opts * 5 * np .dtype (dtype ).itemsize
2628 usm_mem = dpctl_mem .MemoryUSMShared (nbytes , queue = queue )
2729 params = np .ndarray (shape = (n_opts , 5 ), buffer = usm_mem , dtype = dtype )
2830 seed = 1234
29- bs .populate_params (params , pl , ph , sl , sh , tl , th , rl , rh , vl , vh , seed , queue = queue )
31+ bs .populate_params (
32+ params , pl , ph , sl , sh , tl , th , rl , rh , vl , vh , seed , queue = queue
33+ )
3034 return params
3135
3236
@@ -47,7 +51,9 @@ def gen_option_params(n_opts, pl, ph, sl, sh, tl, th, rl, rh, vl, vh, dtype, que
4751# compute prices in CPython
4852X_ref = np .array ([ref_python_black_scholes (* opt ) for opt in opts ], dtype = "d" )
4953
50- print ("Correctness check: allclose(Xgpu, Xref) == " , np .allclose (Xgpu , X_ref , atol = 1e-5 ))
54+ print (
55+ "Correctness check: allclose(Xgpu, Xref) == " , np .allclose (Xgpu , X_ref , atol = 1e-5 )
56+ )
5157
5258n_opts = 3 * 10 ** 6
5359
@@ -72,14 +78,14 @@ def gen_option_params(n_opts, pl, ph, sl, sh, tl, th, rl, rh, vl, vh, dtype, que
7278 X1 = bs .black_scholes_price (opts1 , queue = cpu_q )
7379 t1 = timeit .default_timer ()
7480
75- cpu_times .append (t1 - t0 )
81+ cpu_times .append (t1 - t0 )
7682
7783 # compute on GPU sycl device
7884
7985 t0 = timeit .default_timer ()
8086 X2 = bs .black_scholes_price (opts2 , queue = gpu_q )
8187 t1 = timeit .default_timer ()
82- gpu_times .append (t1 - t0 )
88+ gpu_times .append (t1 - t0 )
8389
8490print ("Using : {}" .format (cpu_q .sycl_device .name ))
8591print ("Wall times : {}" .format (cpu_times ))
0 commit comments