-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
Speed-up the creation of a zero matrix of type Matrix_modn_dense_template
#36093
Conversation
Thank you for this. At first sight, it looks good. I will run some more benchmarks to make sure there is no performance regression due to the calloc. Could you please check if there are other places where There are currently two testing errors. Could you please check if they are due to this PR?
|
In terms of performance, this looks good to me. Some more comments. Creating the zero matrix is always significantly faster than before. In terms of performance regression for |
I have added the missing Regarding the testing errors, they do not seem to come from this PR, I have seen them in other PR. |
This looks good to me. (Looking closer at the new Some more details about performance. There is no need to comment on the significant speedups thanks to the sparse iterator (factors of several hundreds or even thousands, cf the timings above for creating the zero or identity matrix). The main question is whether the added branching in
Timings are given below for three variants (current sage 10.1.rc0, proposed solution in this PR, and version using always
Current sage 10.1.rc0:
With
This PR:
|
self._matrix = <celement **>check_allocarray(self._nrows, sizeof(celement*)) | ||
if zeroed_alloc: | ||
self._entries = <celement *>check_calloc(self._nrows * self._ncols, sizeof(celement)) | ||
self._matrix = <celement **>check_calloc(self._nrows, sizeof(celement*)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_matrix
never needs calloc
since it is filled with values just after this allocation
Just added a comment about some minor improvement I had missed. There is no need to |
Documentation preview for this PR (built with commit 513a5b5; changes) is ready! 🎉 |
Merge conflict |
Working with @marizee , we have assumed this conflict was between this PR and another one also authored by @marizee 36059. So she has worked on merging the former into the latter. I have checked the merge and it looks good to me so I would propose to close this PR and merge 36059 into develop. One question still. This is pure guess about the conflict, as we have not found where to look for more information about this merge conflict you have announced. Is there some way for us to see that there is a merge conflict, and to get some information about it? |
Fixes #35961
For example, creating the zero matrix over
GF(9001)
is currently much slower than over the rationals:This can be improved by considering the iterator as
sparse=True
in the constructor__init__
:However, it involves to calloc the memory as
zero_matrix
will only fill the diagonal coefficients of the new matrix. To avoid unnecessary computing for other methods calling the constructor__cinit__
that don't need to be zeroed beforehand, the parameterzeroed_alloc
allows to choose between callingcheck_calloc
orcheck_allocarray
with amalloc
currently implemented.This also substantially improves
identity_matrix()
fromspecial.py
:📝 Checklist
⌛ Dependencies