summaryrefslogtreecommitdiff
path: root/include/gf_cpu.h
diff options
context:
space:
mode:
authorBassam Tabbara <bassam@symform.com>2016-09-03 08:43:13 -0700
committerBassam Tabbara <bassam@symform.com>2016-09-13 12:24:25 -0700
commit4339569f14c95a8895a347845f8ed6e18b345ace (patch)
treeb603e3cc81fb8bc85a7bed6822b4df101b7bc1e9 /include/gf_cpu.h
parent7761438c63e18f380979a3bf5647574243708abd (diff)
downloadgf-complete-4339569f14c95a8895a347845f8ed6e18b345ace.tar.gz
Support for runtime SIMD detection
This commits adds support for runtime detection of SIMD instructions. The idea is that you would build once with all supported SIMD functions and the same binaries could run on different machines with varying support for SIMD. At runtime gf-complete will select the right functions based on the processor. gf_cpu.c has the logic to detect SIMD instructions. On Intel processors this is done through cpuid. For ARM on linux we use getauxv. The logic in gf_w*.c has been changed to check for runtime SIMD support and fallback to generic code. Also a new test has been added. It compares the functions selected by gf_init when we enable/disable SIMD support through build flags, with runtime enabling/disabling. The test checks if the results are identical.
Diffstat (limited to 'include/gf_cpu.h')
-rw-r--r--include/gf_cpu.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/gf_cpu.h b/include/gf_cpu.h
new file mode 100644
index 0000000..71c7227
--- /dev/null
+++ b/include/gf_cpu.h
@@ -0,0 +1,20 @@
+/*
+ * GF-Complete: A Comprehensive Open Source Library for Galois Field Arithmetic
+ * James S. Plank, Ethan L. Miller, Kevin M. Greenan,
+ * Benjamin A. Arnold, John A. Burnum, Adam W. Disney, Allen C. McBride.
+ *
+ * gf_cpu.h
+ *
+ * Identifies whether the CPU supports SIMD instructions at runtime.
+ */
+
+#pragma once
+
+extern int gf_cpu_supports_intel_pclmul;
+extern int gf_cpu_supports_intel_sse4;
+extern int gf_cpu_supports_intel_ssse3;
+extern int gf_cpu_supports_intel_sse3;
+extern int gf_cpu_supports_intel_sse2;
+extern int gf_cpu_supports_arm_neon;
+
+void gf_cpu_identify(void);