Better HN
topnewbestaskshowjobs
Log inSign up

drmackay

1 karma · joined Feb 3, 2016 (10y ago) · 2 submissions

Submissions

comment 10y ago · link · parent

The gcc compiler does vectorize the code. I wrote that gcc 4.1.2 did not interchange loops automatically (ijk to ikj). Matrix multiply is very easy for a compiler to optimize and it is easy to use to illustrate principles. There may exist some cases where a developer may see the value in interchanging loops that the compiler (intel compiler, llvm, gcc, . . . )doesn't recognize. I pointed out how to see when the compiler does this with the optimization report. If the compiler already does it for you, don't bother with explicitly making the change - save your time for something else.

comment 10y ago · link · parent

The intel compiler update 1 (16.1) was released in late 2015. It is available to download to all who have a license or are beginning a new evaluation.

For matrices of size 4000x4000 there was significant benefit for blocking the loops - please check the table again. This benefit continues as matrices continue to get larger. I specifically used two different size matrices as examples so that the reader could see that blocking is not a panacea or cure all. So as you point out for the smaller case there was no benefit - I wanted the reader to see that, so I included both data sets. The value of block size varies depending on the matrix size and the cache size of the system you are running on. When the data sets or number of iterations you are running on is relatively small (compared to cache size) the blocking will not provide benefit; don't blindly apply it. The matrix multiply was selected for pedagogical purposes - it is easy to illustrate and easy to explain. I was limited to article length - see the link to the article on finite difference methods for more on value of blocking. If you are really interested in blocking for matrix multiply there many other good articles that go into this in much more detail (and the fastest ones do block into submatrices and perform additional optimizations). (Please note the optimal blocking may be rectangular non square blocks - I did not code the general case.)