New issue
Advanced search Search tips

Issue 667457 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 630077
Owner: ----
Closed: Jan 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

CPUID detection for AVX2 seems incorrect

Reported by tlip...@gmail.com, Nov 21 2016

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36

Steps to reproduce the problem:
In base/cpu.cc, the call to __cpuid(cpu_info, 7) which is supposed to check for extended CPU features isn't zeroing ECX before the call.

See https://en.wikipedia.org/wiki/CPUID#EAX.3D7.2C_ECX.3D0:_Extended_Features

What is the expected behavior?

What went wrong?
If the function is called when ecx happens to be non-zero, it will return a set of all zero flags and disable features unnecessarily.

Did this work before? N/A 

Chrome version: 53.0.2785.116  Channel: n/a
OS Version: 
Flash Version: Shockwave Flash 23.0 r0
 
Components: Internals
Labels: Needs-Triage-M54 M-54
Could you please provide a sample testcase/ steps for the ease of triaging.

Comment 2 by tlip...@gmail.com, Nov 21 2016

Unfortunately I don't have a testcase/repro, since I'm using base/cpu.cc in an external project rather than as part of Chromium. But, I found that CPU().has_avx2() on my Haswell box was returning false. When I added this diff:

--- a/src/kudu/gutil/cpu.cc
+++ b/src/kudu/gutil/cpu.cc
@@ -68,7 +68,7 @@ void __cpuid(int cpu_info[4], int info_type) {
   __asm__ volatile (
     "cpuid\n"
     : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
-    : "a"(info_type)
+    : "a"(info_type), "c"(0)
   );
 }


it fixed the issue for me and properly reported has_avx2() as true on my box (matching the flags line in /proc/cpuinfo)
Labels: -Needs-Triage-M54 TE-NeedsTriageHelp
This seems out of Scope from TE end, hence added TE-NeedsTriageHelp to get addressed further.
Labels: Needs-Triage-M54
Mergedinto: 630077
Status: Duplicate (was: Unconfirmed)

Sign in to add a comment