3
$\begingroup$

I am attempting to run some CUDA functions in MMA 12.1, specifically CUDAFinancialDerivative. As I recall, this function (and other CUDA functions) ran successfully on this machine with earlier versions of MMA. First of all:

CUDAQ[]
True

and

  CUDAInformation[]

{1 -> {"Name" -> "GeForce GTX 660", "Clock Rate" -> 888500, 
   "Compute Capabilities" -> 3., "GPU Overlap" -> 1, 
   "Maximum Block Dimensions" -> {1024, 1024, 64}, 
   "Maximum Grid Dimensions" -> {2147483647, 65535, 65535}, 
   "Maximum Threads Per Block" -> 1024, 
   "Maximum Shared Memory Per Block" -> 49152, 
   "Total Constant Memory" -> 65536, "Warp Size" -> 32, 
   "Maximum Pitch" -> 2147483647, 
   "Maximum Registers Per Block" -> 65536, "Texture Alignment" -> 512,
    "Multiprocessor Count" -> 6, "Core Count" -> 1152, 
   "Execution Timeout" -> 1, "Integrated" -> False, 
   "Can Map Host Memory" -> True, "Compute Mode" -> "Default", 
   "Texture1D Width" -> 65536, "Texture2D Width" -> 65536, 
   "Texture2D Height" -> 65536, "Texture3D Width" -> 4096, 
   "Texture3D Height" -> 4096, "Texture3D Depth" -> 4096, 
   "Texture2D Array Width" -> 16384, 
   "Texture2D Array Height" -> 16384, 
   "Texture2D Array Slices" -> 2048, "Surface Alignment" -> 512, 
   "Concurrent Kernels" -> True, "ECC Enabled" -> False, 
   "TCC Enabled" -> False, "Total Memory" -> 1610612736}, 
 2 -> {"Name" -> "GeForce GTX 660", "Clock Rate" -> 888500, 
   "Compute Capabilities" -> 3., "GPU Overlap" -> 1, 
   "Maximum Block Dimensions" -> {1024, 1024, 64}, 
   "Maximum Grid Dimensions" -> {2147483647, 65535, 65535}, 
   "Maximum Threads Per Block" -> 1024, 
   "Maximum Shared Memory Per Block" -> 49152, 
   "Total Constant Memory" -> 65536, "Warp Size" -> 32, 
   "Maximum Pitch" -> 2147483647, 
   "Maximum Registers Per Block" -> 65536, "Texture Alignment" -> 512,
    "Multiprocessor Count" -> 6, "Core Count" -> 1152, 
   "Execution Timeout" -> 1, "Integrated" -> False, 
   "Can Map Host Memory" -> True, "Compute Mode" -> "Default", 
   "Texture1D Width" -> 65536, "Texture2D Width" -> 65536, 
   "Texture2D Height" -> 65536, "Texture3D Width" -> 4096, 
   "Texture3D Height" -> 4096, "Texture3D Depth" -> 4096, 
   "Texture2D Array Width" -> 16384, 
   "Texture2D Array Height" -> 16384, 
   "Texture2D Array Slices" -> 2048, "Surface Alignment" -> 512, 
   "Concurrent Kernels" -> True, "ECC Enabled" -> False, 
   "TCC Enabled" -> False, "Total Memory" -> 1610612736}}

Taking an example of the documentation:

 numberOfOptions = 32;
spotPrices = RandomReal[{25.0, 35.0}, numberOfOptions];
strikePrices = RandomReal[{20.0, 40.0}, numberOfOptions];
expiration = RandomReal[{0.1, 10.0}, numberOfOptions];
interest = 0.08;
volatility = RandomReal[{0.10, 0.50}, numberOfOptions];
dividend = RandomReal[{0.2, 0.06}, numberOfOptions];

Then we try:

CUDAFinancialDerivative[{"AsianArithmetic", "Call"}, { 
  "StrikePrice" -> strikePrices, "Expiration" -> expiration}, { 
  "CurrentPrice" -> spotPrices, "InterestRate" -> interest, 
  "Volatility" -> volatility, "Dividend" -> dividend}]

and get:

{1.419*10^-320, 0., 2.4098*10^-319, 0., 2.103*10^-320, 
 3.89353*10^-319, 2.49266*10^-319, 3.85673*10^-319, 2.00793*10^-319, 
 2.9888*10^-319, 1.43516*10^-319, 3.87397*10^-319, 1.56154*10^-319, 
 3.26177*10^-319, 1.82483*10^-319, 3.49774*10^-319, 2.3166*10^-319, 
 3.0936*10^-319, 2.6364*10^-319, 4.4504*10^-319, 2.45595*10^-319, 
 3.43484*10^-319, 2.64745*10^-319, 3.0605*10^-319, 1.45507*10^-319, 
 2.99834*10^-319, 1.2443*10^-319, 3.74166*10^-319, 1.66164*10^-319, 
 2.3544*10^-319, 3.2534*10^-320, 2.39577*10^-319}

Ok lets try something else:

FinancialDerivative[{"European", 
    "Call"}, {"StrikePrice" -> strikePrices, 
    "Expiration" -> #}, {"CurrentPrice" -> spotPrices, 
    "InterestRate" -> interest, "Volatility" -> volatility, 
    "Dividend" -> dividend}] & /@ expiration

Which works fine, of course:

{4.40316, 2.91099, 5.08987, 1.28558, 1.66779, 3.98423, 6.77612, \
3.85855, 3.3438, 1.78221, 1.2393, 3.91376, 1.57782, 2.30576, 2.49557, \
2.84662, 5.29891, 1.97134, 8.14635, 6.17571, 6.44613, 2.69374, \
8.24206, 1.91004, 1.28689, 1.79885, 0.830358, 3.50671, 1.88812, \
0.903983, 6.32724, 5.91882}

Now try the CUDA function:

CUDAFinancialDerivative[{"European", 
  "Call"}, {"StrikePrice" -> strikePrices, 
  "Expiration" -> expiration}, {"CurrentPrice" -> spotPrices, 
  "InterestRate" -> interest, "Volatility" -> volatility, 
  "Dividend" -> dividend}]

Again we get garbage:

{0., 0., -2.28652, 1.33*10^-322, 3.55847*10^-316, 4.95622*10^-315, 
 2.69309*10^-315, 4.96353*10^-315, 2.69309*10^-315, 4.96353*10^-315, 
 2.69309*10^-315, 4.96353*10^-315, 2.69309*10^-315, 4.96353*10^-315, 
 2.69309*10^-315, 4.96353*10^-315, 2.69309*10^-315, 4.96353*10^-315, 
 2.69309*10^-315, 4.96353*10^-315, 2.69309*10^-315, 4.96353*10^-315, 
 2.69451*10^-315, 4.96353*10^-315, 2.69452*10^-315, 4.96353*10^-315, 
 2.69309*10^-315, 4.96353*10^-315, 2.69407*10^-315, 4.96353*10^-315, 
 3.58735*10^-316, 2.69452*10^-315}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.