Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

27
Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces Lauren Bissett, [email protected] Nicholas Woodfield, [email protected] REU Biogrid, Summer 2009 University of Connecticut Storrs, CT 06269

description

Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces. Lauren Bissett, [email protected] Nicholas Woodfield, [email protected] REU Biogrid, Summer 2009 University of Connecticut Storrs, CT 06269. Presentation Summary. - PowerPoint PPT Presentation

Transcript of Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Page 1: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Parallel Computation of the Minimum Separation Distance of Bezier Curves

and Surfaces

Lauren Bissett, [email protected]

Nicholas Woodfield, [email protected]

REU Biogrid, Summer 2009University of ConnecticutStorrs, CT 06269

Page 2: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Presentation Summary

Background Overview CUDA Bezier Curves Bezier Surfaces Benefits/Future work

Page 3: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Background

Animation relies on continuous movement between frames to give the illusion of motion.

When an unexpected change occurs between frames, this is known as temporal aliasing.

Page 4: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Background

One method of dealing with temporal aliasing is detecting self-intersections in geometric objects.

If self-intersections are unnoticed by an animator, it could lead to the animation looking 'off'.

A scientist looking at a visual of a complicated molecule likewise could not determine if there are self-intersections.

Page 5: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Background

One method to detect self-intersections is finding a geometric object's minimum separation distance.

The minimum separation distance is the smallest doubly normal segment between any two points on the object.

A segment is doubly normal if both its endpoints are normal to the curve/surface.

Page 6: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Background

The algorithm for finding the minimum separation distance is time-consuming and not practical for use.

Therefore NVIDIA's CUDA parallel programming langauge will be used to implement the algorithms so that they run fast enough for practical use.

Page 7: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

CUDA

CUDA was developed by NVIDIA for parallel programming on the GPU.

Allows the launch of thousands of parallel threads of execution.

Unlike most GPU programming, CUDA development is relatively easy, because it extends C (with additional bindings for C++ and Fortran).

It also allows for general programming, no prior knowledge of graphics required

Page 8: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

CUDA Memory Model Threads – basic

element of execution, has own register and local memory

Blocks – composed of threads, has own shared memory

Grid – composed of blocks, contains global, constant and texture memory

Page 9: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces
Page 10: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Our Machine

The machine used for this research used a QuadroFX 5800 GPU running Windows Vista.

512 threads per block 32 registers per thread

Page 11: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Minimum Separation Distance

To find the minimum separation distance, there are three major steps:

Generate candidate double normal segments Newton's method Find segment of minimum segment length

Page 12: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Finding Candidate Segments

The method of finding potential double normal segments is simple but time-consuming.

For a given sample size (n), take n sample points and pair with all other points in the sample.

Then check if each pair is creates a double normal segment.

Page 13: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Finding Candidate Segments

Page 14: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Newton's Method

The initial estimates are run on Newton's method until they converge.

When finished, the double normal segment is compared to determine if it is of smallest length.

Page 15: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Bezier Curves

Curve case implemented first It's simple – only two parametric values – (s,t) – to

worry about

Page 16: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Bezier Curve Kernel Organization Used a 1-Dim grid composed of 1-Dim blocks Blocks divided into groups, one for each curve Threads responsible for one s parametric value on

only one curve Each thread tests its sample points vs all other points

on it's parent curve and all other curves If the candidate segment passes the double normal

test, we run newton's method on it Each thread ultimately returns the shortest segment

from its search

Page 17: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Bezier Curve Kernel Organization

What problems can arise? Sample size > maximum thread allowance Register usage Must ensure consistency among multiple blocks

E.g. If we used a thread's built in index value,

and we used 2 blocks per curve, each block

would then only test values between 0 and .5! This required equations to calculate which thread

belonged to whom

Page 18: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Bezier Curve Kernel Results

Double normals returned in a 2D array Rows are blocks Columns are threads in a block

Launched a second kernel to collapse the array into a 1-Dim array the size of the # of blocks

Iterated over those segments, and found the shortest which is our minimum separation distance

Page 19: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Results

8x to 200x speedup

n e1 e2 C code CUDA code

512 0.4 0.4 28s 154.76ms

512 0.2 0.2 26s 154ms

200 0.4 0.4 4.3s 46.6ms

10 0.4 0.4 15ms 1.81ms

Page 20: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Bezier Surfaces

Next we moved onto surfaces – bicubic bezier meshes.

Page 21: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Bezier Surfaces

Surfaces are just an extension of curves, but with two parametric values – u and v.

Each thread in the kernel handles a u,v pair. It then checks against all other u,v pairs on the surface.

Blocks were extended into 2 Dimensions, to represent the unit square.

Page 22: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Bezier Surfaces

Similar to curves, the thread determines if the segment is doubly normal, and if necessary, discards an old one of greater length if it finds a short one.

And again, Newton's method is run on each doubly normal segment.

Finally, a similar search through results to find the minimum separation distance

Page 23: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Bezier Surfaces

The thread results are again searched for the smallest segment, which is the minimum separation distance.

Page 24: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Results?

The mesh algorithm was largely completed in the last few days

Curve case, although simple, took two weeks of tweaking until the code was sastifactory

Mesh case still needs some tweaking Still confident we'll observe similar results to the

curve case However, we do not have comparable C code to

compare results

Page 25: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Benefits/Future work

How does this tie into bio-grid? Nature of the problem:

Self-intersections in molecule simulations are of interest

Leveraging the GPU for general programming 'Supercomputing for the masses' Tremendous speedups for low costs Useful for when supercomputing power is not

present nor available

Future work: Finish the mesh case!

Page 26: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Questions and Answers

Any Questions?

Page 27: Parallel Computation of the Minimum Separation Distance of Bezier Curves and Surfaces

Images

CUDA Memory Model, Dr. Dobbs Supercomputing for the Masses: http://www.ddj.com/architect/208401741?pgno=3

Double normal segments & surfaces double normals, Ed Moore's Ph.D. Thesis

Newton's method: http://en.wikipedia.org/wiki/Newton%27s_method

Bezier surface w/control points: http://www.cs.cf.ac.uk/Ralph/graphicspics/bez.GIF