-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Block SpMV #274
Comments
It is possible, but is not directly provided by the library. There is an example of a block-valued spmv in vexcl backend for amgcl here: The code extends vexcl sparse matrix operations to support |
Thank you for your prompt reply, I will try to follow it. Do you have an estimate of the performance gain against the scalar version with regard to SpMV? |
It should be faster, but not dramatically so. Here is a quick experiment of using amgcl to solve an elasticity problem which has a 4x4 block structure. In the first case the matrix is treated as a scalar one, and pointwise aggregation coarsening (block_size=4) is employed
In the second case the matrix is treated as block-valued with 4x4 blocks (-b4):
As you can see, the problem solution requires similar number of iterations (where each iteration consists of a number of spmv operations) in both cases, but the block-valued one is about 30% faster (the 'solve' line in profile). Also, the method is constructed ('setup') much faster in block-valued case, but that is done on the CPU side. |
Hi Denis, with the help of AMGCL I was able to add support for block matrices in my application, thanks! Now I'm trying to inline a sequence of operations, which I can do using scalar matrices but not with block matrices: This sequence (scalar):
is inlined as:
where However, with the block version, if I try to inline that sequence I get the error:
where:
Also, in order to perform
Do you think it is possible to inline the block matrix version? If so, do you have any suggestion on how to accomplish that? Thank you very much. |
I think you should use The block matrices that are implemented in amgcl with amgcl/backend/vexcl_static_matrix.hpp do support inlining. For example, the residual operation is completely inline here: |
Hi Denis, I converted all the declarations to
Then, I can compile the following:
But when I run it I receive this error:
No problem running that with the scalar version, though. |
The kernel looks like it is almost working for you. The problem is that OpenCL does not know how to multiply tmp = mul(*m_D, (*m_Z * x)); The example of such a function implemented in a generic way can be found here: This is used in If you only need the 3x3 case, the function definition may be as simple as VEX_FUNCTION(value_type_vector, mul, (value_type_matrix, a)(value_type_vector, x),
amgcl_matrix_double_3x1 r;
r[0][0] = a[0][0] * x[0] + a[0][1] * x[1] + a[0][2] * x[2];
r[1][0] = a[1][0] * x[0] + a[1][1] * x[1] + a[1][2] * x[2];
r[2][0] = a[2][0] * x[0] + a[2][1] * x[1] + a[2][2] * x[2];
return r;
); |
Hi Denis, thank you for your answer. Following the proposed approach, would the following work as well (gets rid of
And, if so, would it be more efficient than doing the calculation in two steps:
? Thanks again. |
|
Yes, it is a sparse block matrix. I was hopping VexCL would magically fuse them into a single kernel... ;-) I'll check which is best. Thank you. |
VexCL will fuse them into a single kernel, but I am afraid the kernel will be quite ineffective. |
Hi Denis, I ended up using
which leads to a speedup of 1.2 over doing three separate operations (
Thank you. |
Hi, first of all, thanks for the development and maintenance of this great library!
I would like to know if there is any plan to support block sparse matrices and block SpMV with constant-size blocks. This would speedup the kernel by reducing the indexing overhead for this class of matrices.
Thank you.
The text was updated successfully, but these errors were encountered: