Set some constant memory on GPU
setConstantMemory(kern,sym,val) sets the constant memory in the CUDA kernel kern with symbol name sym to contain the data in val. val can be any numeric array, including a gpuArray. The command errors if the named symbol does not exist or if it is not big enough to contain the specified data. Partially filling a constant is allowed.
There is no automatic data-type conversion for constant memory, so it is important to make sure that the supplied data is of the correct type for the constant memory symbol being filled.
setConstantMemory(kern,sym1,val1,sym2,val2,...) sets multiple constant symbols.
If KERN represents a CUDA kernel whose CU file contains the following includes and constant definitions:
#include "tmwtypes.h" __constant__ int32_t N1; __constant__ int N2; // Assume 'int' is 32 bits __constant__ double CONST_DATA;
you can fill these with MATLAB data as follows:
KERN = parallel.gpu.CUDAKernel(ptxFile,cudaFile); setConstantMemory(KERN,'N1',int32(10)); setConstantMemory(KERN,'N2',int32(10)); setConstantMemory(KERN,'CONST_DATA',1:10);