[petsc-dev] error with flags PETSc uses for determining AVX
Jed Brown
jed at jedbrown.org
Sun Feb 14 16:27:54 CST 2021
Jacob Faibussowitsch <jacob.fai at gmail.com> writes:
>> working out dispatch in MatCreate_XXX() instead of for each function.
>
> Or use compiler extensions for multiversioned functions (I recall GCC has something similar):
> https://clang.llvm.org/docs/AttributeReference.html#target <https://clang.llvm.org/docs/AttributeReference.html#target>
Yes, if you want multiple kernel variants to live in the same source file.
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-target-function-attribute
I believe you can do something like the following to specialize "portable" code.
static inline void f_portable(size_t n, double *x) {
for (size_t i=0; i<n; i++) x[i] += 1.;
}
void f_haswell(size_t n, double *x) __attribute__((__target__("arch=haswell"))) {
f_portable(n, x);
}
void f_skylakeavx512(size_t n, double *x) __attribute__((__target__("arch=skylake-avx512"))) {
f_portable(n, x);
}
More information about the petsc-dev
mailing list