File: test_gpu.m

package info (click to toggle)
mwrap 1.3-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 1,548 kB
  • sloc: cpp: 3,315; python: 1,850; ansic: 856; makefile: 258; lex: 233; sh: 145
file content (15 lines) | stat: -rw-r--r-- 396 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function test_gpu
% Test GPU double array passing via gpuArray.
% Requires: CUDA toolkit, mexcuda, GPU device.
% Run mwrap first:
%   ../mwrap -gpu -list -cppcomplex -mb -mex test_gpu -c test_gpu.cu test_gpu.mw

mexcuda test_gpu.cu

a = (1:7)';
agpu = gpuArray(a);
bgpu = timestwo(agpu);
b = gather(bgpu);
assert(norm(b - 2*a) == 0, 'GPU double timestwo failed');

fprintf('test_gpu: PASSED\n');