1 / 26

Timing Trials An investigation arising out of the Assignment 2012-2013

Timing Trials An investigation arising out of the Assignment 2012-2013. CS32310 – Nov 2013 H Holstein. Abstract. Transformations of the coordinates defining points in a 3D scene can be carried out using vector formulae or matrix formulae

vielka-lang
Download Presentation

Timing Trials An investigation arising out of the Assignment 2012-2013

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Timing TrialsAn investigation arising out of the Assignment 2012-2013 CS32310 – Nov 2013 H Holstein

  2. Abstract • Transformations of the coordinates defining points in a 3D scene can be carried out using vector formulae or matrix formulae • Operation counts suggest that the matrix formulae are more efficient when there are enough points to transform. • MATLAB Timings showed unexpectedly high matrix speedups • Cannot be explained by complexity alone

  3. Abstract • Theoretical gains levels were observedwith ‘own coded’ (slower) matrix multiply routines, • This suggests that the MATLAB matrix routines make use of some form of parallel array processing. • Conclude that MATLB matrix methodsbenefit fromparallelisation • more significant than the reduced complexity, in outperformingvector methods.

  4. Introduction • Task is to compare performance of vector and matrix transformation methods • For this purpose, plotting of the transformed points is not necessary • Carry out a theoretical operations count analysis, • Assume operation count ∝ execution time • Carry out timing experiments, using the processor clock

  5. Methods • Complexity count for a sequence of operations • Count the number of multiplications and additions required, per point transformed, • Estimate operations needed for N points • Use a fairly large point set (e.g. N ≈ 1000) on which to carry out the computation of a sequence of transformations • Do this for the matrix and the vector cases

  6. Derivation of the matrix operators • Use the vector formulae to transform the unit basis vectors. The result are the columns of the transformation matrix. Columns of 3D transformation matrix

  7. Complexity example • Consider a case with • Shift • Rotation • Shift • Scaling • Perspective projection • N points to be transformed

  8. Derivation of the matrix operators • Embed in a 4 x 4 matrix • Include shifts and perspective transformations • References: • Worksheet 3 • Homogeneous coordinates (pptx, lecture notes)

  9. Derivation of the matrix operators • Set the timer • Set up the 4 x 4 transformation matrix for each operation • Multiply the operators together • Obtain a single operator • Multiply the positions vectors ( in homogeneous coordinates) by this operator • Record the time • Repeat for different sizes of data points • Draw graph of times vs number of points

  10. MATLAB timed runs 2.8 x 10-3 s Single, one-off trial set Timings very different in different trials Optimization taking place? 1.9 x 10-3 s

  11. Results • Timing results varied, but settled down • Carried out 20 timing trials, each for 10 to 1220 points, • Ignore first 10 trials. • This way obtained repeatable results.

  12. Matrix methods - timing 1.5 x 10-3 s MATLAB Trials 11-20 Timings settled down Optimization taking place? 1.2 x 10-3 s

  13. Vector methods - timing 400 x 10-3 s MATLAB Trials 1-10 Timings immediately repeatable 0 s

  14. Comparison – average of 10 trials Vertices Vector Matrix Ratio Time (milliseconds) 10 100 200 300 400 500 600 700 800 900 1000 1100 1200 1220 3.4 29.0 57.7 86.2 114.8 143.6 172.2 200.6 229.4 258.0 286.7 315.4 344.2 350.1 1.3458 1 / 2.5 1.3469 1.3540 1.3675 1.3676 1.3737 1.3805 1.3883 1.3979 1.3962 1.4053 1.4141 1.4222 1.4163 1 / 250 Ratio of slopes Can simple complexity theory explain this result?

  15. Complexity example • Consider the same case with • Shift • Rotation • Shift • Scaling • Perspective projection • N points to be transformed

  16. Vector Arithmetic Complexity • Notation: (multiplies, adds)multiplies+adds • 3D rotation (18,11)  29 • Scaling (7,6)  13 • Perspective projection (10,13)  23 • Shift (0,3)  3 2 Shifts + 1 Rotation + 1 Scaling + 1 Proj 71 Cost for N points: 71 N

  17. Matrix Arithmetic Complexity • Set-up: N=3 for vector formula: 71x3=213 • Concatenation: 4 matrix multiplies (4 by 4): 4x16 x(4,3)  448 • Running cost • Matrix multiply (4x4)x (4xN): 4N(4,3)28N • Post processing: 4-vectors to 3 vectors: • 3N Cost for N points: 448 + 31N

  18. Theoretical operation counts Matrix methods superior for N>11

  19. Operation counts • Precise details depend on case and formula optimisation, but the result is typical.

  20. Operation counts • MATLAB trials indicated matrix methods outperforming vector methods by up to a factor of about 5000 in timing. • Operation counts do not explain this. • Repeat the experiments, using ‘own’ matrix multiply routines.

  21. Comparison – average of 10 trials Vector formulae Matrix formulae, Own coded matrix multiply

  22. Comparison – average of 10 trials Time (seconds) Vertices Vector Matrix 0.0035 0.0036 0.0043 0.0087 0.0158 0.0301 0.0443 0.0585 0.0728 0.0872 0.1013 0.1156 0.1300 0.1445 0.1588 0.1728 0.1757 0.0034 0.0046 0.0059 0.0146 0.0290 0.0577 0.0862 0.1148 0.1436 0.1722 0.2006 0.2294 0.2580 0.2867 0.3154 0.3442 0.3501 10 15 20 50 100 200 300 400 500 600 700 800 900 1000 1100 1200 1220 Ratio of slopes acceptably close to theory: 0.44

  23. Comparison – average of 10 trials • Equation of regression lines (best fit) • Matrix: • Vector • Slope ratio:

  24. Break even at N ≈10 Matrix methods superior for N>10 Vector formulae Matrix formulae, Own coded matrix multiply

  25. Conclusions • Transformation using matrix operators have lower operation counts per point transformed, than corresponding vector formulae • Initial timing tests showed matrix methods up to about 250 times faster, with an extrapolation up to 5000 times faster. • Theory can explain a speedup by about 2 • Factor 2 verified by ‘own code’ matrix methods • A greater speedup in matrix method can comes from parallel array processing • Appears that MATLAB uses this (via graphics card) • Feature not directly available to vector methods

  26. END

More Related