orzzzjq / Parallel-Banding-Algorithm-plus

Compute the exact Euclidean Distance Transform and Voronoi Diagram for 2D and 3D binary images using the GPU.
https://www.comp.nus.edu.sg/~tants/pba.html
MIT License
73 stars 8 forks source link

Why my output array is always 0 #2

Closed Tobiaswei closed 4 years ago

Tobiaswei commented 4 years ago

As title, I just copy the code and run it.

orzzzjq commented 4 years ago

We didn't write any output funtions, please paste your code here. As a recommand, please see pba-plus-2D/main.cpp line 145-148.

Tobiaswei commented 4 years ago

So does the outputVoronoi array corresponding to "Output: 2D texture. Each pixel is represented as two "short" integer " refering to its nearest site. I assumed the outputVoronoi should contain the nearest point coordinates respect to the random generate 2D texture. Thanks for your reply!

orzzzjq commented 4 years ago

Yes... outputVoronoi stores the coordinate of the nearest point generated in generateRandomPoints() for each pixel. So do u have any problems now?

Tobiaswei commented 4 years ago

outputVoronoi seems to be all zero. And it seems not jump into the kernel function since I cannot printout from any kernel function. Do you have any ideas whats wrong with it ? I compile it with nvcc pba/pba2DHost.cu main.cpp -o dt.o

orzzzjq commented 4 years ago

I can get the correct answer with nvcc main.cpp pba/pba2DHost.cu -o dt.

Tobiaswei commented 4 years ago

It sounds wired... here are the parameters I used int fboSize = 30; int nVertices = 50; output result.txt.txt Do you have any suggestions?

orzzzjq commented 4 years ago

fboSize = 30 is too small for PBA+, the texture size should be multiple of 64. You can see main.cpp line 53-55 for more details. If u want to construct DT for a small texture, you can simply put it into a larger square with a size of multiple of 64. This is for a better performance of CUDA.

Tobiaswei commented 4 years ago

Yes, I reset the fboSize = 2048 nVertices = 100 and it works correctly, giving the error 0. However, when I reset the fboSize = 1024 nVertices = 100 it gives a really large error value 1043722 Is there anything I have to change?

orzzzjq commented 4 years ago

I guess you didn't set the parameters phase1Band, phase2Band, phase3Band correctly. You can see main.cpp line 53-55 for the constraints of the parameters. Or you can take the suggested parameters on our website (Table 2. Appropriate parameters of PBA+ on different GPUs).

Tobiaswei commented 4 years ago

Thanks! Really appreciate!