ochafik/nativelibs4java — pull request #439 by fvlankvelt (2013-09-13 09:29:54+00:00)
Title: use tiled matrices for faster matrix multiplication

The matrix multiplication implementation was quite naive. There are well-known improvements to be made such as read/write coalescing & tiling. These are implemented in a couple of code samples available on the web, such as
http://www.shodor.org/media/content//petascale/materials/UPModules/matrixMultiplication/moduleDocument.pdf
and
https://developer.nvidia.com/opencl

In this patch, I've adjusted the NVidia implementation of the kernel. Haven't run systematic benchmarks yet, but sample matrix multiplications with 10M multiply-add operations go from 17.5mus to 0.66mus (25x speedup).

The block size is 16, same as in the above references. All matrices are expanded to multiples of this, so there is some overhead on the blas facade. Some current limitations:
- the containsValue method only works for matrices of commensurate dimensions
- matrices with non-commensurate sizes need to be cleared before they can be used

These limitations are obvious candidates for further improvement; another improvement that I would like to look into is to use similar techniques for the transpose kernel.