@BravoWA
2015-12-27T13:06:29.000000Z
字数 554
阅读 1097
未分类
%=================================================================
%test for the GPU solve sparse linear equations using MATLAB2015B
%By Chen Jiang
%=================================================================
n = 30000;
% get CPU data
Acpu = sprandsym(n,0.02) + 100*speye(n);
bcpu = rand(n,1);
% get GPU data
Agpu = gpuArray(Acpu);
bgpu = gpuArray(bcpu);
%% timing for gmres
% cpu version
tic;
xcpu_gmres = gmres(Acpu,bcpu);
t_gmres_cpu = toc;
% gpu version
tic;
xgpu_gmres = gather(gmres(Agpu,bcpu));
t_gmres_gpu = toc;
residual = norm(xcpu_gmres - xgpu_gmres)/norm(xcpu_gmres);