OpenCL Kernels.

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.

  1. An "integrand" for the C routines is a structure with a pointer to a multivariate function (the integrand) and a pointer of type void* to its ptional parameters. These are defined in include/integrands.h.
  2. The C routines allocate a small amount of scratch space using the "malloc" function.

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.

Configuration notes

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 #define commands.

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

Multi-Gauss-Kronrod rules

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.

 All Classes Functions Variables