Is the above correct, or is there something else I have to consider, if I want to compile a function with & without FMA operations?Put it in an include file, and include it once in a unit compiled for one architecture and once for the other. Make the function name either configurable via a macro, or keep the header in the unit so that you can give them different names.
Finally there is the command line parameter -Sv which is only explained as "use vector operations if available".It enables adding (and several other math and logic operations) for array operands, and will use vector operations to calculate the results. It does not perform auto-vectorization.
* the defines are set if a suitable target architecture is selected - e.g. for COREIAVX2 they are set, for COREI they are unset
* in the source I can enable / disable the use via {$optimisation FASTMATH} and {$optimisation NOFASTMATH}
Finally there is the command line parameter -Sv which is only explained as "use vector operations if available".
* is this really for generation of vector operations, or does it only relate to the vectorised parameter passing under Win?
* if the former, what magic must be applied in the source to make use of this? <= I did try some variants, but without any effect
* the defines are set if a suitable target architecture is selected - e.g. for COREIAVX2 they are set, for COREI they are unset
The defines solely depend on the specified FPU type. Both AVX2 and AVX512 have them set.* in the source I can enable / disable the use via {$optimisation FASTMATH} and {$optimisation NOFASTMATH}
FastMath might result in the loss of precision on certain platforms with certain operations (especially on platforms that support 80-bit floating point). Otherwise it will try to use FMA in case of Single or Double types (see compiler/nadd.pas, taddnode.try_fma (https://gitlab.com/freepascal.org/fpc/source/-/blob/main/compiler/nadd.pas#L3907)).Finally there is the command line parameter -Sv which is only explained as "use vector operations if available".
* is this really for generation of vector operations, or does it only relate to the vectorised parameter passing under Win?
* if the former, what magic must be applied in the source to make use of this? <= I did try some variants, but without any effect
It's related to the former. You need to arrays with 4 fields (or in general?) of an ordinal or floating point type (with a size <= 8 Byte) and you need to have SSE or higher enabled. Then the compiler will allow the use of vector operations on these types and use SIMD to achieve them.
Is the above correct, or is there something else I have to consider, if I want to compile a function with & without FMA operations?Put it in an include file, and include it once in a unit compiled for one architecture and once for the other. Make the function name either configurable via a macro, or keep the header in the unit so that you can give them different names.QuoteFinally there is the command line parameter -Sv which is only explained as "use vector operations if available".It enables adding (and several other math and logic operations) for array operands, and will use vector operations to calculate the results. It does not perform auto-vectorization.