Compare commits

...

10 Commits

Author SHA1 Message Date
00de7ebc6a add dart support 2024-10-14 11:53:27 +08:00
nihui
b9a2fafa70
drop flyci 2024-10-12 11:05:58 +08:00
Apachiww
9b8711c8f2
detect x86 bmi, gfni, vaes, rdrand, rdseed and tsx extensions (#123) 2024-09-10 14:18:27 +08:00
dependabot[bot]
34e3dd7eeb
Bump pypa/cibuildwheel from 2.19.2 to 2.20.0 (#121)
Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.19.2 to 2.20.0.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.19.2...v2.20.0)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-09 18:55:26 +08:00
Apachiww
4371e5c4c1
detect x86 aes-ni and sha extension (#120) 2024-07-29 10:40:54 +08:00
bakacai
501b6b0d75
add cangjie binding (#117) 2024-07-27 14:15:23 +08:00
柚木 鉉
28ff8bb8f7
catch SIGSEGV in sig caught (#119)
In the RISC-V extension instruction set, there are cases where cores from different manufacturers and different functional extension instructions share the same op. In such situations, it is necessary to add SIGSEGV handling to prevent program termination.
2024-07-27 14:14:42 +08:00
Easton Man
4032cd3b40
detect risc-v zcb extension (#118) 2024-07-27 14:13:55 +08:00
dependabot[bot]
4477644c74
Bump pypa/cibuildwheel from 2.18.0 to 2.19.2 (#116)
Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.18.0 to 2.19.2.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.18.0...v2.19.2)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-18 11:48:14 +08:00
Alex
8a048fb025
detect risc-v spacemit vmadot extension (#113)
update readme for riscv spacemit vmadot

Co-authored-by: Alex <jinghui.huang@spacemit.com>
2024-06-12 11:04:28 +08:00
20 changed files with 1081 additions and 18 deletions

View File

@ -191,12 +191,3 @@ jobs:
run: |
docker run -u root --rm -v $(pwd):/${{ github.workspace }} -w ${{ github.workspace }} --platform linux/${{ matrix.arch }} debian:unstable-slim \
/bin/bash -c "apt update && apt install -y gcc libc6-dev && gcc main.c -o ruapu && ./ruapu"
macos-flyci:
runs-on: flyci-macos-14-xlarge-m2
steps:
- uses: actions/checkout@v4
- name: build-test
run: |
clang main.c -o ruapu
./ruapu

View File

@ -23,7 +23,7 @@ jobs:
platforms: all
- name: cibuildwheel
uses: pypa/cibuildwheel@v2.18.0
uses: pypa/cibuildwheel@v2.20.0
env:
CIBW_ARCHS_LINUX: "x86_64 i686 aarch64 ppc64le s390x"
CIBW_ARCHS_MACOS: "x86_64 arm64 universal2"

View File

@ -62,14 +62,14 @@ _`fma4` on zen1, ISA in hypervisor, etc._
|CPU|ISA|
|:---:|---|
|x86|`mmx` `sse` `sse2` `sse3` `ssse3` `sse41` `sse42` `sse4a` `xop` `avx` `f16c` `fma` `fma4` `avx2` `avx512f` `avx512bw` `avx512cd` `avx512dq` `avx512vl` `avx512vnni` `avx512bf16` `avx512ifma` `avx512vbmi` `avx512vbmi2` `avx512fp16` `avx512er` `avx5124fmaps` `avx5124vnniw` `avxvnni` `avxvnniint8` `avxvnniint16` `avxifma` `amxfp16` `amxbf16` `amxint8` `amxtile`|
|x86|`mmx` `sse` `sse2` `sse3` `ssse3` `sse41` `sse42` `sse4a` `xop` `avx` `f16c` `fma` `fma4` `avx2` `avx512f` `avx512bw` `avx512cd` `avx512dq` `avx512vl` `avx512vnni` `avx512bf16` `avx512ifma` `avx512vbmi` `avx512vbmi2` `avx512fp16` `avx512er` `avx5124fmaps` `avx5124vnniw` `avxvnni` `avxvnniint8` `avxvnniint16` `avxifma` `amxfp16` `amxbf16` `amxint8` `amxtile` `bmi1` `bmi2` `gfni` `aesni` `vaes` `sha` `rdrand` `rdseed` `tsx`|
|arm|`half` `edsp` `neon` `vfpv4` `idiv`|
|aarch64|`neon` `vfpv4` `lse` `cpuid` `asimdrdm` `asimdhp` `asimddp` `asimdfhm` `bf16` `i8mm` `frint` `jscvt` `fcma` `mte` `mte2` `sve` `sve2` `svebf16` `svei8mm` `svef32mm` `svef64mm` `sme` `smef16f16` `smef64f64` `smei64i64` `pmull` `crc32` `aes` `sha1` `sha2` `sha3` `sha512` `sm3` `sm4` `svepmull` `svebitperm` `sveaes` `svesha3` `svesm4` `amx`|
|mips|`msa` `mmi` `sx` `asx` `msa2` `crypto`|
|powerpc|`vsx`|
|s390x|`zvector`|
|loongarch|`lsx` `lasx`|
|risc-v|`i` `m` `a` `f` `d` `c` `v` `zba` `zbb` `zbc` `zbs` `zbkb` `zbkc` `zbkx` `zfa` `zfbfmin` `zfh` `zfhmin` `zicond` `zicsr` `zifencei` `zmmul` `zvbb` `zvbc` `zvfh` `zvfhmin` `zvfbfmin` `zvfbfwma` `zvkb` `zvl32b` `zvl64b` `zvl128b` `zvl256b` `zvl512b` `zvl1024b` `xtheadba` `xtheadbb` `xtheadbs` `xtheadcondmov` `xtheadfmemidx` `xtheadfmv` `xtheadmac` `xtheadmemidx` `xtheadmempair` `xtheadsync` `xtheadvdot`|
|risc-v|`i` `m` `a` `f` `d` `c` `v` `zba` `zbb` `zbc` `zbs` `zbkb` `zbkc` `zbkx` `zcb` `zfa` `zfbfmin` `zfh` `zfhmin` `zicond` `zicsr` `zifencei` `zmmul` `zvbb` `zvbc` `zvfh` `zvfhmin` `zvfbfmin` `zvfbfwma` `zvkb` `zvl32b` `zvl64b` `zvl128b` `zvl256b` `zvl512b` `zvl1024b` `xtheadba` `xtheadbb` `xtheadbs` `xtheadcondmov` `xtheadfmemidx` `xtheadfmv` `xtheadmac` `xtheadmemidx` `xtheadmempair` `xtheadsync` `xtheadvdot` `spacemitvmadot` `spacemitvmadotn` `spacemitvfmadot`|
|openrisc| `orbis32` `orbis64` `orfpx32` `orfpx64` `orvdx64` |
## Let's ruapu
@ -495,6 +495,52 @@ class Example {
</td></tr>
</table>
### ruapu with cangjie
<table>
<tr><td>
Compile ruapu library
```bash
cd cangjie
cd c-src
cmake .
make
```
run example
```bash
cd cangjie
cjpm run
```
or compile example
```bash
cd cangjie
cjpm build
./target/release/bin/main
```
</td>
<td>
Use ruapu in cangjie
```swift
import ruapu.*
main(): Int64 {
ruapu_init()
let neon_supported = ruapu_supports("neon")
println("supports neon: ${neon_supported}")
let d = ruapu_rua()
for (i in d) {
println(i)
}
return 0
}
```
</td></tr>
</table>

14
cangjie/README.md Normal file
View File

@ -0,0 +1,14 @@
## ruapu cangjie
当前代码仓颉版本: `0.51.4`
> 仓颉目前处于内测阶段,不保证该代码在更新的仓颉编译器版本中可用
```bash
cd cangjie
cd c-src
cmake .
make
cd ..
cjpm run
```

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.5)
project(ruapu)
include_directories(../../)
add_library(ruapu
ruapu-binding.c
)

View File

@ -0,0 +1,14 @@
#define RUAPU_IMPLEMENTATION
#include "ruapu.h"
void ruapu_init_c() {
ruapu_init();
}
int ruapu_supports_c(const char* isa) {
return ruapu_supports(isa);
}
const char* const* ruapu_rua_c() {
return ruapu_rua();
}

16
cangjie/cjpm.toml Normal file
View File

@ -0,0 +1,16 @@
[dependencies]
[package]
cjc-version = "0.51.4"
compile-option = ""
description = "ruapu"
link-option = ""
name = "ruapu_cangjie"
output-type = "executable"
src-dir = ""
target-dir = ""
version = "1.0.0"
package-configuration = {}
[ffi.c]
ruapu = { path = "./c-src/" }

11
cangjie/src/main.cj Normal file
View File

@ -0,0 +1,11 @@
import ruapu.*
main(): Int64 {
ruapu_init()
let neon_supported = ruapu_supports("neon")
println("supports neon: ${neon_supported}")
let d = ruapu_rua()
for (i in d) {
println(i)
}
return 0
}

View File

@ -0,0 +1,30 @@
package ruapu
from std import collection.ArrayList
foreign func ruapu_init_c(): Unit
foreign func ruapu_supports_c(s: CString): Int32
foreign func ruapu_rua_c(): CPointer<CString>
public func ruapu_init(): Unit {
unsafe{ ruapu_init_c() }
}
public func ruapu_supports(isa: String): Bool {
var isa_c = unsafe { LibC.mallocCString(isa) }
let result_c = unsafe { ruapu_supports_c(isa_c) }
return result_c == 1
}
public func ruapu_rua(): Array<String> {
var ruaList = ArrayList<String>()
var sp = unsafe { ruapu_rua_c() }
while(!unsafe { sp.read().isNull() }) {
let temp = unsafe { sp.read() }
ruaList.append(temp.toString())
sp = unsafe { sp + 1 }
}
return Array<String>(ruaList)
}

View File

@ -0,0 +1,321 @@
{
"configVersion": 2,
"packages": [
{
"name": "_fe_analyzer_shared",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/_fe_analyzer_shared-73.0.0",
"packageUri": "lib/",
"languageVersion": "3.3"
},
{
"name": "_macros",
"rootUri": "file:///opt/homebrew/Cellar/dart/3.5.3/libexec/pkg/_macros",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "analyzer",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/analyzer-6.8.0",
"packageUri": "lib/",
"languageVersion": "3.3"
},
{
"name": "args",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/args-2.5.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "async",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/async-2.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "boolean_selector",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "collection",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/collection-1.19.0",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "convert",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/convert-3.1.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "coverage",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/coverage-1.9.2",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "crypto",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/crypto-3.0.5",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "ffi",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/ffi-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "file",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/file-7.0.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "frontend_server_client",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/frontend_server_client-4.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "glob",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/glob-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "http_multi_server",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/http_multi_server-3.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "http_parser",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/http_parser-4.1.0",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "io",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/io-1.0.4",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "js",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/js-0.7.1",
"packageUri": "lib/",
"languageVersion": "3.1"
},
{
"name": "lints",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/lints-4.0.0",
"packageUri": "lib/",
"languageVersion": "3.1"
},
{
"name": "logging",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/logging-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "macros",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/macros-0.1.2-main.4",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "matcher",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/matcher-0.12.16+1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "meta",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/meta-1.16.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "mime",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/mime-2.0.0",
"packageUri": "lib/",
"languageVersion": "3.2"
},
{
"name": "node_preamble",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/node_preamble-2.0.2",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "package_config",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/package_config-2.1.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/path-1.9.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "pool",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/pool-1.5.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "pub_semver",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/pub_semver-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/shelf-1.4.2",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "shelf_packages_handler",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/shelf_packages_handler-3.0.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "shelf_static",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/shelf_static-1.1.3",
"packageUri": "lib/",
"languageVersion": "3.3"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/shelf_web_socket-2.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "source_map_stack_trace",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/source_map_stack_trace-2.1.2",
"packageUri": "lib/",
"languageVersion": "3.3"
},
{
"name": "source_maps",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/source_maps-0.10.12",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "source_span",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/source_span-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stack_trace",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/stack_trace-1.12.0",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "stream_channel",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/stream_channel-2.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "string_scanner",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/string_scanner-1.3.0",
"packageUri": "lib/",
"languageVersion": "3.1"
},
{
"name": "term_glyph",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/term_glyph-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "test",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/test-1.25.8",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "test_api",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/test_api-0.7.3",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "test_core",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/test_core-0.6.5",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "typed_data",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/typed_data-1.3.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "vm_service",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/vm_service-14.3.0",
"packageUri": "lib/",
"languageVersion": "3.3"
},
{
"name": "watcher",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/watcher-1.1.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "web",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/web-1.1.0",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "web_socket",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/web_socket-0.1.6",
"packageUri": "lib/",
"languageVersion": "3.3"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/web_socket_channel-3.0.1",
"packageUri": "lib/",
"languageVersion": "3.3"
},
{
"name": "webkit_inspection_protocol",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/webkit_inspection_protocol-1.2.1",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "yaml",
"rootUri": "file:///Users/darren/.pub-cache/hosted/pub.dev/yaml-3.1.2",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "dartHello",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "3.4"
}
],
"generated": "2024-10-14T02:37:48.199003Z",
"generator": "pub",
"generatorVersion": "3.5.3",
"pubCache": "file:///Users/darren/.pub-cache"
}

22
dart/build.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/bash
PROJECT_DIR=$(pwd)
RUAPU_API_DIR="$PROJECT_DIR/ruapu-api"
BUILD_DIR="$PROJECT_DIR/build"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR" || exit
cmake "$RUAPU_API_DIR"
make
if [ $? -ne 0 ]; then
echo "编译失败,请检查错误信息。"
exit 1
fi
cd "$PROJECT_DIR" || exit
dart pub get
dart run main.dart

33
dart/main.dart Normal file
View File

@ -0,0 +1,33 @@
import 'dart:io';
import 'ruapu_api.dart';
import 'package:path/path.dart' as path;
void main() {
var libraryPath =
path.join(Directory.current.path, 'build', 'libruapu.so');
if (Platform.isMacOS) {
libraryPath =
path.join(Directory.current.path, 'build', 'libruapu.dylib');
}
if (Platform.isWindows) {
libraryPath = path.join(
Directory.current.path, 'build', 'Debug', 'hello.dll');
}
Ruapu api = Ruapu(libraryPath);
api.init();
List<String> isas = api.getRuapuISA();
print("This CPU Support:");
for (String isa in isas) {
print(isa);
}
print("=================");
String isaToCheck = 'aes';
bool isSupported = api.supportsISA(isaToCheck);
print('Does the system support $isaToCheck? $isSupported');
}

410
dart/pubspec.lock Normal file
View File

@ -0,0 +1,410 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "45cfa8471b89fb6643fe9bf51bd7931a76b8f5ec2d65de4fb176dba8d4f22c77"
url: "https://pub.dev"
source: hosted
version: "73.0.0"
_macros:
dependency: transitive
description: dart
source: sdk
version: "0.3.2"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: "4959fec185fe70cce007c57e9ab6983101dbe593d2bf8bbfb4453aaec0cf470a"
url: "https://pub.dev"
source: hosted
version: "6.8.0"
args:
dependency: transitive
description:
name: args
sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a"
url: "https://pub.dev"
source: hosted
version: "2.5.0"
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
url: "https://pub.dev"
source: hosted
version: "1.19.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: c1fb2dce3c0085f39dc72668e85f8e0210ec7de05345821ff58530567df345a5
url: "https://pub.dev"
source: hosted
version: "1.9.2"
crypto:
dependency: transitive
description:
name: crypto
sha256: ec30d999af904f33454ba22ed9a86162b35e52b44ac4807d1d93c288041d7d27
url: "https://pub.dev"
source: hosted
version: "3.0.5"
ffi:
dependency: "direct main"
description:
name: ffi
sha256: "13a6ccf6a459a125b3fcdb6ec73bd5ff90822e071207c663bfd1f70062d51d18"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
file:
dependency: transitive
description:
name: file
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
url: "https://pub.dev"
source: hosted
version: "7.0.1"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694
url: "https://pub.dev"
source: hosted
version: "4.0.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "40f592dd352890c3b60fec1b68e786cefb9603e05ff303dbc4dda49b304ecdf4"
url: "https://pub.dev"
source: hosted
version: "4.1.0"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js:
dependency: transitive
description:
name: js
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
url: "https://pub.dev"
source: hosted
version: "0.7.1"
lints:
dependency: "direct dev"
description:
name: lints
sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
macros:
dependency: transitive
description:
name: macros
sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536"
url: "https://pub.dev"
source: hosted
version: "0.1.2-main.4"
matcher:
dependency: transitive
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
meta:
dependency: transitive
description:
name: meta
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
url: "https://pub.dev"
source: hosted
version: "1.16.0"
mime:
dependency: transitive
description:
name: mime
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: "direct main"
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
shelf:
dependency: transitive
description:
name: shelf
sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12
url: "https://pub.dev"
source: hosted
version: "1.4.2"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3
url: "https://pub.dev"
source: hosted
version: "1.1.3"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b
url: "https://pub.dev"
source: hosted
version: "2.1.2"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
url: "https://pub.dev"
source: hosted
version: "1.12.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: "713a8789d62f3233c46b4a90b174737b2c04cb6ae4500f2aa8b1be8f03f5e67f"
url: "https://pub.dev"
source: hosted
version: "1.25.8"
test_api:
dependency: transitive
description:
name: test_api
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
url: "https://pub.dev"
source: hosted
version: "0.7.3"
test_core:
dependency: transitive
description:
name: test_core
sha256: "12391302411737c176b0b5d6491f466b0dd56d4763e347b6714efbaa74d7953d"
url: "https://pub.dev"
source: hosted
version: "0.6.5"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
url: "https://pub.dev"
source: hosted
version: "14.3.0"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web:
dependency: transitive
description:
name: web
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web_socket:
dependency: transitive
description:
name: web_socket
sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83"
url: "https://pub.dev"
source: hosted
version: "0.1.6"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.4.0 <4.0.0"

18
dart/pubspec.yaml Normal file
View File

@ -0,0 +1,18 @@
name: dartHello
version: 0.0.1
description: >-
A super simple example of calling C code from Dart with FFI
# This example isn't intended for publishing on pub.dev.
publish_to: none
environment:
sdk: ^3.4.0
dependencies:
path: ^1.9.0
ffi: ^1.0.0
dev_dependencies:
lints: ^4.0.0
test: ^1.25.0

View File

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
project(ruapu_library VERSION 1.0.0 LANGUAGES C)
add_library(ruapu_library SHARED ruapu.c ruapu.def)
include_directories(../../)
set_target_properties(ruapu_library PROPERTIES
PUBLIC_HEADER ../../ruapu.h
VERSION ${PROJECT_VERSION}
SOVERSION 1
OUTPUT_NAME "ruapu"
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Hex_Identity_ID_Goes_Here"
)

3
dart/ruapu-api/ruapu.c Normal file
View File

@ -0,0 +1,3 @@
#define RUAPU_IMPLEMENTATION
#include "ruapu.h"

5
dart/ruapu-api/ruapu.def Normal file
View File

@ -0,0 +1,5 @@
LIBRARY ruapu
EXPORTS
ruapu_rua
ruapu_supports
ruapu_init

63
dart/ruapu_api.dart Normal file
View File

@ -0,0 +1,63 @@
import 'dart:ffi'; // dart:ffi
import 'package:ffi/ffi.dart';
typedef RuapuRUA_C = Pointer<Pointer<Utf8>> Function();
typedef RuapuRUA_Dart = Pointer<Pointer<Utf8>> Function();
typedef RuapuInit_C = Void Function();
typedef RuapuInit_Dart = void Function();
typedef RuapuSupports_C = Int32 Function(Pointer<Utf8>);
typedef RuapuSupports_Dart = int Function(Pointer<Utf8>);
class Ruapu {
final DynamicLibrary _nativeLib;
Ruapu(String libraryPath) : _nativeLib = DynamicLibrary.open(libraryPath);
///
void init() {
final RuapuInit_Dart ruapu_init = _nativeLib
.lookup<NativeFunction<RuapuInit_C>>('ruapu_init')
.asFunction();
ruapu_init();
}
/// ISA列表
List<String> getRuapuISA() {
final RuapuRUA_Dart ruapu_rua = _nativeLib
.lookup<NativeFunction<RuapuRUA_C>>('ruapu_rua')
.asFunction();
Pointer<Pointer<Utf8>> result = ruapu_rua();
List<String> isas = [];
int index = 0;
while (true) {
Pointer<Utf8> strPtr = result.elementAt(index).value;
if (strPtr.address == 0) break; //
String str = strPtr.toDartString();
isas.add(str);
index++;
}
return isas;
}
/// ISA
bool supportsISA(String isa) {
final Pointer<Utf8> cIsa = isa.toNativeUtf8();
final RuapuSupports_Dart ruapu_supports = _nativeLib
.lookup<NativeFunction<RuapuSupports_C>>('ruapu_supports')
.asFunction();
int result = ruapu_supports(cIsa);
malloc.free(cIsa);
return result != 0;
}
}

14
main.c
View File

@ -52,6 +52,15 @@ int main()
PRINT_ISA_SUPPORT(amxbf16)
PRINT_ISA_SUPPORT(amxint8)
PRINT_ISA_SUPPORT(amxtile)
PRINT_ISA_SUPPORT(bmi1)
PRINT_ISA_SUPPORT(bmi2)
PRINT_ISA_SUPPORT(gfni)
PRINT_ISA_SUPPORT(aesni)
PRINT_ISA_SUPPORT(vaes)
PRINT_ISA_SUPPORT(sha)
PRINT_ISA_SUPPORT(rdrand)
PRINT_ISA_SUPPORT(rdseed)
PRINT_ISA_SUPPORT(tsx)
#elif __aarch64__ || defined(_M_ARM64)
PRINT_ISA_SUPPORT(neon)
@ -135,6 +144,7 @@ int main()
PRINT_ISA_SUPPORT(zbkb)
PRINT_ISA_SUPPORT(zbkc)
PRINT_ISA_SUPPORT(zbkx)
PRINT_ISA_SUPPORT(zcb)
PRINT_ISA_SUPPORT(zfa)
PRINT_ISA_SUPPORT(zfbfmin)
PRINT_ISA_SUPPORT(zfh)
@ -169,6 +179,10 @@ int main()
PRINT_ISA_SUPPORT(xtheadsync)
PRINT_ISA_SUPPORT(xtheadvdot)
PRINT_ISA_SUPPORT(spacemitvmadot)
PRINT_ISA_SUPPORT(spacemitvmadotn)
PRINT_ISA_SUPPORT(spacemitvfmadot)
#elif __openrisc__
PRINT_ISA_SUPPORT(orbis32)
PRINT_ISA_SUPPORT(orbis64)

42
ruapu.h
View File

@ -82,28 +82,29 @@ static int ruapu_detect_isa(ruapu_some_inst some_inst)
#include <signal.h>
#include <setjmp.h>
static int g_ruapu_sigill_caught = 0;
static int g_ruapu_sig_caught = 0;
static sigjmp_buf g_ruapu_jmpbuf;
static void ruapu_catch_sigill(int signo, siginfo_t* si, void* data)
static void ruapu_catch_sig(int signo, siginfo_t* si, void* data)
{
(void)signo;
(void)si;
(void)data;
g_ruapu_sigill_caught = 1;
g_ruapu_sig_caught = 1;
siglongjmp(g_ruapu_jmpbuf, -1);
}
static int ruapu_detect_isa(ruapu_some_inst some_inst)
{
g_ruapu_sigill_caught = 0;
g_ruapu_sig_caught = 0;
struct sigaction sa = { 0 };
struct sigaction old_sa;
sa.sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO;
sa.sa_sigaction = ruapu_catch_sigill;
sa.sa_sigaction = ruapu_catch_sig;
sigaction(SIGILL, &sa, &old_sa);
sigaction(SIGSEGV, &sa, &old_sa);
if (sigsetjmp(g_ruapu_jmpbuf, 1) == 0)
{
@ -111,8 +112,9 @@ static int ruapu_detect_isa(ruapu_some_inst some_inst)
}
sigaction(SIGILL, &old_sa, NULL);
sigaction(SIGSEGV, &old_sa, NULL);
return g_ruapu_sigill_caught ? 0 : 1;
return g_ruapu_sig_caught ? 0 : 1;
}
#elif defined __SYTERKIT__
@ -223,6 +225,15 @@ RUAPU_INSTCODE(amxfp16, 0xc4, 0xe2, 0x7b, 0x5c, 0xd1) // tdpfp16ps %tmm0, %tmm1,
RUAPU_INSTCODE(amxbf16, 0xc4, 0xe2, 0x7a, 0x5c, 0xd1) // tdpbf16ps %tmm0, %tmm1, %tmm2
RUAPU_INSTCODE(amxint8, 0xc4, 0xe2, 0x7b, 0x5e, 0xd1) // tdpbssd %tmm0, %tmm1, %tmm2
RUAPU_INSTCODE(amxtile, 0xc4, 0xe2, 0x7a, 0x49, 0xc0) // tilezero %tmm0
RUAPU_INSTCODE(bmi1, 0xc4, 0xe2, 0x78, 0xf2, 0xc0) // andn eax,eax,eax
RUAPU_INSTCODE(bmi2, 0xc4, 0xe2, 0x7b, 0xf6, 0xc0) // mulx eax,eax,eax
RUAPU_INSTCODE(gfni, 0x66, 0x0f, 0x38, 0xcf, 0xc0) // gf2p8mulb xmm0,xmm0
RUAPU_INSTCODE(aesni, 0x66, 0x0f, 0x38, 0xdc, 0xc0) // aesenc xmm0,xmm0
RUAPU_INSTCODE(vaes, 0xc4, 0xe2, 0x7d, 0xdc, 0xc0) // vaesenc ymm0,ymm0,ymm0
RUAPU_INSTCODE(sha, 0x0f, 0x38, 0xc9, 0xc0) // sha1msg1 xmm0,xmm0
RUAPU_INSTCODE(rdrand, 0x0f, 0xc7, 0xf0) // rdrand eax
RUAPU_INSTCODE(rdseed, 0x0f, 0xc7, 0xf8) // rdseed eax
RUAPU_INSTCODE(tsx, 0x0f, 0x01, 0xd6) // xtest
#elif __aarch64__ || defined(_M_ARM64)
RUAPU_INSTCODE(neon, 0x4e20d400) // fadd v0.4s,v0.4s,v0.4s
@ -314,6 +325,7 @@ RUAPU_INSTCODE(zbs, 0x48a51533) // bclr a0,a0,a0
RUAPU_INSTCODE(zbkb, 0x08a54533) // pack a0,a0,a0
RUAPU_INSTCODE(zbkc, 0x0aa53533) // clmulh a0,a0,a0
RUAPU_INSTCODE(zbkx, 0x28a52533) // xperm.n a0,a0,a0
RUAPU_INSTCODE(zcb, 0x9d759d75) // c.not a0 c.not a0
RUAPU_INSTCODE(zfa, 0xf0108053) // fli.s ft0, min
RUAPU_INSTCODE(zfbfmin, 0x44807053) // fcvt.bf16.s ft0,ft0
RUAPU_INSTCODE(zfh, 0x04007053); // fadd.hs ft0, ft0, ft0
@ -335,6 +347,10 @@ RUAPU_INSTCODE(xtheadmempair, 0xe0a1450b) // th.lwd a0,a0,(sp),#0,3
RUAPU_INSTCODE(xtheadsync, 0x0180000b) // th.sync
RUAPU_INSTCODE(xtheadvdot, 0x8000600b) // th.vmaqa.vv v0,v0,v0
RUAPU_INSTCODE(spacemitvmadot, 0xe200312b) // vmadot v2,v0,v0
RUAPU_INSTCODE(spacemitvmadotn, 0xe600b12b) // vmadot3 v2,v0,v1 //vmadot2 vmadot1
RUAPU_INSTCODE(spacemitvfmadot, 0xea00012b) // vfmadot v2,v0,v0
// RVV 1.0 support
// unimp (csrrw x0, cycle, x0)
#define RUAPU_RV_TRAP() asm volatile(".align 2\n.word 0xc0001073")
@ -429,6 +445,15 @@ RUAPU_ISAENTRY(amxfp16)
RUAPU_ISAENTRY(amxbf16)
RUAPU_ISAENTRY(amxint8)
RUAPU_ISAENTRY(amxtile)
RUAPU_ISAENTRY(bmi1)
RUAPU_ISAENTRY(bmi2)
RUAPU_ISAENTRY(gfni)
RUAPU_ISAENTRY(aesni)
RUAPU_ISAENTRY(vaes)
RUAPU_ISAENTRY(sha)
RUAPU_ISAENTRY(rdrand)
RUAPU_ISAENTRY(rdseed)
RUAPU_ISAENTRY(tsx)
#elif __aarch64__ || defined(_M_ARM64)
RUAPU_ISAENTRY(neon)
@ -512,6 +537,7 @@ RUAPU_ISAENTRY(zbs)
RUAPU_ISAENTRY(zbkb)
RUAPU_ISAENTRY(zbkc)
RUAPU_ISAENTRY(zbkx)
RUAPU_ISAENTRY(zcb)
RUAPU_ISAENTRY(zfa)
RUAPU_ISAENTRY(zfbfmin)
RUAPU_ISAENTRY(zfh)
@ -546,6 +572,10 @@ RUAPU_ISAENTRY(xtheadmempair)
RUAPU_ISAENTRY(xtheadsync)
RUAPU_ISAENTRY(xtheadvdot)
RUAPU_ISAENTRY(spacemitvmadot)
RUAPU_ISAENTRY(spacemitvmadotn)
RUAPU_ISAENTRY(spacemitvfmadot)
#elif __openrisc__
RUAPU_ISAENTRY(orbis32)
RUAPU_ISAENTRY(orbis64)