The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Invoke GPU Kernel in MATLAB for Pointwise Multiplication
Replies: 1   Last Post: Nov 6, 2012 5:37 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 48
Registered: 12/9/11
Invoke GPU Kernel in MATLAB for Pointwise Multiplication
Posted: Nov 5, 2012 2:35 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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:
__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];

kernel = parallel.gpu.CUDAKernel('func.ptx',;
kernel.ThreadBlockSize = [1,1,1]
kernel.GridSize = [1,1]
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)

Thanks in Advance

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.