mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
clean up loops and add AVX-512
This commit is contained in:
parent
9d5a00bde1
commit
b8753e3daf
@ -39,11 +39,12 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
struct XcompileMode {
|
struct XcompileMode {
|
||||||
const char *name;
|
const string name;
|
||||||
unsigned long long cpu_features;
|
unsigned long long cpu_features;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const XcompileMode xcompile_options[] = {
|
static const XcompileMode xcompile_options[] = {
|
||||||
|
{ "avx512", HS_CPU_FEATURES_AVX512 },
|
||||||
{ "avx2", HS_CPU_FEATURES_AVX2 },
|
{ "avx2", HS_CPU_FEATURES_AVX2 },
|
||||||
{ "base", 0 },
|
{ "base", 0 },
|
||||||
};
|
};
|
||||||
@ -60,12 +61,10 @@ unique_ptr<hs_platform_info> xcompileReadMode(const char *s) {
|
|||||||
bool found_mode = false;
|
bool found_mode = false;
|
||||||
|
|
||||||
if (!opt.empty()) {
|
if (!opt.empty()) {
|
||||||
const size_t numOpts = ARRAY_LENGTH(xcompile_options);
|
for (const auto &xcompile : xcompile_options) {
|
||||||
for (size_t i = 0; i < numOpts; i++) {
|
if (opt == xcompile.name) {
|
||||||
if (opt == xcompile_options[i].name) {
|
DEBUG_PRINTF("found opt %zu:%llu\n", i, xcompile.cpu_features);
|
||||||
DEBUG_PRINTF("found opt %zu:%llu\n", i,
|
rv.cpu_features = xcompile.cpu_features;
|
||||||
xcompile_options[i].cpu_features);
|
|
||||||
rv.cpu_features = xcompile_options[i].cpu_features;
|
|
||||||
found_mode = true;
|
found_mode = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -88,6 +87,11 @@ string to_string(const hs_platform_info &p) {
|
|||||||
|
|
||||||
if (p.cpu_features) {
|
if (p.cpu_features) {
|
||||||
u64a features = p.cpu_features;
|
u64a features = p.cpu_features;
|
||||||
|
if (features & HS_CPU_FEATURES_AVX512) {
|
||||||
|
out << " avx512";
|
||||||
|
features &= ~HS_CPU_FEATURES_AVX512;
|
||||||
|
}
|
||||||
|
|
||||||
if (features & HS_CPU_FEATURES_AVX2) {
|
if (features & HS_CPU_FEATURES_AVX2) {
|
||||||
out << " avx2";
|
out << " avx2";
|
||||||
features &= ~HS_CPU_FEATURES_AVX2;
|
features &= ~HS_CPU_FEATURES_AVX2;
|
||||||
@ -103,13 +107,11 @@ string to_string(const hs_platform_info &p) {
|
|||||||
|
|
||||||
string xcompileUsage(void) {
|
string xcompileUsage(void) {
|
||||||
string variants = "Instruction set options: ";
|
string variants = "Instruction set options: ";
|
||||||
const size_t numOpts = ARRAY_LENGTH(xcompile_options);
|
const auto commaspace = ", ";
|
||||||
for (size_t i = 0; i < numOpts; i++) {
|
auto sep = "";
|
||||||
variants += xcompile_options[i].name;
|
for (const auto &xcompile : xcompile_options) {
|
||||||
if (i + 1 != numOpts) {
|
variants += sep + xcompile.name;
|
||||||
variants += ", ";
|
sep = commaspace;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return variants;
|
return variants;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user