# ruapu   Detect CPU ISA features with single-file
CPU | ✅ x86, x86-64 ✅ arm, aarch64 ✅ mips ✅ powerpc ✅ s390x ✅ loongarch ✅ risc-v ✅ openrisc | ```c #define RUAPU_IMPLEMENTATION #include "ruapu.h" int main() { // initialize ruapu once ruapu_init(); // now, tell me if this cpu has avx2 int has_avx2 = ruapu_supports("avx2"); // loop all supported features const char* const* supported = ruapu_rua(); while (*supported) { fprintf(stderr, "%s\n", *supported); supported++; } return 0; } ``` |
OS | ✅ Windows ✅ Linux ✅ macOS ✅ Android ✅ iOS ✅ FreeBSD ✅ NetBSD ✅ OpenBSD | |
Compiler | ✅ GCC ✅ Clang ✅ MSVC ✅ MinGW |
Compile ruapu test program ```shell # GCC / MinGW gcc main.c -o ruapu ``` ```shell # Clang clang main.c -o ruapu ``` ```shell # MSVC cl.exe /Fe: ruapu.exe main.c ``` | Run ruapu in command line ```shell ./ruapu mmx = 1 sse = 1 sse2 = 1 sse3 = 1 ssse3 = 1 sse41 = 1 sse42 = 1 sse4a = 1 xop = 0 ... more lines omitted ... ``` |
Compile and install ruapu library ```shell # from pypi pip3 install ruapu ``` ```shell # from source code pip3 install ./python ``` | Use ruapu in python ```python import ruapu ruapu.supports("avx2") # True ruapu.supports(isa="avx2") # True ruapu.rua() #(mmx', 'sse', 'sse2', 'sse3', 'ssse3', 'sse41', 'sse42', 'avx', 'f16c', 'fma', 'avx2') ``` |
Compile ruapu library ```shell # from source code cd rust cargo build --release ``` | Use ruapu in Rust ```rust extern crate ruapu; fn main() { println!("supports neon: {}", ruapu::supports("neon").unwrap()); println!("supports avx2: {}", ruapu::supports("avx2").unwrap()); println!("rua: {:?}", ruapu::rua()); } ``` |
Compile ruapu library ```shell # from source code cd lua # lua binding has been tested on Lua 5.2~5.4 luarocks make ``` | Use ruapu in Lua ```Lua ruapu = require "ruapu"; print(ruapu.supports("mmx")); for _, ext in ipairs(ruapu.rua()) do print(ext); end ``` |