I have a sparse A matrix stored in column major order (it is intrisically column major) of ~80GB and another sparse matrix B relatively small (1GB) which can be loaded in row or column major with no particular effort. I need to compute a straight matrix product S = AB. My problem is that I have only 64 GB of RAM (I usually use the Eigen c++ library ) and i need to compute the product by blocks.
I was thinking to re store the A matrix in row major (even it could imply a great increase in terms of storage) and later load the new matrix A by blocks, N rows at time, compute and store the various products and at the end assembly all the blocks together.
Do you have any better ideas?
Let A be of size m by n and B be of size n by k. You might consider:
Store B by rows rather than columns.
Break up the A matrix into blocks of size m by n1. Break up B into blocks of size n1 by k.
Multiply the blocks of A times the corresponding blocks of B, and then sum/merge the results to get AB in row major form.
Keep in mind that AB will be of size m by k and might be very dense.