0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 disp(' '); err = system('/Developer/NVIDIA/CUDA-5.0/bin/nvcc -ptx kernel_test.cu');
0011 if (err==1)
0012 fprintf('error compiling kernel_test.cu: code = %d \n',err)
0013 else
0014 disp('compiled kernel_test.cu successfully')
0015 end
0016
0017
0018
0019
0020
0021 k1 = parallel.gpu.CUDAKernel('kernel_test.ptx', 'kernel_test.cu', 'add1');
0022 feval(k1, 1, 1)
0023
0024 k2 = parallel.gpu.CUDAKernel('kernel_test.ptx', 'kernel_test.cu', 'add2');
0025 feval(k2, 1, 1)
0026
0027 N = 32;
0028 k2.ThreadBlockSize = N;
0029 feval(k2, ones(N, 1), ones(N, 1))