Enhance Python API to support retrieval of all available ISAs (#51)
* Enhance Python API to support retrieval of all available ISAs * add rua! ci * migrate to ruapu_rua()
This commit is contained in:
parent
fdead14410
commit
070f52dda3
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -38,6 +38,7 @@ jobs:
|
||||
cd python
|
||||
pip3 install .
|
||||
python3 -c 'import ruapu; print(ruapu.supports("neon")); print(ruapu.supports(isa="avx"))'
|
||||
python3 -c 'import ruapu; print(ruapu.rua())'
|
||||
- name: build-test-rust
|
||||
run: |
|
||||
rustup update stable
|
||||
@ -61,6 +62,7 @@ jobs:
|
||||
cd python
|
||||
pip3 install .
|
||||
python3 -c 'import ruapu; print(ruapu.supports("neon")); print(ruapu.supports(isa="avx"))'
|
||||
python3 -c 'import ruapu; print(ruapu.rua())'
|
||||
- name: build-test-rust
|
||||
run: |
|
||||
rustup update stable
|
||||
@ -84,6 +86,7 @@ jobs:
|
||||
cd python
|
||||
pip3 install .
|
||||
python3 -c 'import ruapu; print(ruapu.supports("neon")); print(ruapu.supports(isa="avx"))'
|
||||
python3 -c 'import ruapu; print(ruapu.rua())'
|
||||
- name: build-test-rust
|
||||
run: |
|
||||
rustup update stable
|
||||
@ -113,6 +116,7 @@ jobs:
|
||||
cd python
|
||||
pip3 install .
|
||||
python3 -c 'import ruapu; print(ruapu.supports("neon")); print(ruapu.supports(isa="avx"))'
|
||||
python3 -c 'import ruapu; print(ruapu.rua())'
|
||||
- name: build-test-rust
|
||||
run: |
|
||||
rustup update stable
|
||||
|
@ -117,6 +117,9 @@ ruapu.supports("avx2")
|
||||
|
||||
ruapu.supports(isa="avx2")
|
||||
# True
|
||||
|
||||
ruapu.rua()
|
||||
#(mmx', 'sse', 'sse2', 'sse3', 'ssse3', 'sse41', 'sse42', 'avx', 'f16c', 'fma', 'avx2')
|
||||
```
|
||||
</td></tr>
|
||||
</table>
|
||||
|
@ -15,9 +15,33 @@ static PyObject *ruapu_supports_py(PyObject *self, PyObject *args, PyObject *kwa
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
static PyObject *get_isa_items_py(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
const char* const* isa_supported = ruapu_rua();
|
||||
int total = 0;
|
||||
while(*isa_supported)
|
||||
{
|
||||
total++;
|
||||
isa_supported++;
|
||||
}
|
||||
|
||||
isa_supported = ruapu_rua();
|
||||
PyObject* supported_isa_py = PyTuple_New(total);
|
||||
|
||||
int tuple_idx = 0;
|
||||
while(*isa_supported)
|
||||
{
|
||||
PyTuple_SetItem(supported_isa_py, tuple_idx++, PyUnicode_FromString(*isa_supported));
|
||||
isa_supported++;
|
||||
}
|
||||
|
||||
return supported_isa_py;
|
||||
}
|
||||
|
||||
static PyMethodDef ruapu_methods[] =
|
||||
{
|
||||
{"supports", ruapu_supports_py, METH_VARARGS | METH_KEYWORDS, "Check if the CPU supports an instruction set"},
|
||||
{"rua", get_isa_items_py, METH_VARARGS | METH_KEYWORDS, "Get the instruction sets supported by the current CPU"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user