linbox-team/fflas-ffpack

Is it allowed to have big matrix?

Closed this issue · 3 comments

We are trying big matrix multiplication, but we found when matrix size reaches about 400x400, the function "fgemm" will give segmentation fault. Do we have other choices?
Also if what we need is only multiplication of two matrices, do we have to use fgemm?

Of course, you can use matrices as large as your memory permits. 400x400 is typically still a small matrix.
Please feel free to share you code, so we can inspect it.
Maybe you are allocating the matrix on the stack, as in the tutorial file, which of course should be avoided for larger matrices. Consider allocating them on the heap using

Field::Element_prt A = fflas_new (F,Nrows,Ncols);
fgemm(...);
fflas_delete(A);

Of course, you can use matrices as large as your memory permits. 400x400 is typically still a small matrix.
Please feel free to share you code, so we can inspect it.
Maybe you are allocating the matrix on the stack, as in the tutorial file, which of course should be avoided for larger matrices. Consider allocating them on the heap using

Field::Element_prt A = fflas_new (F,Nrows,Ncols);
fgemm(...);
fflas_delete(A);

Thank you for the reply.
Yes, we just modified the tutorial example.
But we just got another question. Is the function "fgemm" using multi-thread? If so, can we turn it into single-thread?
Also if we only need multiplication of two matrices, is "fgemm" the only function we can use?

fgemm is by default single-threaded, and pfgemm is for the multi-threaded (OpenMP) variant.
And yes, this is the routine for multiplying arbitrary dense matrices.