diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-06-20 19:08:14 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-06-25 18:49:28 +0000 |
commit | f6d9cc5b79d545be0c64ff6fd85131a89ee21edd (patch) | |
tree | 42ead74a188d61c4011bb61fc876ffee0938fe35 /util | |
parent | 74ce4ffff6cd771a558790c7f602387491ffeb5a (diff) |
SIMD: Refactor the constants to be actual bit values
... instead of being the bit numbers. This allows us to test more than
one feature at a time with qCpuHasFeature (see commit about the Haswell
architecture features). The drawback is that we won't be able to handle
more than 63 different CPU features, though we're likely quite far from
it (x86 currently has only 36 features).
Change-Id: Iff4151c519c144d580c4fffd153a0acbfd74c2c6
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-x | util/x86simdgen/generate.pl | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/util/x86simdgen/generate.pl b/util/x86simdgen/generate.pl index 572891d483..0b8ee434f8 100755 --- a/util/x86simdgen/generate.pl +++ b/util/x86simdgen/generate.pl @@ -99,33 +99,32 @@ for my $feature (@features) { } # Print the enum -printf "\nenum CPUFeatures {"; +print q{ +// used only to indicate that the CPU detection was initialized +static const quint64 QSimdInitialized = Q_UINT64_C(1) << 0;}; my $lastleaf; for (my $i = 0; $i < scalar @features; ++$i) { my $feature = $features[$i]; # Leaf header: - printf "\n // in %s:\n", $leaves{$feature->{leaf}} + printf "\n// in %s:\n", $leaves{$feature->{leaf}} if $feature->{leaf} ne $lastleaf; $lastleaf = $feature->{leaf}; # Feature - printf " CpuFeature%-13s = %d,\n", $feature->{id}, $i + 1; + printf "static const quint64 CpuFeature%-13s = Q_UINT64_C(1) << %d;\n", $feature->{id}, $i + 1; } print q{ - // used only to indicate that the CPU detection was initialized - QSimdInitialized = 1 -\}; - static const quint64 qCompilerCpuFeatures = 0}; # And print the compiler-enabled features part: -for my $feature (@features) { +for (my $i = 0; $i < scalar @features; ++$i) { + my $feature = $features[$i]; printf "#ifdef __%s__\n" . - " | (Q_UINT64_C(1) << CpuFeature%s)\n" . + " | (Q_UINT64_C(1) << %d) \t// CpuFeature%s\n" . "#endif\n", - $feature->{id}, $feature->{id}; + $feature->{id}, $i + 1, $feature->{id}; } print q{ ; @@ -149,7 +148,7 @@ if (my $cpp = shift @ARGV) { print "// This is a generated file. DO NOT EDIT."; print "// Please see util/x86simdgen/generate.pl"; -print "#include <qglobal.h>"; +print '#include "qsimd_p.h"'; print ""; # Now generate the string table and bit-location array @@ -189,4 +188,16 @@ for (my $j = 0; $j < scalar @features; ++$j) { $feature->{leaf}, $feature->{bit}; $lastname = $feature->{name}; } -print " // $lastname\n};"; +printf qq{ // $lastname +\}; + +// List of AVX512 features (see detectProcessorFeatures()) +static const quint64 AllAVX512 = 0}; + +# Print AVX512 features +for (my $j = 0; $j < scalar @features; ++$j) { + my $feature = $features[$j]; + $_ = $feature->{id}; + printf "\n | CpuFeature%s", $_ if /AVX512/; +} +print ";"; |