File: test_gpu_complex.m

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

mexcuda test_gpu_complex.cu

a = complex((1:7)', (7:-1:1)');
agpu = gpuArray(a);
bgpu = timestwo_complex(agpu);
b = gather(bgpu);
assert(norm(b - 2*a) < 1e-14, 'GPU complex timestwo failed');

fprintf('test_gpu_complex: PASSED\n');