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: Performance Difference in CPU and GPU in MATALB
Replies: 2   Last Post: Nov 9, 2012 7:07 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
Performance Difference in CPU and GPU in MATALB
Posted: Nov 8, 2012 9:16 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have invoked a cuda kernel from my MATLAB implementation; however my CPU results are faster than my gpu implementation.

The results are:

CPU: 0.000006
GPU: 0.00134
My kernel and MATLAB code is below:

Thanks in Advance!

__global__ void matrix_mult2(double *A, double *B, double * C) {
int x = blockIdx.x * blockDim.x + threadIdx.x;

C[x] = A[x] * B[x];


kernel = parallel.gpu.CUDAKernel( 'matrix_mult2.ptx', ...
'' );

kernel.ThreadBlockSize = [25,1,1];
kernel.GridSize = [1,1];

A = parallel.gpu.GPUArray.rand(5,5,'double');
B = parallel.gpu.GPUArray.rand(5,5,'double');
C = parallel.gpu.GPUArray.zeros(5,5);

C = feval(kernel,A,B,C);

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.