kernel_test

PURPOSE ^

This example is based on the info in:

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 This example is based on the info in:
 http://www.mathworks.co.uk/help/distcomp/executing-cuda-or-ptx-code-on-the-gpu.html

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %
0002 % This example is based on the info in:
0003 % http://www.mathworks.co.uk/help/distcomp/executing-cuda-or-ptx-code-on-the-gpu.html
0004 %
0005 
0006 %
0007 % use nvcc to compile kernel_test.cu to PTX code
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 % now test the execution
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))

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.