aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/main.c b/main.c
index 09c7376..14eb66e 100644
--- a/main.c
+++ b/main.c
@@ -48,7 +48,7 @@ static __always_inline int name(void) \
} while (0)
#define report_it(name) do { \
- pr_err("%lu: %7s: %llu cycles per call\n", stamp, #name, (end_ ## name - start_ ## name) / TRIALS); \
+ pr_err("%lu: %12s: %6llu cycles per call\n", stamp, #name, (end_ ## name - start_ ## name) / TRIALS); \
} while (0)
@@ -57,7 +57,8 @@ declare_it(hacl64)
declare_it(fiat64)
declare_it(sandy2x)
declare_it(amd64)
-declare_it(precomp)
+declare_it(precomp_bmi2)
+declare_it(precomp_adx)
declare_it(fiat32)
declare_it(donna32)
@@ -71,9 +72,13 @@ static bool verify(void)
test_it(donna64, {}, {});
test_it(hacl64, {}, {});
test_it(fiat64, {}, {});
- test_it(sandy2x, kernel_fpu_begin(), kernel_fpu_end());
+ if (boot_cpu_has(X86_FEATURE_AVX) && cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL))
+ test_it(sandy2x, kernel_fpu_begin(), kernel_fpu_end());
+ if (boot_cpu_has(X86_FEATURE_BMI2))
+ test_it(precomp_bmi2, {}, {});
+ if (boot_cpu_has(X86_FEATURE_BMI2) && boot_cpu_has(X86_FEATURE_ADX))
+ test_it(precomp_adx, {}, {});
test_it(amd64, {}, {});
- test_it(precomp, {}, {});
test_it(fiat32, {}, {});
test_it(donna32, {}, {});
}
@@ -87,9 +92,10 @@ static int __init mod_init(void)
cycles_t start_donna64, end_donna64;
cycles_t start_hacl64, end_hacl64;
cycles_t start_fiat64, end_fiat64;
- cycles_t start_sandy2x, end_sandy2x;
+ cycles_t start_sandy2x = 0, end_sandy2x = 0;
cycles_t start_amd64, end_amd64;
- cycles_t start_precomp, end_precomp;
+ cycles_t start_precomp_bmi2 = 0, end_precomp_bmi2 = 0;
+ cycles_t start_precomp_adx = 0, end_precomp_adx = 0;
cycles_t start_fiat32, end_fiat32;
cycles_t start_donna32, end_donna32;
unsigned long flags;
@@ -105,11 +111,16 @@ static int __init mod_init(void)
do_it(donna64);
do_it(hacl64);
do_it(fiat64);
- kernel_fpu_begin();
- do_it(sandy2x);
- kernel_fpu_end();
+ if (boot_cpu_has(X86_FEATURE_AVX) && cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL)) {
+ kernel_fpu_begin();
+ do_it(sandy2x);
+ kernel_fpu_end();
+ }
+ if (boot_cpu_has(X86_FEATURE_BMI2))
+ do_it(precomp_bmi2);
+ if (boot_cpu_has(X86_FEATURE_BMI2) && boot_cpu_has(X86_FEATURE_ADX))
+ do_it(precomp_adx);
do_it(amd64);
- do_it(precomp);
do_it(fiat32);
do_it(donna32);
@@ -118,9 +129,13 @@ static int __init mod_init(void)
report_it(donna64);
report_it(hacl64);
report_it(fiat64);
- report_it(sandy2x);
+ if (boot_cpu_has(X86_FEATURE_AVX) && cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL))
+ report_it(sandy2x);
+ if (boot_cpu_has(X86_FEATURE_BMI2))
+ report_it(precomp_bmi2);
+ if (boot_cpu_has(X86_FEATURE_BMI2) && boot_cpu_has(X86_FEATURE_ADX))
+ report_it(precomp_adx);
report_it(amd64);
- report_it(precomp);
report_it(fiat32);
report_it(donna32);