Date: Nov 8, 2012 9:16 PM
Author: Jerome
Subject: Performance Difference in CPU and GPU in MATALB

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!

matrix.cu

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

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


}



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


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);