From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <36683D70.5A8AEAF2@nist.gov> Date: Fri, 04 Dec 1998 14:52:16 -0500 From: Adam C. Powell, IV Subject: Re: Optimizing CRS-Matrix routines In-Reply-To: <3667cc2e2696002@u8455.bs.ptb.de> Thomas Bruns wrote: > Hi, > > recently I modified the code of a FEM-Application due to the > information on loop otimization from Mr. Goto, and it was a real > improvement. > But those optimization base on fixed loop-boundaries. > > How can I optimize code as it is used in sparse matrix applications > where the index of the non-zero-elements is a an array of it`s own > like: > --------------------------- > double vector[MatrixDimension]; > double vector[MatrixDimension]; > > double matrix[NumberOfNonZeroElements]; /* only nze of matrix */ > int matrix_idx[NumberOfNonZeroElements]; /* col_idxt */ > int matrix_ptr[MatrixDimension+1]; /* start of row */ > > for (row=0; row for(ptr=matrix_ptr[row]; ptr vector[matrix_idx[ptr]] += matrix[ptr]*vector[matrix_idx[ptr]] > --------------------------- > You can't do manual loop-unrolling here, can you ?!?! Why not just: for (row=0; row10000; but for FEM, the matrices tend to be at least somewhat "blocked" anyway (depending on the node ordering) so I'm not convinced it would help much. But the point is, I think you do have fixed loop boundaries, because you know matrix_ptr[row] and [row+1] in advance. Right? Anyone interested in collaborating on some fast sparse matrix routines? :-) Zeen, -Adam `Cold Fusion' Powell, IV http://www.ctcms.nist.gov/~powell/ ____ USDoC, National Institute of Standards & Technology (NIST) |\ ||< | Center for Theoretical and Computational Materials Science | \||_> |