How to gpuArraying the imported data?

13 vues (au cours des 30 derniers jours)
sazlieya saupi teri
sazlieya saupi teri le 9 Nov 2015
I have xyz data, i want to load this data into gpuArray so i can make meshgrid processing using GPU. Do my code right?
tic; lidar=load('lidar2.txt'); lx=lidar(:,1);ly=lidar(:,2);lz=lidar(:,3); gx=gpuArray(lx);gy=gpuArray(ly);gz=gpuArray(lz);
rangeY=floor(min(ly)):1:ceil(max(ly)); rangeX=floor(min(lx)):1:ceil(max(lx));
[X,Y]=meshgrid(rangeX,rangeY);
Z=griddata(lx,ly,lz,X,Y); s=surf(X,Y,Z); set(s, 'edgecolor','none')
rangeZ=floor(min(lz)):0.2:ceil(max(lz)); [C,h]=contour(X,Y,Z,rangeZ, 'k'); %c_h=clabel(C,h,rangeZ(1:2:end));
%surf(X,Y,Z,'edgeColor','none','FaceColor','interp','FaceLighting','phong'); %contour3(X,Y,Z,rangeZ,'k')
wait(gpuDevice(1)); from_gpu_to_cpu_Z2=gather(Z); dlmwrite('mygpuTriangulation2.txt',tri,'delimiter','\t','precision',3) dlmwrite('mygpuMesh2.txt',Z,'delimiter','\t','precision',3) dlmwrite('mygpuContour2.txt',C,'delimiter','\t','precision',3)
toc;

Réponses (1)

Joss Knight
Joss Knight le 4 Déc 2015
It looks like you are assuming that by putting your mesh data on the GPU it will be available directly to the GPU for graphics display. This is not the case. gpuArray stores data in GPU main memory but this is not accessed by the renderer. All the mesh data will be being put back in CPU memory by the contour command before display.
Hardware rendering is used by default for your plots so if that's all you were after, you already have it.

Catégories

En savoir plus sur GPU Computing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by