This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 29ee2ed14b5578e915d288cd07d32c5f42486366
Author: Todd Lipcon <[email protected]>
AuthorDate: Mon Mar 23 13:10:52 2020 -0700

    gutil: add CPU detection flags for carryless multiplication, BMI
    
    These instruction sets are useful for various code paths in my upcoming
    columnar serialization patch. This adds flag detection based on the
    tables in the Intel software development manual Table 3-8 "Information
    Returned by CPUID Instruction" and Table 3-10 "Feature Information
    Returned in the ECX Register"
    
    [1] 
https://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-vol-2a-manual.html
    
    Change-Id: I89a0c6eab5e37dc8ce59fe1a048670c6c79c692a
    Reviewed-on: http://gerrit.cloudera.org:8080/15536
    Reviewed-by: Adar Dembo <[email protected]>
    Tested-by: Kudu Jenkins
---
 src/kudu/gutil/cpu.cc | 6 ++++++
 src/kudu/gutil/cpu.h  | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/src/kudu/gutil/cpu.cc b/src/kudu/gutil/cpu.cc
index 17063a0..b3ea105 100644
--- a/src/kudu/gutil/cpu.cc
+++ b/src/kudu/gutil/cpu.cc
@@ -30,12 +30,15 @@ CPU::CPU()
     has_sse_(false),
     has_sse2_(false),
     has_sse3_(false),
+    has_pclmulqdq_(false),
     has_ssse3_(false),
     has_sse41_(false),
     has_sse42_(false),
     has_avx_(false),
     has_avx2_(false),
     has_aesni_(false),
+    has_bmi_(false),
+    has_bmi2_(false),
     has_non_stop_time_stamp_counter_(false),
     has_broken_neon_(false),
     cpu_vendor_("unknown") {
@@ -219,6 +222,7 @@ void CPU::Initialize() {
     has_sse_ =   (cpu_info[3] & 0x02000000) != 0;
     has_sse2_ =  (cpu_info[3] & 0x04000000) != 0;
     has_sse3_ =  (cpu_info[2] & 0x00000001) != 0;
+    has_pclmulqdq_ = (cpu_info[2] & 0x00000002) != 0;
     has_ssse3_ = (cpu_info[2] & 0x00000200) != 0;
     has_sse41_ = (cpu_info[2] & 0x00080000) != 0;
     has_sse42_ = (cpu_info[2] & 0x00100000) != 0;
@@ -239,6 +243,8 @@ void CPU::Initialize() {
         (_xgetbv(0) & 6) == 6 /* XSAVE enabled by kernel */;
     has_aesni_ = (cpu_info[2] & 0x02000000) != 0;
     has_avx2_ = has_avx_ && (cpu_info7[1] & 0x00000020) != 0;
+    has_bmi_ = cpu_info7[1] & (1 << 3);
+    has_bmi2_ = cpu_info7[1] & (1 << 8);
   }
 
   // Get the brand string of the cpu.
diff --git a/src/kudu/gutil/cpu.h b/src/kudu/gutil/cpu.h
index 6549814..b3cf2e5 100644
--- a/src/kudu/gutil/cpu.h
+++ b/src/kudu/gutil/cpu.h
@@ -41,12 +41,15 @@ class CPU {
   bool has_sse() const { return has_sse_; }
   bool has_sse2() const { return has_sse2_; }
   bool has_sse3() const { return has_sse3_; }
+  bool has_pclmulqdq() const { return has_pclmulqdq_; }
   bool has_ssse3() const { return has_ssse3_; }
   bool has_sse41() const { return has_sse41_; }
   bool has_sse42() const { return has_sse42_; }
   bool has_avx() const { return has_avx_; }
   bool has_avx2() const { return has_avx2_; }
   bool has_aesni() const { return has_aesni_; }
+  bool has_bmi() const { return has_bmi_; }
+  bool has_bmi2() const { return has_bmi2_; }
   bool has_non_stop_time_stamp_counter() const {
     return has_non_stop_time_stamp_counter_;
   }
@@ -73,12 +76,15 @@ class CPU {
   bool has_sse_;
   bool has_sse2_;
   bool has_sse3_;
+  bool has_pclmulqdq_;
   bool has_ssse3_;
   bool has_sse41_;
   bool has_sse42_;
   bool has_avx_;
   bool has_avx2_;
   bool has_aesni_;
+  bool has_bmi_;
+  bool has_bmi2_;
   bool has_non_stop_time_stamp_counter_;
   bool has_broken_neon_;
   std::string cpu_vendor_;

Reply via email to