OpenCL multi-quadrature routines are based on the C routines in the serial directory. Key differences in the C and OpenCL routines highlight some restrictions imposed by the latter for computing across heterogenous platforms.
void*to its ptional parameters. These are defined in include/integrands.h.
The OpenCL language (i) prohibits pointers to functions, (ii) does not support dynamic memory allocation, and (iii) only specifies support for single precision floating point arithmetic.
Item (1) is accommodated in the OpenCL setting by declaring all integrands to be functions with the following name and signature:
void cl_flt_integrand(unsigned int dim, const float* x, __global float* params, float* val);
Each integrand is defined in its own source file.
The amount of scratch space dynamically allocated in item (2) is equal to the dimension of the integration domain. This is accomodated in the OpenCL setting by instead using static arrays whose size is specified at compile time by the MAX_QUAD_DIM preprocessor macro.
Preprocessor macros for OpenCL programs can be supplied in several different ways. One way is via the -D flag when compiling the program using the OpenCL API within a host program. Another way is to "include" a header file in which the macros are set using
The current configuration uses the second method. MAX_QUAD_DIM is defined in config.h, and it can be changed using the configure script:
$ ./configure --enable-maxdim=<MAX_QUAD_DIM> $ make
Determining the degree of the Gauss-Kronrod rule in each dimension to optimize convergence speed is more of an art than a science. Presently rules for 5, 7, 9, 13, 17, and 21-point quadrature per dimension are implemented, although the higher degrees are computationally impractical in dimesions higher than three. Modifying the kernels for other rules is straightforward.