Date: Nov 5, 2012 2:35 PM
Author: Jerome
Subject: Invoke GPU Kernel in MATLAB for Pointwise Multiplication

I am having difficulty multiplying complex numbers on the GPU. 
The values are incorrect from the C=A.*B format.

I am just using one thread to determine if the first element is correct.
My example code is the following:
func.cu
__global__ void matrix_mult(float * A_real, float*A_imag, float*B_real, float *C_real, float *C_imag)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;

C_real =A_real[x]*B_real[x] - A_imag[x] * B_imag[x];
C_imag = A_imag[x]*B_real + A_real[x] * B_imag[x];

}
main_function.m
kernel = parallel.gpu.CUDAKernel('func.ptx',func.cu);
kernel.ThreadBlockSize = [1,1,1]
kernel.GridSize = [1,1]
[x,y]=size(data)
result_real = parallel.gpu.GPUArray.zeros(x,y, 'single');
result_imag = parallel.gpu.GPUArray.zeros(x,y, 'single');
[C_real, C_imag] = feval(kernel, real(A), imag(A), imag(B), real(B), result_real, result_imag)
cvalues=complex(C_real,C_imag);


Thanks in Advance