Merge pull request #19715 from seiko2plus:issue_19698

This commit is contained in:
Alexander Alekhin 2021-03-12 09:45:19 +00:00
commit f136adcad5

View File

@ -128,11 +128,14 @@ void* allocSingletonNewBuffer(size_t size) { return malloc(size); }
#endif #endif
#if CV_VSX && defined __linux__ #if (defined __ppc64__ || defined __PPC64__) && defined __linux__
# include "sys/auxv.h" # include "sys/auxv.h"
# ifndef AT_HWCAP2 # ifndef AT_HWCAP2
# define AT_HWCAP2 26 # define AT_HWCAP2 26
# endif # endif
# ifndef PPC_FEATURE2_ARCH_2_07
# define PPC_FEATURE2_ARCH_2_07 0x80000000
# endif
# ifndef PPC_FEATURE2_ARCH_3_00 # ifndef PPC_FEATURE2_ARCH_3_00
# define PPC_FEATURE2_ARCH_3_00 0x00800000 # define PPC_FEATURE2_ARCH_3_00 0x00800000
# endif # endif
@ -587,14 +590,25 @@ struct HWFeatures
#ifdef __mips_msa #ifdef __mips_msa
have[CV_CPU_MSA] = true; have[CV_CPU_MSA] = true;
#endif #endif
// there's no need to check VSX availability in runtime since it's always available on ppc64le CPUs
have[CV_CPU_VSX] = (CV_VSX); #if (defined __ppc64__ || defined __PPC64__) && defined __linux__
// TODO: Check VSX3 availability in runtime for other platforms unsigned int hwcap = getauxval(AT_HWCAP);
#if CV_VSX && defined __linux__ if (hwcap & PPC_FEATURE_HAS_VSX) {
uint64 hwcap2 = getauxval(AT_HWCAP2); hwcap = getauxval(AT_HWCAP2);
have[CV_CPU_VSX3] = (hwcap2 & PPC_FEATURE2_ARCH_3_00); if (hwcap & PPC_FEATURE2_ARCH_3_00) {
have[CV_CPU_VSX] = have[CV_CPU_VSX3] = true;
} else {
have[CV_CPU_VSX] = (hwcap & PPC_FEATURE2_ARCH_2_07) != 0;
}
}
#else #else
have[CV_CPU_VSX3] = (CV_VSX3); // TODO: AIX, FreeBSD
#if CV_VSX || defined _ARCH_PWR8 || defined __POWER9_VECTOR__
have[CV_CPU_VSX] = true;
#endif
#if CV_VSX3 || defined __POWER9_VECTOR__
have[CV_CPU_VSX3] = true;
#endif
#endif #endif
bool skip_baseline_check = false; bool skip_baseline_check = false;