-
Notifications
You must be signed in to change notification settings - Fork 23
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
Vfmadd #289
Vfmadd #289
Conversation
fflas-ffpack/fflas/fflas_faxpy.inl
Outdated
} | ||
else | ||
{ | ||
typename Field::Element_ptr Xc = fflas_new (F,N) ; |
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.
If only one of X or Y has an inc !=1 then this code copies both vectors anyway!
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.
This looks indeed wasteful
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.
Should be fixed in latest commit
typename Field::ConstElement_ptr Xi = X; | ||
typename Field::Element_ptr Yi=Y; | ||
for (; Xi < X+n*incX; Xi+=incX, Yi+=incY ) | ||
*Yi = reduce(a*(*Xi) + (*Yi), H); |
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.
Are we sure that the infix operators + and * are legit for this field?
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.
This should come from support_fast_mod (also implied by support_simd_mod)
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.
Ok. At some point, one should consider cleaning up these traits. This is #304
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.
This axpyp should also not be in the namespace vectorised as it does not use vectorization
fflas-ffpack/fflas/fflas_faxpy.inl
Outdated
typename Field::Element_ptr Yc = fflas_new (F,N) ; | ||
fassign(F,N,X,incX,Xc,1); | ||
fassign(F,N,Y,incY,Yc,1); | ||
faxpy(F,N,a,Xc,1,Yc,1,FieldCategories::ModularTag()); |
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.
From JGD: why not a call to vectorised::axpyp directly?
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.
Should be fixed in latest commit
Tests passed on |
There is still at least one bug in this branch w.r.t. the current master, but I believe it's due to recent changes in cardinality bounds.
In short, I believe that the cardinality bound is incorrect and that no modulus should make such an overflow possible. Note: Even if I encountered this problem while testing this branch, I see no reason why the same bug would not be currently present on master. Maybe it's simply better hidden. @cyrilbouvier , @ClementPernet do you have an opinion on this? |
The bug from my previous comment actually came from a not-up-to-date master (I am apparently too distracted and/or not skilful enough to actually merge master into branches). |
fflas-ffpack/fflas/fflas_faxpy.inl
Outdated
} | ||
else | ||
{ | ||
Yc = const_cast<typename Field::Element_ptr>(Y); |
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.
No need for const_cast as Y is not const
fflas-ffpack/fflas/fflas_freduce.inl
Outdated
} | ||
else | ||
{ | ||
Ac = const_cast<typename Field::Element_ptr>(A); // Oh the horror |
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.
Same here: A is not const, so why a const_cast
else | ||
{ | ||
typename Field::Element_ptr Ac; | ||
typename Field::Element_ptr Bc; |
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.
Why do we need Bc to be Element_ptr and not ConstElement_ptr, which would then remove the need for const_cast
fassign(F,N,Yc,1,Y,incY); | ||
fflas_delete(Xc); | ||
fflas_delete(Yc); | ||
typename Field::Element_ptr Xc; |
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.
Define Xc as ConstElement_ptr instead, which will remove the need for const_cast
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.
Cf. our offline discussion, the const_cast
is needed for compatibility with the signature of faxpy
. The proposed fix doesn't work (as is) since there is a branch where Xc
is assigned
All tests now passing with master (2.5.0rc0) on |
Back to it. LGTM |
Tentatively solving issue #274 (plus some minor change in
fflas_fscal.inl
)This is mostly a duplication of
fflas_fscal.inl
intofflas_faxpy.inl
and replacing muls by muladds.Tested with and without vectorisation enabled on albaron (AVX2) and retourdest (AVX512)