# Intel-AMX-Detection **Repository Path**: mirrors_intel/Intel-AMX-Detection ## Basic Information - **Project Name**: Intel-AMX-Detection - **Description**: No description available - **Primary Language**: Unknown - **License**: 0BSD - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-04-03 - **Last Updated**: 2026-05-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

Intel Logo

# Intel® AMX Validation for Linux and Windows © Copyright 2025, Intel Corporation ## Overview This Python script detects the presence of Intel AMX features on your CPU as well as OS by using the cpuid instruction to query processor capabilities on Linux and Windows. AMX (Advanced Matrix Extensions) is a set of instructions introduced in Intel's 4th Generation Xeon Scalable processors ("Sapphire Rapids") that significantly accelerates AI workloads, deep learning, and matrix multiplication operations. The CPUID instruction is a processor supplementary instruction allowing software to discover details of the processor. By examining the CPUID output and checking the relevant bits, you can determine if the CPU supports certain instruction sets or features. The cpuid -1 command queries the CPU's feature set. When AMX is enabled, it should show a specific bit set in the ECX register. It checks for three specific AMX features: - **AMX-TILE:** The tile architecture foundation.
- **AMX-BF16:** Support for BFloat16 operations.
- **AMX-INT8:** Support for 8-bit integer operations. ## How the Script Works This script detects AMX (Advanced Matrix Extensions) support by working with a companion executable (amx_detection) and analyzing its output. Here's how it works: ### AMX Enablement in the CPU For CPU support detection: The script runs an external program called **amx_detection** which queries CPU information via CPUID instruction. It parses the output looking for specific CPU feature flags: CPUID.07H.00H:EDX[22] indicates AMX-BF16 support.
CPUID.07H.00H:EDX[24] indicates AMX-TILE support.
CPUID.07H.00H:EDX[25] indicates AMX-INT8 support.
### AMX Enablement in the OS For OS detection: The script uses XGETBV instruction to read XCR0 register which is a control register that indicates which processor states the operating system is configured to manage using the XSAVE feature set. The OS detection is done in the **amx_os_windows.c** and **amx_os_linux.c** files where it provides platform-specific implementations for detecting CPU features, specifically related to Intel's AMX technology. The main functionality of these files: 1. **Reading CPU Information:** Both files implement functions to read CPUID information, which allows the software to query what features the CPU supports.
2. **Reading Extended Control Registers:** The code uses XGETBV instruction to read the XCR0 register, which indicates which state components are enabled by the operating system.
3. **Platform-Specific Implementations:** The implementation differs between Windows and Linux: Windows uses intrinsic functions (__cpuidex and __xgetbv) while Linux uses inline assembly to directly execute the CPUID and XGETBV instructions. The Linux version also includes syscall definitions for requesting permission to use certain CPU extended features, which is needed for AMX functionality. ### Why Check for AMX Support? AMX can provide significant performance improvements for: - Machine learning applications - AI inference workloads - Scientific computing - Applications using matrix operations Detecting AMX support helps determine if your system can benefit from AMX-optimized software and libraries like Intel's oneAPI, PyTorch with Intel extensions, or TensorFlow with oneDNN. ## Prerequistes ### Linux - Python 3.6 or higher ### Windows - Python 3.6 or higher - Microsoft Visual Studio 2022
Once Visual Studio is installed click on the Tools tab and navigate to the "Get Tools and Features" section. Ensure that the following settings are selected and then select install while downloading in the bottom right.
![alt text](./images/image-3.png) ## Usage ### Linux 1. Launch an instance on desired platform and SSH into instance 2. Clone the repository to get the required files: amx-detect-linux.py, amx_os_linux.c, amx_detection.c, amx_detection.h ```bash git clone https://github.com/intel/Intel-AMX-Detection.git cd Intel-AMX-Detection ``` 3. Compile both amx_os_linux.c and amx_detection.c together ```bash gcc -o amx_detection amx_detection.c amx_os_linux.c ``` 4. Compiling these files should output the executable amx_detection to the current directory 5. Run the script ```bash python3 amx-detect-linux.py ``` ### Expected Output If AMX is enabled on the CPU and OS the script should output the following ![alt text](./images/image-6.png) ### Windows 1. Launch Windows instance and RDP into instance 2. Clone repository to get required files: amx-detect-windows.py, amx_detection.c, amx_detection.h, and amx_os_windows.c ```bash git clone https://github.com/intel/Intel-AMX-Detection.git cd Intel-AMX-Detection ``` 3. Open Microsoft Visual Studio and navigate to the current directory 4. Compile the source files by running the following command ```bash cl amx_detection.c amx_os_windows.c ``` 5. Once finished compiling, an amx_detection.exe file should be outputted to the repository folder. Exit out of visual studio 7. Open command prompt and navigate to the current directory 8. Run the script by running ```bash py amx-detect-windows.py ``` ### Expected Output If AMX is enabled on the CPU and OS the script should output the following ![alt text](./images/image-7.png) ## License BSD Zero Clause License Copyright (C) 2025 Intel Corporation Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ## More Information For more information regarding AMX and AMX specific implementation please visit the following developer guide: https://www.intel.com/content/www/us/en/content-details/671488/intel-64-and-ia-32-architectures-optimization-reference-manual-volume-1.html