#include <math.h>
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include "input.h"
const float sqrt05 =
sqrt(0.5f);
return 0.5f *
erfc(-x * sqrt05);
}
d1 = d1 + (R + (V * V) * 0.5) * T;
C = S * cnd_d1 - (X *
exp((-R) * T) * cnd_d2);
P = X *
exp((-R) * T) * (1 - cnd_d2) - (S * (1 - cnd_d1));
}
int main(int argc, char** argv) {
try {
int device = argc > 1 ? atoi(argv[1]) : 0;
printf(
"** ArrayFire Black-Scholes Example **\n"
"** by AccelerEyes **\n\n");
black_scholes(Cg, Pg, Sg, Xg, Rg, Vg, Tg);
printf("Warming up done\n");
int iter = 1000;
for (int n = 50; n <= 500; n += 50) {
dim4 dims = Xg.dims();
timer::start();
for (int i = 0; i < iter; i++) {
black_scholes(Cg, Pg, Sg, Xg, Rg, Vg, Tg);
}
double t = timer::stop() / iter;
printf("Input Data Size = %8d. Mean GPU Time: %0.6f ms\n",
(int)dims[0], 1000 * t);
}
fprintf(stderr,
"%s\n", e.
what());
throw;
}
return 0;
}
An ArrayFire exception class.
virtual const char * what() const
Returns an error message for the exception in a string format.
AFAPI array erfc(const array &in)
C++ Interface for complementary error function value.
AFAPI array exp(const array &in)
C++ Interface for exponential of an array.
AFAPI array log(const array &in)
C++ Interface for natural logarithm.
AFAPI array sqrt(const array &in)
C++ Interface for square root of input.
array & eval(array &a)
Evaluate an expression (nonblocking).
AFAPI void setDevice(const int device)
Sets the current device.
AFAPI void sync(const int device=-1)
Blocks until the device is finished processing.
AFAPI array tile(const array &in, const unsigned x, const unsigned y=1, const unsigned z=1, const unsigned w=1)
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.