-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added program to check for Intel TSX support
- Loading branch information
1 parent
e599240
commit 93db53c
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// This simple program prints the name of the cpu and if it supports | ||
// Intel RTM and HLE. | ||
// It exits with status code 0 only is RTM and HLE are both supported. | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
|
||
"github.com/intel-go/cpuid" | ||
) | ||
|
||
func main() { | ||
hasRTM := cpuid.HasExtendedFeature(cpuid.RTM) | ||
hasHLE := cpuid.HasExtendedFeature(cpuid.HLE) | ||
|
||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) | ||
printyesno := func(v bool) { | ||
if v { | ||
fmt.Fprintln(w, "Yes") | ||
} else { | ||
fmt.Fprintln(w, "No") | ||
} | ||
} | ||
|
||
fmt.Fprintf(w, "CPU Brand:\t%s\n", cpuid.ProcessorBrandString) | ||
fmt.Fprint(w, "RTM:\t") | ||
printyesno(hasRTM) | ||
fmt.Fprint(w, "HLE:\t") | ||
printyesno(hasHLE) | ||
w.Flush() | ||
|
||
if hasRTM && hasHLE { | ||
os.Exit(0) | ||
} else { | ||
os.Exit(1) | ||
} | ||
} |