REPRESENTING HIGHER DIMENSIONAL ARRAYS INTO A GENERALIZED TWO-DIMENSIONAL ARRAY Authors K.M. Azharul Hasan Md Abu Hanif Shaikh Dept. of Computer Science and Engineering Khulna University of Engineering & Technology, Khulna, Bangladesh PRESENTATION LAYOUT Motivation toward G2A G2A Matrix Operation Algorithm Experimental Data Why G2A 3-D to 2-D Addition/Subtraction Addition/Subtraction Previous Work 4-D to 2-D Multiplication Multiplication 6-D to 2-D WHY G2A ? Modeling and analyzing scientific phenomena strongly requires handling large scale data of higher dimension efficiently and effectively The cost of index computation becomes high for higher dimensional array The cache miss rate increases for higher dimensional arrays as more cache lines need to be accessed Visualization and operation on higher dimensional array is tough for Traditional Multidimensional Array (TMA) PREVIOUS WORK Extendible Karnaugh Map Representation (EKMR) by Lin et al. But it works well till four dimensions. Matricization of n-way tensor by Brett W. Bader and Tamara G. Kolda has a higher storage rate though operation on stored data good hear. G2A N-dimensional array will be fitted in a 2-D space by placing odd dimensions in row direction and even dimensions along column direction Forward Mapping: Equivalent G2A indices from TMA(n) G2A (CONTINUED….) Backward Mapping: Finding TMA from G2A Initialize x1’ := 0, x2’ : = 0 Repeat i := 1 to n Repeat j:= i +2 to n xi := xi × lj j := j + 2 x’2 - i%2 := x’2 - i%2 + xi G2A: 3-D TO 2-D G2A A[l1'][ l2'] for TMA(3) A[2][3][4] where l1'=l1×l3=8 and l2'=l2=3 Element A[1][1]2] of TMA(3) is equivalent G2A is A[x1'][ x2'] where x1'= 1 × 4 + 2 = 6 and x2'= x2 =1 G2A is A[x1'][ x2'] is known then it’s equivalent TMA(4) becomes A[x1][x2][x3] where x3=x1'%l3=6%4=2, x1=x1'/l3 =1 and x2 =x2'=1 G2A: 4-D TO 2-D TMA(4) A[l1][l2][l3][l4] of size [2, 3, 3, 2], the corresponding G2A A[l1'][ l2‘] where l1'=l1×l3 =2×3=6 and l2'=l2×l4=3×2=6 Element A[1][1][2][0] of TMA(4) is equivalent G2A is A[x1'][ x2'] where x1'= 1 × 3 + 2 = 5 and x2'= 1 × 2 + 0=2 G2A is A[x1'][ x2'] is known then it’s equivalent TMA(3) becomes A[x1][x2][x3] [x4] where x3=x1'%l3=5%3=2, x1=x1'/l3 =1 and x4 =x2'%l4=2%2=0, x2 =x2'/l4=2/2=1 G2A: 6-D TO 2-D Similarly for G2A of size[12,12] equivalent to TMA(6) of size [2, 2, 2, 3, 3, 2] x'1= x1×l3×l5+x3×l5+x5, x'2=x2×l4×l6+x4× l6+ x6 For backward mapping x6 = 7 % l6 = 7 % 2 = 1, x4=(7/l6)%l4=(7/2)%3=0 x2 =(7/l6)/l4=(7/2)/3=1 ………… MATRIX-MATRIX ADDITION/SUBTRACTION Algorithm 1: matrixmatrix_addition_TMA_n begin for x1 = 0 to (l1-1) do for x2 = 0 to (l2-1) do …………………. …………………. for xn =0 to (ln-1) do C[x1][x2]…[xn] = A[x1][x2]…[xn] + B[x1][x2]…[xn]; End. Algorithm 2: matrix-matrix_addition_G2A begin for = 0 to (-1) do for = 0 to (-1) do C'[x'1][x'2] = A'[x'1][x'2] + B'[x'1][x'2]; End. MATRIX-MATRIX MULTIPLICATION Algorithm 3: Algorithm 4: matrixmatrix-matrix_multiplication_G2A matrix_multiplication_TMA_n begin begin for = 0 to (-1) do for x1 = 0 to (l1-1) do begin for x2 = 0 to (l2-1) do m= for x3 =0 to (l3-1) do for = 0 to (-1) do …………………… begin …………………… n= for xn-1 =0 to (l-1) do for i =0 to (l-1) do for xn =0 to (l-1) do C'[x'1][x'2] = C'[x'1][x'2] + for i =0 to (l-1) do A'[x'1][n+i] × B'[m+i][x‘2]; C[x1][x2]…[xn-1][xn]= end C[x1][x2]…[xn-1][xn] + End. A[x1][x2]…[xn-1][i]×B[x1][x2]…[i][ xn]; End. MATRIX OPERATION (BLOCK BY BLOCK) EXPERIMENTAL RESULT (ADDITION) 2500 4000 TMA(4) Addition G2A Addition 3000 1500 Execution Time (ms) Execution Time (ms) 2000 1000 500 TMA(8) Addition G2A Addition 2000 1000 0 0 0 20 40 60 80 Length of Dimensions 100 120 3 4 5 6 7 8 9 Length of Dimensions Execution time is less for our proposed G2A scheme than TMA. Because the algorithm for TMA has many loops than G2A based algorithm. Hence TMA based algorithm has higher cache miss rate than that of G2A based algorithm. 10 11 12 EXPERIMENTAL RESULT (MULTIPLICATION) 300000 60000 250000 50000 Execution Time (ms) Execution Time (ms) TMA(4) Multiplication G2A Multiplication 200000 150000 100000 TMA(8) Multiplication G2A Multiplication 40000 30000 20000 10000 50000 0 0 3 0 20 40 60 80 Length of Dimensions 100 120 4 5 6 7 8 9 Length of Dimensions Execution time is less for our proposed G2A scheme than TMA. Because the algorithm for TMA has many loops than G2A based algorithm. Hence TMA based algorithm has higher cache miss rate than that of G2A based algorithm. 10 11 12 FUTURE SCOPE Efficient Storage Scheme for higher dimensional sparse array Better Memory Management with G2A than TMA Operations on Stored data with G2A Parallelization on operation on G2A operation Thank you