Efficiency and Flexibility of Jagged Arrays - PowerPoint PPT Presentation

About This Presentation
Title:

Efficiency and Flexibility of Jagged Arrays

Description:

LU decomposition with row partial pivoting (LU=PA) on VBS does not guarantee ... An LU decomposition of a sparse matrix consist of a symbolic and a numerical phase. ... – PowerPoint PPT presentation

Number of Views:266
Avg rating:3.0/5.0
Slides: 18
Provided by: iiU8
Category:

less

Transcript and Presenter's Notes

Title: Efficiency and Flexibility of Jagged Arrays


1
Efficiency and Flexibility of Jagged Arrays
  • Geir Gundersen
  • Department of Informatics
  • University of Bergen
  • Norway
  • Joint work with Trond Steihaug

2
Objectives
  • Efficiency of linear and jagged arrays for
    several numerical linear algebra algorithms.
  • Flexibility of linear and jagged arrays for LU
    factorization on a banded matrix.
  • Jagged versus Multidimensional arrays on
    row-oriented algorithms in C.
  • Compare these algorithms on only two platforms
    using the languages C, C and Java.

3
Basic Storage Schemes for Matrices
  • Storage Schemes
  • Multidimensional Arrays
  • Jagged Arrays
  • Linear Arrays

4
Algorithms
  • Algorithms
  • Matrix Vector product
  • LU Decomposition (LUPA)
  • 3D Element Sum/Voxel Sum

5
ANSI C on Red Hat Linux
  • Matrix Vector product No indication that using
    a linear array is significantly more efficient
    than jagged array.
  • LU decomposition Using jagged array was more
    efficient than linear array for all of the input
    sizes.

6
Java on Red Hat Linux
  • Matrix Vector product No indication that using
    a linear array is significantly more efficient
    than jagged array.
  • LU decomposition Using jagged array was more
    efficient than linear array for most input sizes.

7
Java on Windows XP
  • Matrix Vector product No indication that using
    a linear array is significantly more efficient
    than jagged array.
  • LU decomposition Using jagged array was more
    efficient than linear array for most input sizes.

8
C on Windows XP
  • Matrix Vector product Linear, jagged and
    multidimensional arrays have approximately the
    same efficiency.
  • LU decomposition Using jagged and linear
    arrays was clearly more efficient than
    multidimensional arrays.

9
Jagged versus Multidimensional arrays in
row-oriented algorithms in C
  • Jagged arrays are for row-oriented algorithms
    approximately 25 more efficient than
    multidimensional arrays.
  • Minor limitations in the current JIT compiler
    regarding the elimination of array bounds check
    for multidimensional arrays.
  • Column, diagonally or random traversel with
    jagged arrays performs poorly compared to
    multidimensional arrays.

10
3D Element Sum Results
11
Utilizing flexibility Sparse Matrices
  • A sparse matrix is usually defined as a matrix
    where "many" of its elements are equal to zero.
  • We benefit both in time and space by working
    only on the nonzero data structure.
  • Sparse Matrices have a wide variety of
    structures that defines several different data
    structures. Some examples

12
Data Structure Jagged Variable Band Storage
  • All matrix elements from the first nonzero to
    the last nonzero in each row are explicitly
    stored.
  • We only store and work on the nonzero structure
    of the banded matrix.
  • We refer to this data structure as Jagged
    Variable Band Storage (JVBS), since we use jagged
    arrays to store the matrix.
  • The last index is given as the sum of the first
    index and the length of the array row.

13
LU Decomposition on Variable Band Storage (VBS)
  • LU decomposition with row partial pivoting
    (LUPA) on VBS does not guarantee that the
    nonzero structure is preserved, i.e. we can get
    new entries (fill-ins) in the data structure.
  • An LU decomposition of a sparse matrix consist
    of a symbolic and a numerical phase.
  • In general, no symbolic phase can predict
    fill-ins in since the pivot choices are based on
    numerical values, during the decomposition.

14
Fill-Ins Issues
  • Two approaches
  • Resize the whole data structure for each row
    that has new fill-ins.
  • Resize each row that has new fill-ins.
  • The first approach must be done using linear or
    multidimensional arrays.
  • The second approach is clearly the most
    efficient using jagged arrays.
  • We do not have any overall loss using jagged
    arrays. It is therefore the preferred choice
    rather than linear and multidimensional arrays.

15
Java versus C on Red Hat Linux
  • Matrix Vector product Java was more efficient
    than C on for large m.
  • LU decomposition C was approximately 10 more
    efficient than Java.
  • C does not outperform Java on any algorithms we
    have tested.

16
Not Covered
  • Jagged arrays have poor performance on
    column-oriented algorithms.
  • In G. Gundersen and T. Steihaug. Data
    Structures in Java for Matrix Computation.
    Concurrency and Computation Practice and
    Experience Volume 16, Issue 8, Pages 735-815
    (July 2004). it is shown for several matrix
    multiplication algorithms the impact of
    column-oriented algorithms for jagged arrays in
    Java.
  • It is clear from those numerical results that
    column-oriented algorithms can be multiple times
    slower than their row-oriented versions.
  • That Java also is as fast as C for some
    algorithms is reported in Performance test shows
    Java as fast as C, Carmine Mangione, in
    JavaWorld, February 1998.

17
Concluding Remarks
  • The numerical testing shows insignificant
    differences in performance (less than 10)
    between Java versus C and Java versus C.
  • Jagged arrays on row-oriented algorithms in C,
    Java and C are competitive with linear arrays,
    despite non-contiguously memory layout.
  • Our observations on the performance of
    row-oriented algorithms using jagged arrays are
    important and indicate that flexibility and
    efficiency are not mutually exclusive.
Write a Comment
User Comments (0)
About PowerShow.com