flint icon indicating copy to clipboard operation
flint copied to clipboard

Allow aliasing in all mpn multiplication functions

Open fredrik-johansson opened this issue 1 year ago • 4 comments

The hardcoded assembly versions do so, the FFT versions ought to do so automatically, and at intermediate sizes we could probably afford to stick in some pointer comparison and allocate temporary memory when needed.

fredrik-johansson avatar Apr 30 '24 13:04 fredrik-johansson

Hmm, not all functions allow aliasing. Whenever there is a loop involved, I believe it does not support aliasing (or it may do up to some specific iteration).

albinahlback avatar Apr 30 '24 14:04 albinahlback

Generally, I think it is a bad idea performance-wise to try to allow aliasing for low-level multiplication functions.

albinahlback avatar Apr 30 '24 14:04 albinahlback

The point is that for small n, the hardcoded functions do support aliasing, so there is no performance hit on the mpn level. But functions like fmpz_mul and arf_mul currently waste time comparing pointers, allocating temp space and copying data since they don't know about this.

Similarly, functions like fmpz_mul waste memory handling aliasing for FFT-size operands.

fredrik-johansson avatar May 02 '24 12:05 fredrik-johansson

I don't recall if the Arm semi-hardcoded multiplication routines allow for aliasing, but I'm pretty sure there is ranges there where aliasing is not allowed.

albinahlback avatar May 02 '24 13:05 albinahlback