How to gpuArraying the imported data?

조회 수: 13 (최근 30일)
sazlieya saupi teri
sazlieya saupi teri 2015년 11월 9일
답변: Joss Knight 2015년 12월 4일
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;

답변 (1개)

Joss Knight
Joss Knight 2015년 12월 4일
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.

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by