Blog Code Forum

ASM:Topology

From Wiki.cyring.fr

(Difference between revisions)
Jump to: navigation, search
(Prerequesites)
(Additional documentation)
 
(24 intermediate revisions not shown)
Line 3: Line 3:
==== Prerequesites ====
==== Prerequesites ====
* The Linux Operating System.
* The Linux Operating System.
-
* Any Linux package which provides the [http://www.linuxcommand.org/man_pages/taskset1.html taskset] command that allows the [http://en.wikipedia.org/wiki/Processor_affinity Processor affinity] ; [https://www.archlinux.org/packages/core/x86_64/util-linux util-linux] if running ArchLinux.
+
* Any Linux package which provides the [http://www.linuxcommand.org/man_pages/taskset1.html taskset] command that allows the [http://en.wikipedia.org/wiki/Processor_affinity Processor affinity].<br />
 +
** ( [https://www.archlinux.org/packages/core/x86_64/util-linux util-linux] if running ArchLinux. )
* The GNU [https://www.archlinux.org/packages/core/x86_64/gcc gcc] C compiler.
* The GNU [https://www.archlinux.org/packages/core/x86_64/gcc gcc] C compiler.
==== Getting the Source Files ====
==== Getting the Source Files ====
In the repository, download the following files in a project directory, such as x2topology
In the repository, download the following files in a project directory, such as x2topology
-
[[http://code.cyring.fr/FTS/Source/ASM/x2topology/x2topology.c|x2topology.c]]
+
* [http://code.cyring.fr/FTS/Source/ASM/x2topology/x2topology.c x2topology.c]
-
[[http://code.cyring.fr/FTS/Source/ASM/x2topology/x2topology.sh|x2topology.sh]]
+
* [http://code.cyring.fr/FTS/Source/ASM/x2topology/x2topology.sh x2topology.sh]
-
''Optionaly'', the binary executable file : [http://code.cyring.fr/FTS/Source/ASM/x2topology/x2topology x2topology]
+
* ''Optionally'', the binary executable file : [http://code.cyring.fr/FTS/Source/ASM/x2topology/x2topology x2topology]
-
==== Build the Program ====
+
 
 +
==== Compile the Source File ====
* Compile the C source file
* Compile the C source file
 +
<syntaxhighlight lang="bash">
gcc x2topology.c -o x2topology
gcc x2topology.c -o x2topology
-
* Give an executable permission to the downloaded Bash script
+
</syntaxhighlight>
 +
* Give the executable permission to the downloaded Bash script
 +
<syntaxhighlight lang="bash">
chmod +x x2topology.sh
chmod +x x2topology.sh
 +
</syntaxhighlight>
 +
 +
=== Running x2topology ===
 +
* ''Remark'': You may add your project directory to the executable PATH, or invoke x2topology with a '''./''' prefix (meaning in the current directory)<br />
 +
Launch the x2topology.sh script which iterates through all the '''enabled''' Cores
 +
<syntaxhighlight lang="bash">
 +
./x2topology.sh
 +
</syntaxhighlight>
 +
* Using a Core i7, Nehalem architecture, Hyper-threading and 4 Cores enabled, it outputs:
 +
<syntaxhighlight lang="text">
 +
OS      APIC    Thread  Core
 +
0x1    0      0      0
 +
0x2    2      0      1
 +
0x4    4      0      2
 +
0x8    6      0      3
 +
0x10    1      1      0
 +
0x20    3      1      1
 +
0x40    5      1      2
 +
0x80    7      1      3
 +
</syntaxhighlight>
 +
* Using a Core i7, Nehalem architecture, '''Hyper-threading [[ASM:Topology#Disabling the Hyper-threading|disabled]]''' and 4 Cores enabled, it outputs:
 +
<syntaxhighlight lang="text">
 +
OS      APIC    Thread  Core
 +
0x1    0      0      0
 +
0x2    2      0      1
 +
0x4    4      0      2
 +
0x8    6      0      3
 +
0x10
 +
0x20
 +
0x40
 +
0x80
 +
</syntaxhighlight>
 +
* Using a Core i7, Nehalem architecture, '''Hyper-threading disabled''' and '''only 1 Core enabled''' (3 Cores disabled), it outputs:
 +
<syntaxhighlight lang="text">
 +
OS      APIC    Thread  Core
 +
0x1    0      0      0
 +
0x2
 +
0x4
 +
0x8
 +
0x10
 +
0x20
 +
0x40
 +
0x80
 +
</syntaxhighlight>
 +
where in the header text the following fields mean:
 +
# OS is the CPU mask as defined by the Linux Kernel, see man taskset
 +
# ACPI is the identifier of the physical or logical Core in a SMT architecture
 +
# Thread is the index number of a Thread inside a Core
 +
# Core is the index number of a Core inside a Processor package
 +
==== Option ====
 +
x2topology, binary or shell script can be launched with a verbose option to get details:
 +
<syntaxhighlight lang="bash">
 +
./x2topology -v
 +
./x2topology.sh -v
 +
</syntaxhighlight><br />
 +
===== Disabling the Hyper-threading =====
 +
Hyper-threading is disabled when starting the Processor.<br />
 +
Usually this is done through the appropriate option in the BIOS.
 +
 +
== Additional documentation ==
 +
# [http://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration Intel® 64 Architecture Processor Topology Enumeration] white paper
 +
# Intel 64 and IA-32 Software Developer Manual
 +
# Intel Processor Identification CPUID Instruction

Latest revision as of 11:34, 12 March 2014

Contents

ACPI Extended Topology

Building the Program

Prerequesites

Getting the Source Files

In the repository, download the following files in a project directory, such as x2topology

Compile the Source File

  • Compile the C source file
gcc x2topology.c -o x2topology
  • Give the executable permission to the downloaded Bash script
chmod +x x2topology.sh

Running x2topology

  • Remark: You may add your project directory to the executable PATH, or invoke x2topology with a ./ prefix (meaning in the current directory)

Launch the x2topology.sh script which iterates through all the enabled Cores

./x2topology.sh
  • Using a Core i7, Nehalem architecture, Hyper-threading and 4 Cores enabled, it outputs:
OS      APIC    Thread  Core
0x1     0       0       0
0x2     2       0       1
0x4     4       0       2
0x8     6       0       3
0x10    1       1       0
0x20    3       1       1
0x40    5       1       2
0x80    7       1       3
  • Using a Core i7, Nehalem architecture, Hyper-threading disabled and 4 Cores enabled, it outputs:
OS      APIC    Thread  Core
0x1     0       0       0
0x2     2       0       1
0x4     4       0       2
0x8     6       0       3
0x10
0x20
0x40
0x80
  • Using a Core i7, Nehalem architecture, Hyper-threading disabled and only 1 Core enabled (3 Cores disabled), it outputs:
OS      APIC    Thread  Core
0x1     0       0       0
0x2
0x4
0x8
0x10
0x20
0x40
0x80

where in the header text the following fields mean:

  1. OS is the CPU mask as defined by the Linux Kernel, see man taskset
  2. ACPI is the identifier of the physical or logical Core in a SMT architecture
  3. Thread is the index number of a Thread inside a Core
  4. Core is the index number of a Core inside a Processor package

Option

x2topology, binary or shell script can be launched with a verbose option to get details:

./x2topology -v
./x2topology.sh -v

Disabling the Hyper-threading

Hyper-threading is disabled when starting the Processor.
Usually this is done through the appropriate option in the BIOS.

Additional documentation

  1. Intel® 64 Architecture Processor Topology Enumeration white paper
  2. Intel 64 and IA-32 Software Developer Manual
  3. Intel Processor Identification CPUID Instruction
Personal tools