Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 ]
Jerome

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:
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



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.