[关闭]
@BravoWA 2015-12-27T13:06:29.000000Z 字数 554 阅读 1097

MATLAB_GPU Linear Equation Solver test

未分类


  1. %=================================================================
  2. %test for the GPU solve sparse linear equations using MATLAB2015B
  3. %By Chen Jiang
  4. %=================================================================
  5. n = 30000;
  6. % get CPU data
  7. Acpu = sprandsym(n,0.02) + 100*speye(n);
  8. bcpu = rand(n,1);
  9. % get GPU data
  10. Agpu = gpuArray(Acpu);
  11. bgpu = gpuArray(bcpu);
  12. %% timing for gmres
  13. % cpu version
  14. tic;
  15. xcpu_gmres = gmres(Acpu,bcpu);
  16. t_gmres_cpu = toc;
  17. % gpu version
  18. tic;
  19. xgpu_gmres = gather(gmres(Agpu,bcpu));
  20. t_gmres_gpu = toc;
  21. residual = norm(xcpu_gmres - xgpu_gmres)/norm(xcpu_gmres);
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注